|
| 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