1- name : Typist Package Release
1+ name : Package Release
22
33on :
44 workflow_run :
99 types :
1010 - completed
1111
12+ env :
13+ GH_PACKAGES_TOKEN : ${{ secrets.GH_PACKAGES_TOKEN }}
14+
1215permissions :
13- # Enable the use of OIDC for npm provenance
16+ # Enable the use of OIDC for trusted publishing and npm provenance
1417 id-token : write
1518 # Enable the use of GitHub Packages registry
1619 packages : write
17- # Enable `semantic-release` to publish a GitHub release and post comments on issues/PRs
20+ # Enable `semantic-release` to publish a GitHub release
1821 contents : write
22+ # Enable `semantic-release` to post comments on issues
1923 issues : write
24+ # Enable `semantic-release` to post comments on pull requests
2025 pull-requests : write
2126
22- # The release workflow involves many crucial steps that once triggered it shouldn't be cancelled
23- # until it's finished, otherwise we might end up in an inconsistent state (e.g., a new release
24- # published to npm but not GitHub Packages). To prevent this, concurrency is disabled with
25- # `cancel-in-progress: false`, and new workflow runs will be queued to be started only when the
26- # previous one has completely finished.
27+ # The release workflow involves many crucial steps that once triggered shouldn't be cancelled until
28+ # finished, otherwise we might end up in an inconsistent state (e.g., published to GitHub Packages
29+ # but not npm), so new workflow runs are queued until the previous one has completely finished.
2730concurrency :
28- group : typist-package-release
31+ group : ${{ github.workflow }}
2932 cancel-in-progress : false
3033
3134jobs :
@@ -38,19 +41,19 @@ jobs:
3841
3942 steps :
4043 - name : Checkout repository
41- uses : actions/checkout@v4
44+ uses : actions/checkout@v5
4245 with :
4346 token : ${{ secrets.GH_REPO_TOKEN }}
4447
4548 - name : Prepare Node.js environment
46- uses : actions/setup-node@v3
49+ uses : actions/setup-node@v6
4750 with :
4851 cache : npm
4952 node-version-file : .node-version
5053
5154 - name : Cache project 'node_modules' directory
52- uses : actions/cache@v4
5355 id : node-modules-cache
56+ uses : actions/cache@v4
5457 with :
5558 key : node-modules-cache-${{ hashFiles('**/package-lock.json', '**/.node-version') }}
5659 path : node_modules/
6467 run : |
6568 npm run build
6669
67- - name : Run automated package publishing
70+ # The Node.js environment is prepared based on the `.npmrc` file in the repo, which
71+ # configures Doist scoped packages to use the GitHub Packages registry for the initial
72+ # `semantic-release` publish, after which we remove the Doist registry configuration,
73+ # prepare the Node.js environment for the public npm registry with OIDC authentication,
74+ # and update npm to the latest version (required for trusted publishing support),
75+ # providing a predictable release workflow for both registries.
76+
77+ - name : Publish package to private GitHub Packages registry
6878 id : semantic-release
6979 run : |
7080 npx semantic-release
@@ -80,23 +90,20 @@ jobs:
8090 run : |
8191 npm config delete @doist:registry --location=project
8292
83- - name : Prepare Node.js environment for GitHub Packages
84- uses : actions/setup-node@v3
93+ - name : Prepare Node.js environment for npm registry
94+ uses : actions/setup-node@v6
8595 if : ${{ steps.semantic-release.outputs.package-published == 'true' }}
8696 with :
8797 cache : npm
8898 node-version-file : .node-version
89- registry-url : https://npm.pkg.github.com /
99+ registry-url : https://registry.npmjs.org /
90100 scope : ' @doist'
91101
92- - name : Disable npm package provenance (unsupported by GitHub Packages )
102+ - name : Update npm for trusted publishing (requires 11.5.1 or later )
93103 if : ${{ steps.semantic-release.outputs.package-published == 'true' }}
94- run : |
95- npm config set provenance false --location=project
104+ run : npm install -g npm@latest
96105
97- - name : Publish package to GitHub Packages
106+ - name : Publish package to public npm registry
98107 if : ${{ steps.semantic-release.outputs.package-published == 'true' }}
99108 run : |
100109 npm publish
101- env :
102- NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments