Skip to content

Commit e4bafc3

Browse files
committed
chore: oidc npm workflow
1 parent a987ec2 commit e4bafc3

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

.github/workflows/publish_npm.yml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,43 @@ env:
1010
jobs:
1111
release:
1212
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
id-token: write
1316

1417
steps:
15-
- uses: actions/checkout@v2
16-
- uses: actions/setup-node@v3
18+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
19+
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
1720
with:
18-
node-version: '18.x'
21+
node-version: 22
1922
registry-url: 'https://registry.npmjs.org'
23+
- name: Update npm (required for OIDC trusted publishing)
24+
run: |
25+
npm install -g npm@^11.5.1
26+
npm --version
2027
- name: Setup
2128
run: npm install
22-
- name: Publish All Templates
29+
- name: Prepare Templates
30+
run: npm run prepare-templates
31+
32+
- name: Publish All Templates (OIDC trusted publishing)
33+
if: ${{ vars.USE_NPM_TOKEN != 'true' }}
34+
env:
35+
NODE_AUTH_TOKEN: ""
36+
run: |
37+
echo "Publishing templates to npm with tag $NPM_TAG via OIDC trusted publishing..."
38+
unset NODE_AUTH_TOKEN
39+
if [ -n "${NPM_CONFIG_USERCONFIG:-}" ]; then
40+
rm -f "$NPM_CONFIG_USERCONFIG"
41+
fi
42+
# run publish in every package, ignore failures (ie no publish required if the version is already published)
43+
npx lerna exec --no-bail --stream --concurrency 1 -- "npm publish --tag \"$NPM_TAG\" --access public --provenance || true"
44+
45+
- name: Publish All Templates (granular token)
46+
if: ${{ vars.USE_NPM_TOKEN == 'true' }}
2347
env:
2448
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
2549
run: |
50+
echo "Publishing templates to npm with tag $NPM_TAG via granular token..."
2651
# run publish in every package, ignore failures (ie no publish required if the version is already published)
27-
npm run prepare-templates
28-
npx lerna exec --no-bail --stream --concurrency 1 -- "npm publish || true"
52+
npx lerna exec --no-bail --stream --concurrency 1 -- "npm publish --tag \"$NPM_TAG\" --access public --provenance || true"

0 commit comments

Comments
 (0)