Skip to content

Commit

Permalink
chore: Add support for additional deployment channels (#5098)
Browse files Browse the repository at this point in the history
* chore: add new differentiation of deployments

* chore: for testing disable branch filters

* chore: update noop job

* chore: disable uploading artifacts for testing

* revert: disable uploading artifacts for testing

This reverts commit 872de216e028f599741f2e478afa1fcb410782ef.

* chore: temporary move deployment jobs

* chore: fix message

* chore: test main

* chore: update message

* revert: temporary changes

* chore: use smaller resource for no-op
  • Loading branch information
PeterSchafer authored Mar 11, 2024
1 parent af382ea commit 5e1b1b7
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 13 deletions.
85 changes: 74 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ executors:
alpine:
docker:
- image: alpine:3.17
generic-ubuntu:
docker:
- image: ubuntu:latest
resource_class: small
docker-amd64:
docker:
- image: bastiandoetsch209/cli-build:20240214-145818
Expand Down Expand Up @@ -343,6 +347,19 @@ commands:
- attach_workspace:
at: .

shall-deploy:
parameters:
deployment:
type: string
steps:
- run:
name: Shall deployment be done
command: |
if [ "$(./release-scripts/skip-deployment.sh << parameters.deployment >>)" == true ]; then
echo The current branch does not deploy to \"<< parameters.deployment >>\"
circleci-agent step halt
fi
####################################################################################################
# WORKFLOWS
####################################################################################################
Expand Down Expand Up @@ -724,12 +741,11 @@ workflows:
branches:
only:
- main
- '/release.*/'
- '/.*e2e.*/'

- release-s3:
name: upload preview
deployment: preview
context: team-hammerhead-common-deploy-tokens
- noop:
name: Start Deployments
requires:
- Validate NPM artifacts (docker-amd64)
- Validate NPM artifacts (win-server2019-amd64)
Expand All @@ -752,27 +768,57 @@ workflows:
- e2e fips tests (win-server2022-amd64)
filters:
branches:
only: main
only:
- main
- '/release.*/'

- release-s3:
name: upload latest
deployment: latest
name: upload preview
deployment: preview
context: team-hammerhead-common-deploy-tokens
requires:
- upload preview
- Start Deployments
filters:
branches:
only: main
only:
- main
- '/release.*/'

- release-s3:
name: upload release candidate
deployment: rc
context: team-hammerhead-common-deploy-tokens
requires:
- Start Deployments
filters:
branches:
only:
- main
- '/release.*/'

- release-s3:
name: upload latest/stable
deployment: stable
context: team-hammerhead-common-deploy-tokens
requires:
- Start Deployments
filters:
branches:
only:
- main
- '/release.*/'

- release-github:
name: upload github
context: team-hammerhead-common-deploy-tokens
requires:
- upload latest
- upload latest/stable
filters:
branches:
only:
- main
- '/release.*/'

- release-npm:
name: upload npm
context: team-hammerhead-common-deploy-tokens
Expand All @@ -782,6 +828,7 @@ workflows:
branches:
only:
- main
- '/release.*/'

- trigger-building-snyk-images:
name: Trigger building snyk-images
Expand All @@ -792,6 +839,7 @@ workflows:
branches:
only:
- main
- '/release.*/'

####################################################################################################
# JOBS
Expand Down Expand Up @@ -1176,10 +1224,12 @@ jobs:
parameters:
deployment:
type: string
default: latest
default: stable
executor: docker-amd64
steps:
- prepare-workspace
- shall-deploy:
deployment: << parameters.deployment >>
- aws-cli/install:
version: << pipeline.parameters.aws_version >>
- run:
Expand All @@ -1191,6 +1241,8 @@ jobs:
executor: docker-amd64
steps:
- prepare-workspace
- shall-deploy:
deployment: stable
- gh/setup:
token: HAMMERHEAD_GITHUB_PAT
version: << pipeline.parameters.gh_version >>
Expand All @@ -1203,6 +1255,8 @@ jobs:
executor: docker-amd64
steps:
- prepare-workspace
- shall-deploy:
deployment: stable
- run:
name: Publish to npm
command: ./release-scripts/upload-artifacts.sh npm
Expand All @@ -1212,7 +1266,16 @@ jobs:
executor: docker-amd64
steps:
- prepare-workspace
- shall-deploy:
deployment: stable
- run:
name: Trigger build-and-publish workflow at snyk-images
command: ./release-scripts/upload-artifacts.sh trigger-snyk-images
- failed-release-notification

noop:
executor: generic-ubuntu
steps:
- run:
name: No operation
command: echo Nothing to be done!
3 changes: 1 addition & 2 deletions release-scripts/determine-release-channel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ set -euo pipefail
# - dev


# enable support for stable, preview and other release channels
ENABLE_STABLE_CHANNELS=false
ENABLE_STABLE_CHANNELS=$($(dirname "$0")/enable-stable-release-channels.sh)

CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [ $ENABLE_STABLE_CHANNELS == true ]; then # support for stable, preview and release candidate
Expand Down
6 changes: 6 additions & 0 deletions release-scripts/enable-stable-release-channels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail

# enable support for stable, preview and other release channels
ENABLE_STABLE_CHANNELS=false
echo $ENABLE_STABLE_CHANNELS
20 changes: 20 additions & 0 deletions release-scripts/skip-deployment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail
# Based on the given release channel as an argument, this script checks if the current
# branch is used for this channel.

TEST_CHANNEL=$1
ENABLE_STABLE_CHANNELS=$($(dirname "$0")/enable-stable-release-channels.sh)

# legacy release channel mapping (preview=stable)
if [ "$TEST_CHANNEL" == "preview" ] && [ "$ENABLE_STABLE_CHANNELS" == false ]; then
TEST_CHANNEL=stable
fi

RELEASE_CHANNEL="$($(dirname "$0")/determine-release-channel.sh)"
if [ "$RELEASE_CHANNEL" == $TEST_CHANNEL ]; then
echo false
exit 0
fi

echo true
5 changes: 5 additions & 0 deletions release-scripts/upload-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -211,5 +211,10 @@ for arg in "${@}"; do
# Upload files to S3 bucket
else
upload_s3 "${target}"

# stable and latest are the same target
if [ "${target}" == "stable" ]; then
upload_s3 "latest"
fi
fi
done

0 comments on commit 5e1b1b7

Please sign in to comment.