Skip to content

Commit 4e5a105

Browse files
authored
fix(ci): enable tokenless npm OIDC publish for v0.1.2
* fix(ci): let npm use OIDC instead of empty setup-node auth token * chore: prepare v0.1.2 for OIDC validation * docs: use v0.1.2 in OIDC release example
1 parent 35e6acf commit 4e5a105

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ jobs:
8484
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
8585
with:
8686
node-version: "24"
87-
registry-url: https://registry.npmjs.org
8887
package-manager-cache: false
8988

9089
- name: Require OIDC-compatible npm
@@ -103,7 +102,21 @@ jobs:
103102
}
104103
'
105104
105+
# OIDC requires no authentication token in npm config. Supplying
106+
# registry-url to setup-node writes a classic _authToken placeholder,
107+
# which can prevent npm from starting its OIDC exchange.
108+
- name: Verify OIDC credentials are available
109+
shell: bash
110+
run: |
111+
set -euo pipefail
112+
test -n "${ACTIONS_ID_TOKEN_REQUEST_URL:-}"
113+
test -n "${ACTIONS_ID_TOKEN_REQUEST_TOKEN:-}"
114+
if [[ -n "${NODE_AUTH_TOKEN:-}" || -n "${NPM_TOKEN:-}" ]]; then
115+
echo "Unexpected npm token environment variable; OIDC must be used" >&2
116+
exit 1
117+
fi
118+
106119
# No npm install or dependency scripts in the OIDC-enabled job.
107120
# npm automatically generates provenance for public packages.
108121
- name: Publish to npm via OIDC
109-
run: npm publish --access public --ignore-scripts
122+
run: npm publish --access public --ignore-scripts --registry=https://registry.npmjs.org/

‎README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ Keep the version in `package.json` synchronized with the first published version
8282

8383
### Publish the next version
8484

85-
Update `package.json` to an unpublished version (for example, `0.1.1`), merge it to `main`, and confirm CI is green. Then push the corresponding tag **from a commit on main**:
85+
Update `package.json` to an unpublished version (for example, `0.1.2`), merge it to `main`, and confirm CI is green. Then push the corresponding tag **from a commit on main**:
8686

8787
```sh
8888
git switch main
8989
git pull --ff-only
90-
git tag v0.1.1
91-
git push origin v0.1.1
90+
git tag v0.1.2
91+
git push origin v0.1.2
9292
```
9393

9494
The [publish workflow](./.github/workflows/publish.yml) verifies the exact version and that the tag commit is on `main`, runs tests without OIDC permissions, and publishes in a separate approval-gated environment. The publisher job disables npm lifecycle scripts and uses npm's short-lived OIDC authentication and automatic provenance. Pinned GitHub Action commit SHAs and disabled release-job caching reduce supply-chain risk.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "prettier-plugin-angular-comment",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "Format Angular templates in JS/TS template literals with /* Angular */",
55
"type": "module",
66
"exports": {

0 commit comments

Comments
 (0)