Skip to content

Commit

Permalink
Add gitlab release job (#184)
Browse files Browse the repository at this point in the history
* add release script

* add gitlab workflow

* remove VERSION, the script use the VERSION file

* install zip in the before_script

* set VERSION var to the file content

* PLINT-259

* apply suggestions
  • Loading branch information
NouemanKHAL authored Nov 17, 2023
1 parent 8632cac commit cf133e3
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
variables:
RELEASE_BUCKET:
value: "cloudfoundry.datadoghq.com/datadog-cloudfoundry-buildpack"
description: "Bucket where the buildpack release will be stored"
DRY_RUN:
value: "true"
description: "Set to true to do a dry run"
REPO_BRANCH:
value: "master"
description: "The branch to use"


buildpack-prod-release:
stage: deploy
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-builders/gitlab_agent_deploy:v6554890-8eae026
tags: ["runner:main"]
when: manual
before_script:
- apt-get update -y && apt-get install -y zip
script:
- 'export PRODUCTION=true'
- ./scripts/release.sh
39 changes: 39 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash -l

# http://redsymbol.net/articles/unofficial-bash-strict-mode/
IFS=$'\n\t'
set -euxo pipefail

# Make sure variables are set
PRODUCTION=${PRODUCTION:-"false"}
STAGING=${STAGING:-"false"}
DRY_RUN=${DRY_RUN:-"true"}
RELEASE_BUCKET=${RELEASE_BUCKET:-"false"}
REPO_BRANCH=${REPO_BRANCH:-"master"}


VERSION=$(cat VERSION)

git checkout $REPO_BRANCH

echo "Preparing the buildpack"
REFRESH_ASSETS=1 ./scripts/prepare.sh

echo "Building the buildpack version $VERSION"
./scripts/build.sh

if [ "$DRY_RUN" == "true" ]; then
exit 0
fi


echo "publishing the buildpack artifact"

if [ "$RELEASE_BUCKET" -a "$RELEASE_BUCKET" != "false" ]; then
if [ "$PRODUCTION" = "true" ]; then
# the production release bucket is cloudfoundry.datadoghq.com/datadog-cloudfoundry-buildpack
aws s3 cp datadog-cloudfoundry-buildpack-$VERSION.zip s3://$RELEASE_BUCKET/datadog-cloudfoundry-buildpack-$VERSION.zip --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers full=id=3a6e02b08553fd157ae3fb918945dd1eaae5a1aa818940381ef07a430cf25732

aws s3 cp datadog-cloudfoundry-buildpack-$VERSION.zip s3://$RELEASE_BUCKET/datadog-cloudfoundry-buildpack-latest.zip --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers full=id=3a6e02b08553fd157ae3fb918945dd1eaae5a1aa818940381ef07a430cf25732
fi
fi

0 comments on commit cf133e3

Please sign in to comment.