Skip to content

Commit 8991099

Browse files
jdaltonclaude
andcommitted
chore(workflows): remove token-based npm publishing
Standardize on npm trusted publishing with OIDC tokens by removing all legacy token-based authentication steps and secrets. Simplifies workflow by eliminating conditional branches between publishing methods. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5bf88a0 commit 8991099

File tree

1 file changed

+12
-69
lines changed

1 file changed

+12
-69
lines changed

.github/workflows/provenance.yml

Lines changed: 12 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ on:
7070
description: 'Use npm trusted publishing with OIDC instead of npm token'
7171
required: false
7272
type: boolean
73-
default: false
74-
secrets:
75-
npm_token:
76-
required: false
73+
default: true
7774

7875
permissions:
7976
contents: write
@@ -91,20 +88,9 @@ jobs:
9188
steps:
9289
- name: Validate inputs
9390
run: |
94-
if [ "${{ inputs.use-trusted-publishing }}" = "false" ]; then
95-
if [ -z "${{ inputs.publish-script }}" ] && [ -z "${{ inputs.access-script }}" ] && [ -z "${{ inputs.package-name }}" ]; then
96-
echo "Error: package-name is required when publish-script and access-script are not provided"
97-
exit 1
98-
fi
99-
if [ -z "${{ secrets.npm_token }}" ]; then
100-
echo "Error: npm_token secret is required when use-trusted-publishing is false"
101-
exit 1
102-
fi
103-
else
104-
if [ -z "${{ inputs.publish-script }}" ] && [ -z "${{ inputs.package-name }}" ]; then
105-
echo "Error: package-name is required when publish-script is not provided"
106-
exit 1
107-
fi
91+
if [ -z "${{ inputs.publish-script }}" ] && [ -z "${{ inputs.package-name }}" ]; then
92+
echo "Error: package-name is required when publish-script is not provided"
93+
exit 1
10894
fi
10995
11096
- uses: SocketDev/socket-registry/.github/actions/setup-and-install@42af85173896eefdd299364a2200d308b1c63caa # main
@@ -131,12 +117,8 @@ jobs:
131117
- run: ${{ inputs.setup-script }}
132118
if: inputs.setup-script != ''
133119

134-
- name: Setup npm authentication (token-based)
135-
if: inputs.use-trusted-publishing == false
136-
run: pnpm config set //registry.npmjs.org/:_authToken ${{ secrets.npm_token }}
137-
138-
- name: Publish with custom script (token-based)
139-
if: inputs.publish-script != '' && inputs.use-trusted-publishing == false
120+
- name: Publish with custom script
121+
if: inputs.publish-script != ''
140122
run: |
141123
FLAGS=""
142124
if [ "${{ inputs.force-publish }}" = "true" ]; then
@@ -153,58 +135,19 @@ jobs:
153135
else
154136
pnpm run ${{ inputs.publish-script }}
155137
fi
156-
env:
157-
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
158138
159-
- name: Publish with custom script (trusted publishing)
160-
if: inputs.publish-script != '' && inputs.use-trusted-publishing == true
161-
run: |
162-
FLAGS=""
163-
if [ "${{ inputs.force-publish }}" = "true" ]; then
164-
FLAGS="$FLAGS --force-publish"
165-
fi
166-
if [ "${{ inputs.force-registry }}" = "true" ]; then
167-
FLAGS="$FLAGS --force-registry"
168-
fi
169-
if [ "${{ inputs.skip-npm-packages }}" = "true" ]; then
170-
FLAGS="$FLAGS --skip-npm-packages"
171-
fi
172-
if [ -n "$FLAGS" ]; then
173-
pnpm run ${{ inputs.publish-script }} -- $FLAGS
174-
else
175-
pnpm run ${{ inputs.publish-script }}
176-
fi
177-
178-
- name: Publish package (token-based)
179-
if: inputs.publish-script == '' && inputs.package-name != '' && inputs.use-trusted-publishing == false
180-
run: pnpm publish --provenance --access public --no-git-checks --ignore-scripts
181-
env:
182-
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
183-
184-
- name: Publish package (trusted publishing)
185-
if: inputs.publish-script == '' && inputs.package-name != '' && inputs.use-trusted-publishing == true
139+
- name: Publish package
140+
if: inputs.publish-script == '' && inputs.package-name != ''
186141
run: npm publish --access public
187142
env:
188143
NPM_CONFIG_IGNORE_SCRIPTS: true
189144

190-
- name: Set package access (token-based)
191-
if: inputs.access-script != '' && inputs.use-trusted-publishing == false
145+
- name: Set package access
146+
if: inputs.access-script != ''
192147
run: pnpm run ${{ inputs.access-script }}
193-
env:
194-
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
195-
196-
- name: Set package access (trusted publishing)
197-
if: inputs.access-script != '' && inputs.use-trusted-publishing == true
198-
run: pnpm run ${{ inputs.access-script }}
199-
200-
- name: Set MFA automation (token-based)
201-
if: inputs.access-script == '' && inputs.package-name != '' && inputs.use-trusted-publishing == false
202-
run: pnpm access set mfa=automation ${{ inputs.package-name }}
203-
env:
204-
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
205148

206-
- name: Set MFA automation (trusted publishing)
207-
if: inputs.access-script == '' && inputs.package-name != '' && inputs.use-trusted-publishing == true
149+
- name: Set MFA automation
150+
if: inputs.access-script == '' && inputs.package-name != ''
208151
run: |
209152
echo "Skipping MFA automation - npm access commands require npm_token authentication"
210153
echo "Trusted publishing uses OIDC tokens which don't support npm access commands"

0 commit comments

Comments
 (0)