@@ -23,51 +23,56 @@ jobs:
2323 # Based on historical data
2424 timeout-minutes : 60
2525 steps :
26- - uses : actions/checkout@v4
26+ - name : Checkout repository
27+ uses : actions/checkout@v5
2728
2829 - name : Prepare Node.js environment
29- uses : actions/setup-node@v3
30+ uses : actions/setup-node@v6
3031 with :
31- node-version-file : ' .nvmrc'
32+ cache : npm
33+ node-version-file : .node-version
3234
33- # Temporarily disabled until we can upgrade to Node.js 20+
34- # ref: https://github.com/Doist/reactist/actions/runs/18786284512/job/53605250671
35- # - name: Ensure npm 11.5.1 or later is installed
36- # run: npm install -g npm@latest
35+ - name : Cache project 'node_modules' directory
36+ id : node-modules-cache
37+ uses : actions/cache@v4
38+ with :
39+ key : node-modules-cache-${{ hashFiles('**/package-lock.json', '**/.node-version') }}
40+ path : node_modules/
41+
42+ - name : Ensure npm 11.5.1 or later is installed
43+ run : npm install -g npm@latest
3744
38- # Remove any registry configurations from .npmrc
39- - run : sed -i "/@doist/d" ./.npmrc
45+ - name : Install project npm dependencies
46+ if : ${{ steps.node-modules-cache.outputs.cache-hit != 'true' }}
47+ run : |
48+ npm ci
4049
41- - run : npm ci
4250 - run : npm run lint
4351 - run : npm run type-check
4452 - run : npm test
45-
46- # Build artifacts for publishing
4753 - run : npm run build
4854
49- # Publish to GitHub package registry
50- - name : Publish to GitHub Package Registry
51- uses : actions/setup-node@v3
52- with :
53- node-version-file : ' .nvmrc'
54- registry-url : https://npm.pkg.github.com/
55- scope : ' @doist'
56- - run : npm publish
57- env :
58- NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
55+ # The Node.js environment is prepared based on the `.npmrc` file in the repo, which
56+ # configures Doist scoped packages to use the public npm registry with OIDC
57+ # authentication for the initial `semantic-release` publish, after which we remove the
58+ # Doist registry configuration, and prepare the Node.js environment for the GitHub
59+ # Packages registry, providing a predictable release workflow for both registries.
60+
61+ - name : Publish package to public npm registry
62+ run : npm publish
5963
60- - name : Clear npm config between GitHub/npm registries
61- run : rm -f $NPM_CONFIG_USERCONFIG
64+ - name : Remove Doist registry configuration from `.npmrc`
65+ run : npm config delete @doist:registry --location=project
6266
63- # Publish to npm registry
64- - name : Publish to npm registry
65- uses : actions/setup-node@v3
67+ - name : Prepare Node.js environment for GitHub Packages registry
68+ uses : actions/setup-node@v6
6669 with :
67- node-version-file : ' .nvmrc'
68- registry-url : https://registry.npmjs.org/
70+ cache : npm
71+ node-version-file : .node-version
72+ registry-url : https://npm.pkg.github.com/
6973 scope : ' @doist'
70- - run : npm publish --provenance --access public
71- # Token-based authentication until we can use OIDC
74+
75+ - name : Publish package to private GitHub Packages registry
76+ run : npm publish
7277 env :
73- NODE_AUTH_TOKEN : ${{secrets.NPM_TOKEN }}
78+ NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments