diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..5e4e226 --- /dev/null +++ b/.gitlab-ci.yml @@ -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 diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 0000000..67004f3 --- /dev/null +++ b/scripts/release.sh @@ -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