Skip to content

Commit 093dae4

Browse files
authored
ci: switch npm publish to trusted publishing (OIDC) (#695)
The @launchdarkly/ldcli npm package now has trusted publishing configured on the npm side, which rejects legacy NODE_AUTH_TOKEN publishes (npm returns 404 to obscure auth failures). Align the release-please and manual-publish workflows with the OIDC pattern already used by js-client-sdk, observability-sdk, and launchdarkly- toolbar: * bump actions/setup-node v3 -> v4 * install npm 11.6.2 (trusted publishing requires >= 11.5.1) * drop the SSM-sourced NODE_AUTH_TOKEN; npm CLI picks up the OIDC token automatically via the existing id-token: write permission No changes to scripts/publish-npm.sh (already uses --provenance --access public, same as the sibling repos). Made-with: Cursor
1 parent 129c870 commit 093dae4

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

.github/workflows/manual-publish.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ jobs:
8383
runs-on: ubuntu-latest
8484
if: ${{ inputs.dry-run-npm == false }}
8585
needs: [release-ldcli]
86+
# id-token: write lets npm CLI exchange the GITHUB_TOKEN for an OIDC token
87+
# that the npm registry trusts via the trusted publisher config. The npm
88+
# trusted publisher must be configured with this workflow filename
89+
# (manual-publish.yml) for publishes from this path to succeed.
8690
permissions:
8791
actions: read
8892
id-token: write
@@ -92,15 +96,14 @@ jobs:
9296
name: Checkout
9397
with:
9498
fetch-depth: 0
95-
- uses: actions/setup-node@v3
99+
- uses: actions/setup-node@v4
96100
with:
97101
node-version: 20.x
98102
registry-url: 'https://registry.npmjs.org'
99-
- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.0.1
100-
name: 'Get NPM token'
101-
with:
102-
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
103-
ssm_parameter_pairs: '/production/common/releasing/npm/token = NODE_AUTH_TOKEN'
103+
- name: Update npm
104+
shell: bash
105+
# npm CLI requires >= 11.5.1 for trusted publishing (OIDC) support.
106+
run: npm install -g npm@11.6.2
104107
- id: publish-npm
105108
name: Publish NPM Package
106109
uses: ./.github/actions/publish-npm

.github/workflows/release-please.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,24 @@ jobs:
107107
release-ldcli-npm:
108108
runs-on: ubuntu-latest
109109
needs: [release-please, release-ldcli]
110+
# id-token: write lets npm CLI exchange the GITHUB_TOKEN for an OIDC token
111+
# that the npm registry trusts via the trusted publisher config for this
112+
# workflow. No static NPM token is needed (or wanted: if NODE_AUTH_TOKEN is
113+
# set, npm prefers the token path and skips OIDC).
110114
permissions:
111115
id-token: write
112116
contents: write
113117
if: needs.release-please.outputs.release_created == 'true'
114118
steps:
115119
- uses: actions/checkout@v4
116-
- uses: actions/setup-node@v3
120+
- uses: actions/setup-node@v4
117121
with:
118122
node-version: 20.x
119123
registry-url: 'https://registry.npmjs.org'
120-
- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.0.1
121-
name: 'Get NPM token'
122-
with:
123-
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
124-
ssm_parameter_pairs: '/production/common/releasing/npm/token = NODE_AUTH_TOKEN'
124+
- name: Update npm
125+
shell: bash
126+
# npm CLI requires >= 11.5.1 for trusted publishing (OIDC) support.
127+
run: npm install -g npm@11.6.2
125128
- id: publish-npm
126129
name: Publish NPM Package
127130
uses: ./.github/actions/publish-npm

0 commit comments

Comments
 (0)