Skip to content

Commit aacf6c7

Browse files
frankieyanclaude
andauthored
fix(ci): restructure publish workflow for OIDC authentication (#25)
* fix(ci): restructure publish workflow for OIDC authentication Adopt the Reactist publishing pattern to fix npm registry authentication failures. The previous approach had GITHUB_TOKEN leaking between publish steps, preventing OIDC from working. Changes: - Add .npmrc with @Doist registry config for OIDC-based npm publishing - Reverse publish order: npm first, GitHub Packages second - Remove setup-node registry-url for initial npm publish (uses .npmrc) - Add config cleanup step between registry publishes Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: update .node-version so that it satisfies the requirement defined in package.json on CI Update .node-version to 22.22.0 to satisfy the engine requirement (^22.22.0 || >=24.13.0) while keeping engine-strict=true in .npmrc. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Remove access and provenance flags from npm publish --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 58257a4 commit aacf6c7

File tree

3 files changed

+34
-13
lines changed

3 files changed

+34
-13
lines changed

.github/workflows/publish.yml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
name: Publish @doist/react-compiler-tracker package
22

33
on:
4+
# triggered by `release-please.yml`
45
workflow_dispatch:
56

67
permissions:
7-
contents: read
8-
packages: write
8+
# Enable the use of OIDC for trusted publishing and npm provenance
99
id-token: write
10+
# Enable the use of GitHub Packages registry
11+
packages: write
12+
# Enable Release Please to publish a GitHub release
13+
contents: read
1014

1115
jobs:
1216
publish:
@@ -17,13 +21,11 @@ jobs:
1721
- name: Checkout repository
1822
uses: actions/checkout@v4
1923

20-
- name: Prepare Node.js environment for GitHub Packages registry
24+
- name: Prepare Node.js environment
2125
uses: actions/setup-node@v6
2226
with:
2327
cache: npm
2428
node-version-file: .node-version
25-
registry-url: https://npm.pkg.github.com/
26-
scope: '@doist'
2729

2830
- name: Ensure npm 11.5.1 or later is installed
2931
run: npm install -g npm@latest
@@ -35,17 +37,27 @@ jobs:
3537
- run: npm run test
3638
- run: npm run build
3739

38-
- name: Publish package to GitHub Packages registry
40+
# The Node.js environment is prepared based on the `.npmrc` file in the repo, which
41+
# configures Doist scoped packages to use the public npm registry with OIDC
42+
# authentication for the initial publish, after which we remove the Doist registry
43+
# configuration, and prepare the Node.js environment for the GitHub Packages registry,
44+
# providing a predictable release workflow for both registries.
45+
46+
- name: Publish package to public npm registry
3947
run: npm publish
40-
env:
41-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4248

43-
- name: Prepare Node.js environment for npm registry
49+
- name: Remove Doist registry configuration from `.npmrc`
50+
run: npm config delete @doist:registry --location=project
51+
52+
- name: Prepare Node.js environment for GitHub Packages registry
4453
uses: actions/setup-node@v6
4554
with:
55+
cache: npm
4656
node-version-file: .node-version
47-
registry-url: https://registry.npmjs.org/
57+
registry-url: https://npm.pkg.github.com/
4858
scope: '@doist'
4959

50-
- name: Publish package to npm registry
51-
run: npm publish --access public --provenance
60+
- name: Publish package to GitHub Packages registry
61+
run: npm publish
62+
env:
63+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.node-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
22
1+
22.22

.npmrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Ensure dependencies are installed from the npm Registry instead of GitHub Packages in case you
2+
# have changed the default registry for the `@doist` scope in a parent `.npmrc` file
3+
@doist:registry=https://registry.npmjs.org/
4+
5+
# Refuse to install any package incompatible with the current Node.js version
6+
engine-strict=true
7+
8+
# Save dependencies with an exact version rather than the semver range
9+
save-exact=true

0 commit comments

Comments
 (0)