1111 - main
1212
1313jobs :
14- # Job 1: Run release verification tests when Version Packages PR is merged
14+ # Job 1: Check if there are unconsumed changesets
15+ setup :
16+ runs-on : ubuntu-latest
17+ outputs :
18+ has-changesets : ${{ steps.has-changesets.outputs.has-changesets }}
19+ steps :
20+ - name : Checkout repository
21+ uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
22+ with :
23+ fetch-depth : 0
24+ - name : Check if repo has unconsumed changesets
25+ id : has-changesets
26+ uses : ./.github/actions/has-changesets
27+ # Note: if there are no changesets, that means either
28+ # (1) "Version Packages" PR was just merged, or
29+ # (2) no commits with changesets have been merged after packages were last published.
30+ #
31+ # In either case, we'll attempt to publish the packages. In case of (1), publish will succeed. In
32+ # case of (2), `@changesets/action` will know that packages have already been published and will
33+ # skip publish.
34+
35+ # Job 2: Run release verification tests when Version Packages PR is merged
1536 # This ensures all tests pass before publishing
1637 release-verification :
17- # Only run when a Version Packages PR is merged (detected by commit message)
18- if : github.event_name == 'push' && contains(github.event.head_commit.message, 'Version packages')
38+ needs : setup
39+ if : needs.setup.outputs.has-changesets != 'true'
1940 secrets : inherit
2041 uses : ./.github/workflows/callable-release-verification.yml
2142
22- # Job 2 : Publish packages after all tests pass
43+ # Job 3 : Publish packages after all tests pass
2344 publish :
2445 runs-on : ubuntu-latest
2546 needs : release-verification
47+ outputs :
48+ published : ${{ steps.changesets.outputs.published }}
2649 steps :
2750 - name : Checkout repository
2851 uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
@@ -34,15 +57,19 @@ jobs:
3457 - name : Setup node and build the repository
3558 uses : ./amplify-js/.github/actions/node-and-build
3659
37- - name : Publish to npm
38- working-directory : ./amplify-js
39- run : yarn changeset publish
60+ - name : Publish to @latest
61+ id : changesets
62+ uses : changesets/action@aba318e9165b45b7948c60273e0b72fce0a64eb9 # v1.4.7
63+ with :
64+ cwd : ./amplify-js
65+ publish : yarn publish:latest
4066 env :
4167 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4268 NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
4369
44- # Job 3 : Update local API documentation after successful publish
70+ # Job 4 : Update local API documentation after successful publish
4571 update-local-docs :
72+ if : needs.publish.outputs.published == 'true'
4673 needs : publish
4774 runs-on : ubuntu-latest
4875 steps :
75102 git commit -m "chore(release): Update API docs [skip release]" || echo "No changes to commit"
76103 git push origin main
77104
78- # Job 4 : Update external documentation repository
105+ # Job 5 : Update external documentation repository
79106 update-external-docs :
80107 needs : update-local-docs
81108 secrets : inherit
0 commit comments