Skip to content

Commit 9164883

Browse files
ci(release): automate release of CLI (#2642)
* ci(release): add gh workflow to automatically create release pr * ci(release): create workflow for releasing all packages as latest * ci(release): remove unneeded release workflows * ci(release): replace worker image in docker image publish * ci(release): publish official docker image after npm publish * ci(release): adjust which packages get auto released * chore(ci): add name to release pr workflow * ci(release): add permissions for create release pr at workflow level * ci(release): add npm publish for specific pkg in case of err
1 parent e83202c commit 9164883

17 files changed

+265
-310
lines changed
+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Create Release PR
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
10+
jobs:
11+
create_release_pr:
12+
runs-on: ubuntu-latest
13+
env:
14+
# these are the packages we auto release (e.g. standalone pkgs like artillery/skytrace/types, and included dependencies like plugins)
15+
# some non-included dependencies are not released automatically (e.g. posthog, memory-inspector)
16+
# this list should be kept in sync with npm-publish-all-packages.yml
17+
PACKAGES_TO_RELEASE: "\
18+
artillery-engine-playwright,\
19+
artillery-plugin-apdex,\
20+
artillery-plugin-ensure,\
21+
artillery-plugin-expect,\
22+
artillery-plugin-fake-data,\
23+
artillery-plugin-metrics-by-endpoint,\
24+
artillery-plugin-publish-metrics,\
25+
commons,\
26+
core,\
27+
artillery,\
28+
skytrace"
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v3
32+
33+
# all packages receive minor version bump, except for artillery which receives a patch version bump as convention
34+
- name: Update package versions
35+
run: |
36+
for package in $(echo ${{ env.PACKAGES_TO_RELEASE }} | tr "," "\n"); do
37+
if [ "$package" = "artillery" ]; then
38+
npm version patch --workspace $package
39+
else
40+
npm version minor --workspace $package
41+
fi
42+
done
43+
44+
- name: Get new Artillery version
45+
run: |
46+
ARTILLERY_VERSION=$(node -e "console.log(require('./packages/artillery/package.json').version)")
47+
echo "ARTILLERY_VERSION=$ARTILLERY_VERSION" >> "$GITHUB_ENV"
48+
49+
- name: Create branch
50+
run: |
51+
export BRANCH_NAME=release/artillery-v${{ env.ARTILLERY_VERSION }}-$(date '+%Y-%m-%d-%H-%M-%S')
52+
echo "BRANCH_NAME=$BRANCH_NAME" >> "$GITHUB_ENV"
53+
git checkout -b $BRANCH_NAME
54+
git push --set-upstream origin $BRANCH_NAME
55+
56+
- name: Install dependencies
57+
run: npm ci
58+
59+
- name: Add changes to commit
60+
run: git add .
61+
62+
- name: Commit changes
63+
run: |
64+
git config --global user.name "${{ github.actor }}"
65+
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
66+
RELEASE_COMMIT_MSG="ci: release v${{ env.ARTILLERY_VERSION }} artillery" >> "$GITHUB_ENV"
67+
git commit -m "ci: release v${{ env.ARTILLERY_VERSION }} artillery"
68+
git push
69+
70+
- name: create pull request
71+
run: gh pr create -B main -H ${{ env.BRANCH_NAME }} --body 'Release v${{ env.ARTILLERY_VERSION }}. Created by Github action' --fill
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/docker-publish-artillery.yml

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
name: Publish Docker image for Artillery
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
paths:
8-
- packages/artillery/package.json
4+
workflow_call:
5+
inputs:
6+
COMMIT_SHA:
7+
description: 'Commit SHA'
8+
required: true
9+
type: string
10+
secrets:
11+
DOCKER_USERNAME:
12+
description: 'Docker Hub username'
13+
required: true
14+
DOCKER_PASSWORD:
15+
description: 'Docker Hub password'
16+
required: true
917

1018
jobs:
1119
push_to_registry:
@@ -20,6 +28,10 @@ jobs:
2028
run: |
2129
echo "ARTILLERY_VERSION=$(node -e 'console.log(require("./packages/artillery/package.json").version)')" >> $GITHUB_ENV
2230
31+
- run: node .github/workflows/scripts/replace-worker-version-in-js-file.js
32+
env:
33+
COMMIT_SHA: ${{ inputs.COMMIT_SHA }}
34+
2335
- name: Log in to Docker Hub
2436
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
2537
with:

.github/workflows/npm-publish-all-packages-canary.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ on:
1111
- 'packages/artillery-plugin-ensure/**'
1212
- 'packages/artillery-plugin-expect/**'
1313
- 'packages/artillery-plugin-metrics-by-endpoint/**'
14-
- 'packages/artillery-plugin-publish-metrics/**'
14+
- 'packages/artillery-plugin-publish-metrics/**'
15+
- 'packages/artillery-plugin-fake-data/**'
1516
- 'packages/commons/**'
1617
- 'packages/core/**'
1718
- 'packages/skytrace/**'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Publish packages to CLI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
#If there are changes to package.json and ci:release v is in commit msg, it's a release
8+
- 'packages/artillery/package.json'
9+
10+
jobs:
11+
publish-fargate-worker-image:
12+
if: "contains( github.event.head_commit.message, 'ci: release v')"
13+
uses: ./.github/workflows/docker-ecs-worker-image.yml
14+
permissions:
15+
contents: read
16+
id-token: write
17+
secrets:
18+
ECR_WORKER_IMAGE_PUSH_ROLE_ARN: ${{ secrets.ECR_WORKER_IMAGE_PUSH_ROLE_ARN }}
19+
20+
publish-packages-to-npm:
21+
runs-on: ubuntu-latest
22+
if: "contains( github.event.head_commit.message, 'ci: release v')"
23+
needs: publish-fargate-worker-image
24+
permissions:
25+
contents: read
26+
packages: write
27+
env:
28+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
29+
# this list should be kept in sync with create-release-pr.yml
30+
PACKAGES_TO_RELEASE: "\
31+
artillery-engine-playwright,\
32+
artillery-plugin-apdex,\
33+
artillery-plugin-ensure,\
34+
artillery-plugin-expect,\
35+
artillery-plugin-fake-data,\
36+
artillery-plugin-metrics-by-endpoint,\
37+
artillery-plugin-publish-metrics,\
38+
commons,\
39+
core,\
40+
artillery,\
41+
skytrace"
42+
steps:
43+
- uses: actions/checkout@v3
44+
- uses: actions/setup-node@v3
45+
with:
46+
node-version: '18.x'
47+
registry-url: 'https://registry.npmjs.org'
48+
scope: '@artilleryio'
49+
- run: node .github/workflows/scripts/replace-worker-version-in-js-file.js
50+
env:
51+
COMMIT_SHA: ${{ github.sha }}
52+
- run: node .github/workflows/scripts/rename-packages-to-correct-version.js
53+
env:
54+
PACKAGES_TO_REPLACE: ${{ env.PACKAGES_TO_RELEASE }}
55+
# It must be published in this specific order to account for order of dependencies (e.g. artillery depends on commons, core, etc), in case failures happen in publishing.
56+
- run: npm -w @artilleryio/int-commons publish
57+
- run: npm -w @artilleryio/int-core publish
58+
- run: npm -w artillery-plugin-expect publish
59+
- run: npm -w artillery-plugin-publish-metrics publish
60+
- run: npm -w artillery-plugin-metrics-by-endpoint publish
61+
- run: npm -w artillery-plugin-ensure publish
62+
- run: npm -w artillery-plugin-apdex publish
63+
- run: npm -w artillery-engine-posthog publish
64+
- run: npm -w artillery-engine-playwright publish
65+
- run: npm -w artillery-plugin-fake-data publish
66+
- run: npm -w artillery publish
67+
# Skytrace is a Typescript Package and needs to install -> build -> publish
68+
- run: npm install -w skytrace --ignore-scripts
69+
- run: npm run build -w skytrace
70+
- run: npm -w skytrace publish
71+
72+
publish-official-docker-image:
73+
uses: ./.github/workflows/docker-publish-artillery.yml
74+
needs: publish-packages-to-npm
75+
with:
76+
COMMIT_SHA: ${{ github.sha }}
77+
secrets:
78+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
79+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

.github/workflows/npm-publish-artillery-engine-playwright.yml

-24
This file was deleted.

.github/workflows/npm-publish-artillery-plugin-apdex.yml

-24
This file was deleted.

.github/workflows/npm-publish-artillery-plugin-ensure.yml

-24
This file was deleted.

.github/workflows/npm-publish-artillery-plugin-expect.yml

-24
This file was deleted.

.github/workflows/npm-publish-artillery-plugin-fake-data.yml

-24
This file was deleted.

.github/workflows/npm-publish-artillery-plugin-metrics-by-endpoint.yml

-24
This file was deleted.

.github/workflows/npm-publish-artillery-plugin-publish-metrics.yml

-24
This file was deleted.

0 commit comments

Comments
 (0)