From 6e0cc17d0737accd21679eee56dc78543341c437 Mon Sep 17 00:00:00 2001 From: Bastien Caudan Date: Mon, 22 Apr 2024 14:27:58 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8split=20release=20deployment=20into=20?= =?UTF-8?q?manual=20or=20auto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 90 +++---------------------------- .gitlab/deploy-auto.yml | 60 +++++++++++++++++++++ .gitlab/deploy-manual.yml | 108 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 176 insertions(+), 82 deletions(-) create mode 100644 .gitlab/deploy-auto.yml create mode 100644 .gitlab/deploy-manual.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fdc581c453..1b9d9da188 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,6 @@ stages: - after-tests - browserstack - pre-deploy - - pre-deploy-notify - deploy:canary - notify:canary - deploy @@ -306,67 +305,21 @@ deploy-prod-canary: - node ./scripts/deploy/deploy.js prod canary root - node ./scripts/deploy/upload-source-maps.js canary root -.deploy-prod: +deploy-manual: stage: deploy extends: - - .base-configuration - .tags - when: manual - allow_failure: false - script: - - export BUILD_MODE=release - - VERSION=$(node -p -e "require('./lerna.json').version") - - yarn - - yarn build:bundle - - node ./scripts/deploy/check-monitors.js $UPLOAD_PATH - - node ./scripts/deploy/deploy.js prod v${VERSION%%.*} $UPLOAD_PATH - - node ./scripts/deploy/upload-source-maps.js v${VERSION%%.*} $UPLOAD_PATH - -step-1_deploy-prod-minor-dcs: - extends: - - .deploy-prod - variables: - UPLOAD_PATH: us3,us5,ap1 - -step-2_deploy-prod-eu1: - extends: - - .deploy-prod - variables: - UPLOAD_PATH: eu1 - -step-3_deploy-prod-us1: - extends: - - .deploy-prod - variables: - UPLOAD_PATH: us1 - -step-4_deploy-prod-gov: - extends: - - .deploy-prod - variables: - UPLOAD_PATH: root - -step-5_publish-npm: - stage: deploy - extends: - - .base-configuration - - .tags - when: manual - allow_failure: false - script: - - yarn - - node ./scripts/deploy/publish-npm.js + trigger: + include: + - local: .gitlab/deploy-manual.yml -step-6_publish-developer-extension: +deploy-auto: stage: deploy extends: - - .base-configuration - .tags - when: manual - allow_failure: false - script: - - yarn - - node ./scripts/deploy/publish-developer-extension.js + trigger: + include: + - local: .gitlab/deploy-auto.yml ######################################################################################################################## # Notify @@ -395,15 +348,6 @@ notify-staging-failure: - 'MESSAGE_TEXT=":host-red: $CI_PROJECT_NAME main pipeline for <$BUILD_URL|$COMMIT_MESSAGE> failed."' - postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT" -notify-release-ready: - stage: pre-deploy-notify - extends: - - .prepare_notification - - .tags - script: - - 'MESSAGE_TEXT=":i: $CI_PROJECT_NAME <$BUILD_URL|$COMMIT_MESSAGE> ready to be deployed to :datadog:"' - - postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT" - notify-prod-canary-success: stage: notify:canary extends: @@ -424,24 +368,6 @@ notify-prod-canary-failure: - 'MESSAGE_TEXT=":host-red: $CI_PROJECT_NAME release pipeline <$BUILD_URL|$COMMIT_MESSAGE> failed."' - postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT" -notify-prod-stable-success: - extends: - - .prepare_notification - - .tags - script: - - 'MESSAGE_TEXT=":rocket: $CI_PROJECT_NAME <$COMMIT_URL|$COMMIT_MESSAGE> deployed to :earth_americas:."' - - postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT" - - postmessage "#rum-browser-sdk-ops" "$MESSAGE_TEXT" - -notify-prod-stable-failure: - extends: - - .prepare_notification - - .tags - when: on_failure - script: - - 'MESSAGE_TEXT=":host-red: $CI_PROJECT_NAME release pipeline <$BUILD_URL|$COMMIT_MESSAGE> failed."' - - postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT" - ######################################################################################################################## # To staging CI ######################################################################################################################## diff --git a/.gitlab/deploy-auto.yml b/.gitlab/deploy-auto.yml new file mode 100644 index 0000000000..43e953bbbb --- /dev/null +++ b/.gitlab/deploy-auto.yml @@ -0,0 +1,60 @@ +stages: + - pre-notify + - deploy + - post-notify + +.base-configuration: + tags: ['runner:main', 'size:large'] + image: $CI_IMAGE + +deploy-auto: + stage: deploy + extends: + - .base-configuration + when: manual + allow_failure: false + script: + - export BUILD_MODE=release + - VERSION=$(node -p -e "require('./lerna.json').version") + - yarn + - yarn build:bundle + - node ./scripts/deploy-auto.js v${VERSION%%.*} + +######################################################################################################################## +# Notify +######################################################################################################################## + +include: 'https://gitlab-templates.ddbuild.io/slack-notifier/v1/template.yml' + +.prepare_notification: + extends: .slack-notifier-base + before_script: + - COMMIT_MESSAGE=`git show-branch --no-name HEAD` + - BUILD_URL="$CI_PROJECT_URL/pipelines/$CI_PIPELINE_ID" + - COMMIT_URL="$CI_PROJECT_URL/commits/$CI_COMMIT_SHA" + +notify-deploy-ready: + stage: pre-notify + extends: + - .prepare_notification + script: + - 'MESSAGE_TEXT=":i: $CI_PROJECT_NAME <$BUILD_URL|$COMMIT_MESSAGE> ready to be deployed *automatically* to :datadog:"' + - postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT" + +notify-deploy-success: + stage: post-notify + extends: + - .prepare_notification + script: + - 'MESSAGE_TEXT=":rocket: $CI_PROJECT_NAME <$COMMIT_URL|$COMMIT_MESSAGE> *automatically* deployed to :earth_americas:."' + - postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT" + - postmessage "#rum-browser-sdk-ops" "$MESSAGE_TEXT" + +notify-deploy-failure: + stage: post-notify + extends: + - .prepare_notification + when: on_failure + script: + - 'MESSAGE_TEXT=":host-red: $CI_PROJECT_NAME *automatic* deployment of <$BUILD_URL|$COMMIT_MESSAGE> failed."' + - postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT" diff --git a/.gitlab/deploy-manual.yml b/.gitlab/deploy-manual.yml new file mode 100644 index 0000000000..977c61afab --- /dev/null +++ b/.gitlab/deploy-manual.yml @@ -0,0 +1,108 @@ +stages: + - pre-notify + - deploy + - post-notify + +.base-configuration: + tags: ['runner:main', 'size:large'] + image: $CI_IMAGE + +.deploy-prod: + stage: deploy + when: manual + allow_failure: false + script: + - export BUILD_MODE=release + - VERSION=$(node -p -e "require('./lerna.json').version") + - yarn + - yarn build:bundle + - node ./scripts/deploy/check-monitors.js $UPLOAD_PATH + - node ./scripts/deploy/deploy.js prod v${VERSION%%.*} $UPLOAD_PATH + - node ./scripts/deploy/upload-source-maps.js v${VERSION%%.*} $UPLOAD_PATH + +step-1_deploy-prod-minor-dcs: + extends: + - .base-configuration + - .deploy-prod + variables: + UPLOAD_PATH: us3,us5,ap1 + +step-2_deploy-prod-eu1: + extends: + - .base-configuration + - .deploy-prod + variables: + UPLOAD_PATH: eu1 + +step-3_deploy-prod-us1: + extends: + - .base-configuration + - .deploy-prod + variables: + UPLOAD_PATH: us1 + +step-4_deploy-prod-gov: + extends: + - .base-configuration + - .deploy-prod + variables: + UPLOAD_PATH: root + +step-5_publish-npm: + stage: deploy + extends: + - .base-configuration + when: manual + allow_failure: false + script: + - yarn + - node ./scripts/deploy/publish-npm.js + +step-6_publish-developer-extension: + stage: deploy + extends: + - .base-configuration + when: manual + allow_failure: false + script: + - yarn + - node ./scripts/deploy/publish-developer-extension.js + +######################################################################################################################## +# Notify +######################################################################################################################## + +include: 'https://gitlab-templates.ddbuild.io/slack-notifier/v1/template.yml' + +.prepare_notification: + extends: .slack-notifier-base + before_script: + - COMMIT_MESSAGE=`git show-branch --no-name HEAD` + - BUILD_URL="$CI_PROJECT_URL/pipelines/$CI_PIPELINE_ID" + - COMMIT_URL="$CI_PROJECT_URL/commits/$CI_COMMIT_SHA" + +notify-deploy-ready: + stage: pre-notify + extends: + - .prepare_notification + script: + - 'MESSAGE_TEXT=":i: $CI_PROJECT_NAME <$BUILD_URL|$COMMIT_MESSAGE> ready to be deployed *manually* to :datadog:"' + - postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT" + +notify-deploy-success: + stage: post-notify + extends: + - .prepare_notification + script: + - 'MESSAGE_TEXT=":rocket: $CI_PROJECT_NAME <$COMMIT_URL|$COMMIT_MESSAGE> *manually* deployed to :earth_americas:."' + - postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT" + - postmessage "#rum-browser-sdk-ops" "$MESSAGE_TEXT" + +notify-deploy-failure: + stage: post-notify + extends: + - .prepare_notification + when: on_failure + script: + - 'MESSAGE_TEXT=":host-red: $CI_PROJECT_NAME *manual* deployment of <$BUILD_URL|$COMMIT_MESSAGE> failed."' + - postmessage "#browser-sdk-deploy" "$MESSAGE_TEXT"