Skip to content

Commit 7567ec8

Browse files
authored
ci: create GitHub releases for release candidate branches (#7862)
## Problem The AWS Toolkit VSCode project lacked a streamlined release candidate workflow. Creating release candidates would require manual branch creation and version management. ## Solution Added automated release candidate support: - Created `.github/workflows/setup-release-candidate.yml `- Workflow to create RC branches with automatic version bumping - Supports `Major/Minor/Patch/Custom` version increments - Reads and increments both `toolkit` and `amazonq` package versions independently - Creates date-based RC branches (`rc-YYYYMMDD`) - Commits version changes and pushes the RC branch - Updated `.github/workflows/release.yml` - Added support for `release/* ` branches - Automatically creates `rc-*` prefixed releases for release candidate branches - Proper release naming for RC artifacts This enables a clean RC workflow: trigger the setup workflow with a commit ID and version increment type, then the release pipeline automatically handles the rest. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 14611c3 commit 7567ec8

File tree

2 files changed

+123
-7
lines changed

2 files changed

+123
-7
lines changed

.github/workflows/release.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
required: false
1313
default: prerelease
1414
push:
15-
branches: [master, feature/*]
15+
branches: [master, feature/*, release/*]
1616
# tags:
1717
# - v[0-9]+.[0-9]+.[0-9]+
1818

@@ -40,12 +40,16 @@ jobs:
4040
# run: echo 'TAG_NAME=prerelease' >> $GITHUB_ENV
4141
- if: github.event_name == 'workflow_dispatch'
4242
run: echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
43-
- if: github.ref_name != 'master'
43+
- if: startsWith(github.ref_name, 'feature/')
4444
run: |
45-
TAG_NAME=${{ github.ref_name }}
46-
FEAT_NAME=$(echo $TAG_NAME | sed 's/feature\///')
45+
FEAT_NAME=$(echo ${{ github.ref_name }} | sed 's/feature\///')
4746
echo "FEAT_NAME=$FEAT_NAME" >> $GITHUB_ENV
4847
echo "TAG_NAME=pre-$FEAT_NAME" >> $GITHUB_ENV
48+
- if: startsWith(github.ref_name, 'release/')
49+
run: |
50+
RC_NAME=$(echo ${{ github.ref_name }} | sed 's/release\///')
51+
echo "FEAT_NAME=" >> $GITHUB_ENV
52+
echo "TAG_NAME=rc-$RC_NAME" >> $GITHUB_ENV
4953
- if: github.ref_name == 'master'
5054
run: |
5155
echo "FEAT_NAME=" >> $GITHUB_ENV
@@ -105,10 +109,14 @@ jobs:
105109
- uses: actions/checkout@v4
106110
- uses: actions/download-artifact@v4
107111
- name: Delete existing prerelease
108-
# "prerelease" (main branch) or "pre-<feature>"
109-
if: "env.TAG_NAME == 'prerelease' || startsWith(env.TAG_NAME, 'pre-')"
112+
# "prerelease" (main branch), "pre-<feature>", or "rc-<date>"
113+
if: env.TAG_NAME == 'prerelease' || startsWith(env.TAG_NAME, 'pre-') || startsWith(env.TAG_NAME, 'rc-')
110114
run: |
111-
echo "SUBJECT=AWS IDE Extensions: ${FEAT_NAME:-${TAG_NAME}}" >> $GITHUB_ENV
115+
if [[ "$TAG_NAME" == rc-* ]]; then
116+
echo "SUBJECT=AWS IDE Extensions Release Candidate: ${TAG_NAME#rc-}" >> $GITHUB_ENV
117+
else
118+
echo "SUBJECT=AWS IDE Extensions: ${FEAT_NAME:-${TAG_NAME}}" >> $GITHUB_ENV
119+
fi
112120
gh release delete "$TAG_NAME" --cleanup-tag --yes || true
113121
# git push origin :"$TAG_NAME" || true
114122
- name: Publish Prerelease
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Setup Release Candidate
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
versionIncrement:
7+
description: 'Release Version Increment'
8+
default: 'Minor'
9+
required: true
10+
type: choice
11+
options:
12+
- Major
13+
- Minor
14+
- Patch
15+
- Custom
16+
customVersion:
17+
description: "Custom Release Version (only used if release increment is 'Custom') - Format: 3.15.0"
18+
default: ''
19+
required: false
20+
type: string
21+
commitId:
22+
description: 'Commit ID to create RC from'
23+
required: true
24+
type: string
25+
26+
jobs:
27+
setup-rc:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
ref: ${{ inputs.commitId }}
33+
token: ${{ secrets.GITHUB_TOKEN }}
34+
persist-credentials: true
35+
36+
- name: Setup Node.js
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: '18'
40+
cache: 'npm'
41+
42+
- name: Calculate Release Versions
43+
id: release-version
44+
run: |
45+
customVersion="${{ inputs.customVersion }}"
46+
versionIncrement="${{ inputs.versionIncrement }}"
47+
48+
increment_version() {
49+
local currentVersion=$1
50+
if [[ "$versionIncrement" == "Custom" && -n "$customVersion" ]]; then
51+
echo "$customVersion"
52+
else
53+
IFS='.' read -r major minor patch <<< "$currentVersion"
54+
case "$versionIncrement" in
55+
"Major")
56+
major=$((major + 1))
57+
minor=0
58+
patch=0
59+
;;
60+
"Minor")
61+
minor=$((minor + 1))
62+
patch=0
63+
;;
64+
"Patch")
65+
patch=$((patch + 1))
66+
;;
67+
esac
68+
echo "$major.$minor.$patch"
69+
fi
70+
}
71+
72+
# Read and increment toolkit version
73+
toolkitCurrentVersion=$(node -e "console.log(require('./packages/toolkit/package.json').version)" | sed 's/-SNAPSHOT//')
74+
toolkitNewVersion=$(increment_version "$toolkitCurrentVersion")
75+
76+
# Read and increment amazonq version
77+
amazonqCurrentVersion=$(node -e "console.log(require('./packages/amazonq/package.json').version)" | sed 's/-SNAPSHOT//')
78+
amazonqNewVersion=$(increment_version "$amazonqCurrentVersion")
79+
80+
echo "TOOLKIT_VERSION=$toolkitNewVersion" >> $GITHUB_OUTPUT
81+
echo "AMAZONQ_VERSION=$amazonqNewVersion" >> $GITHUB_OUTPUT
82+
# Use date-based branch naming instead of version-based because we release
83+
# both extensions (toolkit and amazonq) from the same branch, and they may
84+
# have different version numbers. We can change this in the future
85+
echo "BRANCH_NAME=rc-$(date +%Y%m%d)" >> $GITHUB_OUTPUT
86+
87+
- name: Create RC Branch and Update Versions
88+
env:
89+
TOOLKIT_VERSION: ${{ steps.release-version.outputs.TOOLKIT_VERSION }}
90+
AMAZONQ_VERSION: ${{ steps.release-version.outputs.AMAZONQ_VERSION }}
91+
BRANCH_NAME: ${{ steps.release-version.outputs.BRANCH_NAME }}
92+
run: |
93+
git config user.name "aws-toolkit-automation"
94+
git config user.email "<>"
95+
96+
# Create RC branch using date-based naming
97+
git checkout -b $BRANCH_NAME
98+
99+
# Update package versions individually
100+
npm version --no-git-tag-version $TOOLKIT_VERSION -w packages/toolkit
101+
npm version --no-git-tag-version $AMAZONQ_VERSION -w packages/amazonq
102+
103+
# Commit version changes
104+
git add packages/toolkit/package.json packages/amazonq/package.json package-lock.json
105+
git commit -m "Bump versions: toolkit=$TOOLKIT_VERSION, amazonq=$AMAZONQ_VERSION"
106+
107+
# Push RC branch
108+
git push origin $BRANCH_NAME

0 commit comments

Comments
 (0)