Skip to content

Commit 158965f

Browse files
authored
chore(workflow): switch npm release to OIDC (#146)
## Summary This PR migrates the npm release authentication from a static `NPM_TOKEN` (secret) to OpenID Connect (OIDC) via GitHub's Trusted Publishers. ## Changes - Added `id-token: write` and `contents: read` permissions to the `release-npm-registry` job. - Removed the dependency on `secrets.NPM_TOKEN`. - Maintained `NPM_CONFIG_PROVENANCE=true` for secure package publishing. ## Impact - **Security**: No longer requires managing long-lived npm tokens in GitHub Secrets. - **Workflow**: Authentication is now handled automatically by GitHub's OIDC provider.
1 parent 637ab91 commit 158965f

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
runs-on: ubuntu-latest
4949
permissions:
5050
id-token: write
51+
contents: read
5152
steps:
5253
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0
5354
with:
@@ -61,5 +62,3 @@ jobs:
6162
- run: pnpm install
6263
- run: pnpm build
6364
- run: NPM_CONFIG_PROVENANCE=true pnpm run release:npm:registry
64-
env:
65-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"openapi-generator",
1010
"typescript"
1111
],
12-
"homepage": "https://github.com/Himenon/openapi-typescript-code-generator#readme",
12+
"homepage": "https://github.com/Himenon/openapi-typescript-code-generator",
1313
"bugs": {
1414
"url": "https://github.com/Himenon/openapi-typescript-code-generator/issues"
1515
},
@@ -66,8 +66,8 @@
6666
"format": "biome check --write --unsafe .",
6767
"lerna:version:up": "lerna version --yes",
6868
"lint": "biome check .",
69-
"release:github:registry": "pnpm publish --no-git-checks --registry https://npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}",
70-
"release:npm:registry": "pnpm publish --no-git-checks",
69+
"release:npm:registry": "pnpm publish --access public --no-git-checks",
70+
"release:github:registry": "pnpm publish --access public --no-git-checks",
7171
"test": "run-p test:depcruise test:vitest test:code:gen:* test:snapshot",
7272
"test:code:gen": "run-p test:code:gen:*",
7373
"test:code:gen:class": "pnpm ts ./scripts/testCodeGenWithClass.ts",

0 commit comments

Comments
 (0)