Skip to content

Commit 3d9ac30

Browse files
[FSSDK-12891] Switch npm publishing to OIDC trusted publishing
Replace long-lived NPM_PUBLISH_TOKEN with OIDC trusted publishing for more secure, tokenless CI publishing. Changes: - Add id-token: write permission for OIDC token generation - Upgrade setup-node to v4 and Node to 22 (npm 11.5.1+ requirement) - Add npm upgrade step to ensure OIDC support - Remove NPM_PUBLISH_TOKEN references - Add --provenance flag for supply-chain attestations - Add GitHub environment gate (npm) for deployment protection - Separate dry-run and real-publish paths (provenance incompatible with dry-run) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7d8e5ba commit 3d9ac30

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

.github/workflows/release.yml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,28 @@ on:
55
types: [published, edited]
66
workflow_dispatch: {}
77

8+
permissions:
9+
id-token: write
10+
contents: read
11+
812
jobs:
913
publish:
1014
name: Publish to NPM
1115
runs-on: ubuntu-latest
1216
if: ${{ github.event_name == 'workflow_dispatch' || !github.event.release.draft }}
17+
environment: npm
1318
steps:
1419
- name: Checkout branch
1520
uses: actions/checkout@v4
1621

1722
- name: Setup Node
18-
uses: actions/setup-node@v3
23+
uses: actions/setup-node@v4
1924
with:
20-
node-version: 18
25+
node-version: 22
2126
registry-url: "https://registry.npmjs.org/"
22-
always-auth: "true"
23-
env:
24-
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
27+
28+
- name: Upgrade npm for OIDC support
29+
run: npm install -g npm@latest
2530

2631
- name: Install dependencies
2732
run: npm install
@@ -42,7 +47,7 @@ jobs:
4247
run: |
4348
VERSION=$(jq -r '.version' package.json)
4449
LATEST_RELEASE_TAG="${{ steps.latest-release.outputs['latest-release-tag']}}"
45-
50+
4651
if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then
4752
RELEASE_TAG=${GITHUB_REF#refs/tags/}
4853
else
@@ -66,16 +71,9 @@ jobs:
6671
env:
6772
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
6873
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
69-
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
7074
run: |
7175
if [[ ${{ github.event_name }} == "workflow_dispatch" ]]; then
72-
DRY_RUN="--dry-run"
76+
npm publish --tag=${{ steps.npm-tag.outputs['npm-tag'] }} --dry-run
77+
else
78+
npm publish --tag=${{ steps.npm-tag.outputs['npm-tag'] }} --provenance
7379
fi
74-
npm publish --tag=${{ steps.npm-tag.outputs['npm-tag'] }} $DRY_RUN
75-
76-
# - name: Report results to Jellyfish
77-
# uses: optimizely/jellyfish-deployment-reporter-action@main
78-
# if: ${{ always() && github.event_name == 'release' && (steps.release.outcome == 'success' || steps.release.outcome == 'failure') }}
79-
# with:
80-
# jellyfish_api_token: ${{ secrets.JELLYFISH_API_TOKEN }}
81-
# is_successful: ${{ steps.release.outcome == 'success' }}

0 commit comments

Comments
 (0)