88 required : true
99 type : choice
1010 options :
11- - preview
12- - preview-major
1311 - patch
1412 - minor
1513 - major
@@ -35,13 +33,28 @@ jobs:
3533 outputs :
3634 version : ${{ steps.bump.outputs.version }}
3735 branch : ${{ steps.bump.outputs.branch }}
36+ dist_tag : ${{ steps.release-meta.outputs.dist_tag }}
37+ base_branch : ${{ steps.release-meta.outputs.base_branch }}
3838
3939 steps :
40- - name : Validate running from main
40+ - name : Determine release metadata
41+ id : release-meta
4142 run : |
42- if [[ "${{ github.ref }}" != "refs/heads/main" ]]; then
43- echo "⚠️ WARNING: Running from ${{ github.ref }}"
44- echo "⚠️ Production releases should only run from main branch"
43+ BRANCH_NAME="${{ github.ref_name }}"
44+ VERSION_BUMP="${{ github.event.inputs.bump_type }}"
45+
46+ if [[ "$BRANCH_NAME" == "main" ]]; then
47+ echo "dist_tag=latest" >> $GITHUB_OUTPUT
48+ echo "base_branch=main" >> $GITHUB_OUTPUT
49+ else
50+ if [[ "$VERSION_BUMP" != "prerelease" ]]; then
51+ echo "❌ ERROR: Only the prerelease bump type is allowed from non-main branches."
52+ echo "Current branch: $BRANCH_NAME, bump type: $VERSION_BUMP"
53+ exit 1
54+ fi
55+ echo "dist_tag=preview" >> $GITHUB_OUTPUT
56+ echo "base_branch=$BRANCH_NAME" >> $GITHUB_OUTPUT
57+ echo "ℹ️ Publishing preview release from branch: $BRANCH_NAME"
4558 fi
4659
4760 - name : Checkout code
@@ -151,46 +164,39 @@ jobs:
151164 env :
152165 GH_TOKEN : ${{ github.token }}
153166 NEW_VERSION : ${{ steps.bump.outputs.version }}
154- GITHUB_REF : ${{ github.ref }}
167+ BASE_BRANCH : ${{ steps.release-meta.outputs.base_branch }}
168+ DIST_TAG : ${{ steps.release-meta.outputs.dist_tag }}
155169 GITHUB_ACTOR : ${{ github.actor }}
156170 run : |
157171 BRANCH_NAME="release/v$NEW_VERSION"
158172
159- WARNING_TEXT=""
160- if [ "$GITHUB_REF" != "refs/heads/main" ]; then
161- WARNING_TEXT="**WARNING**: Not running from main branch!"
162- else
163- WARNING_TEXT="✅ Running from main branch"
173+ RELEASE_TYPE="Production"
174+ if [ "$DIST_TAG" != "latest" ]; then
175+ RELEASE_TYPE="Preview (npm tag: $DIST_TAG)"
164176 fi
165177
166178 gh pr create \
167- --base main \
179+ --base "$BASE_BRANCH" \
168180 --head "$BRANCH_NAME" \
169181 --title "Release v$NEW_VERSION" \
170- --body "## 🚀 Release v$NEW_VERSION
182+ --body "## Release v$NEW_VERSION
171183
172184 This PR was automatically created by the release workflow.
173185
174- ### ⚠️ Pre-merge Checklist
186+ **Release type:** $RELEASE_TYPE
187+ **Base branch:** $BASE_BRANCH
188+
189+ ### Pre-merge Checklist
175190 - [ ] Review CHANGELOG.md - ensure it has meaningful release notes
176191 - [ ] Verify version numbers are correct in all files
177192 - [ ] All CI checks are passing
178193
179- ### 📝 How to improve changelog
180- If the auto-generated changelog isn't good enough:
181- 1. Edit CHANGELOG.md in this PR
182- 2. Commit the changes
183- 3. Then approve and merge
184-
185- ### 🔄 Release Process
194+ ### Release Process
186195 After merging this PR:
187196 1. Package will be built and tested
188197 2. **Manual approval required** before publishing to npm
189198 3. GitHub release and tag created after publication
190199
191- ### 🚨 Running from: $GITHUB_REF
192- $WARNING_TEXT
193-
194200 ---
195201 *Triggered by @$GITHUB_ACTOR*"
196202
@@ -285,7 +291,6 @@ jobs:
285291 name : Publish to npm
286292 needs : [prepare-release, release-approval]
287293 runs-on : ubuntu-latest
288- if : github.ref == 'refs/heads/main'
289294 environment :
290295 name : npm-publish
291296 url : https://www.npmjs.com/package/@aws/agentcore
@@ -294,14 +299,15 @@ jobs:
294299 contents : write # Required to push git tags
295300
296301 steps :
297- - name : Checkout latest main (AFTER PR merge)
302+ - name : Checkout base branch (AFTER PR merge)
298303 uses : actions/checkout@v6
299304 with :
300- ref : main
305+ ref : ${{ needs.prepare-release.outputs.base_branch }}
301306 fetch-depth : 0
302307
303308 - name : Verify we have the merged code
304309 run : |
310+ echo "Branch: ${{ needs.prepare-release.outputs.base_branch }}"
305311 echo "Current version in package.json:"
306312 cat package.json | grep '"version"'
307313 echo ""
@@ -336,24 +342,25 @@ jobs:
336342 env :
337343 VERSION : ${{ steps.version.outputs.version }}
338344 EXPECTED_VERSION : ${{ needs.prepare-release.outputs.version }}
345+ BASE_BRANCH : ${{ needs.prepare-release.outputs.base_branch }}
339346 run : |
340- echo "Version in main branch : $VERSION"
347+ echo "Version in $BASE_BRANCH : $VERSION"
341348 echo "Expected version from PR: $EXPECTED_VERSION"
342349
343350 if [ "$VERSION" != "$EXPECTED_VERSION" ]; then
344351 echo ""
345352 echo "❌ ERROR: Version mismatch!"
346353 echo ""
347354 echo "The release PR has NOT been merged yet."
348- echo "Main branch has: $VERSION"
355+ echo "$BASE_BRANCH has: $VERSION"
349356 echo "Release PR has: $EXPECTED_VERSION"
350357 echo ""
351- echo "👉 Please MERGE the release PR first, then approve this deployment."
358+ echo "Please MERGE the release PR first, then approve this deployment."
352359 echo ""
353360 exit 1
354361 fi
355362
356- echo "✅ Version matches - PR was merged correctly"
363+ echo "Version matches - PR was merged correctly"
357364
358365 - name : Install dependencies
359366 run : npm ci
@@ -362,10 +369,13 @@ jobs:
362369 run : npm run build
363370
364371 - name : Publish to npm (using OIDC trusted publishing)
372+ env :
373+ DIST_TAG : ${{ needs.prepare-release.outputs.dist_tag }}
365374 run : |
366375 echo "Publishing with OIDC trusted publishing..."
367376 echo "No NPM_TOKEN needed - using GitHub OIDC"
368- npm publish --access public --provenance --tag latest
377+ echo "Dist tag: $DIST_TAG"
378+ npm publish --access public --provenance --tag "$DIST_TAG"
369379
370380 - name : Create and push tag
371381 env :
0 commit comments