Skip to content

Commit 86088d3

Browse files
committed
fix: remove registry-url to enable npm OIDC auto-detection
- Remove registry-url from setup-node (was injecting NODE_AUTH_TOKEN) - Add npm version check and auto-upgrade for OIDC support (11.5.1+) - Add explicit --registry flag to npm publish - Remove empty NODE_AUTH_TOKEN/NPM_CONFIG_USERCONFIG env vars that were breaking OIDC
1 parent ae8a6c5 commit 86088d3

File tree

1 file changed

+40
-12
lines changed

1 file changed

+40
-12
lines changed

.github/workflows/publish-platform.yml

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,35 +188,63 @@ jobs:
188188
ls -la packages/${PLATFORM}/
189189
ls -la packages/${PLATFORM}/bin/
190190
191+
# Use setup-node WITHOUT registry-url to avoid NODE_AUTH_TOKEN injection
192+
# OIDC requires npm 11.5.1+ and NO token to be set
191193
- uses: actions/setup-node@v4
192194
if: steps.check.outputs.skip != 'true'
193195
with:
194196
node-version: "24"
195-
registry-url: "https://registry.npmjs.org"
197+
# DO NOT set registry-url - it injects NODE_AUTH_TOKEN which breaks OIDC
198+
199+
- name: Check npm version and OIDC environment
200+
if: steps.check.outputs.skip != 'true'
201+
run: |
202+
echo "=== Environment Check ==="
203+
echo "npm version: $(npm --version)"
204+
echo "node version: $(node --version)"
205+
echo ""
206+
echo "=== OIDC Environment Variables ==="
207+
echo "ACTIONS_ID_TOKEN_REQUEST_URL: ${ACTIONS_ID_TOKEN_REQUEST_URL:-(not set)}"
208+
echo "ACTIONS_ID_TOKEN_REQUEST_TOKEN: ${ACTIONS_ID_TOKEN_REQUEST_TOKEN:+[REDACTED]}"
209+
echo ""
210+
echo "=== Auth-related env vars ==="
211+
echo "NODE_AUTH_TOKEN: ${NODE_AUTH_TOKEN:-(not set)}"
212+
echo "NPM_CONFIG_USERCONFIG: ${NPM_CONFIG_USERCONFIG:-(not set)}"
213+
echo ""
214+
# Verify npm version >= 11.5.1 for OIDC support
215+
NPM_VERSION=$(npm --version)
216+
NPM_MAJOR=$(echo $NPM_VERSION | cut -d. -f1)
217+
NPM_MINOR=$(echo $NPM_VERSION | cut -d. -f2)
218+
NPM_PATCH=$(echo $NPM_VERSION | cut -d. -f3)
219+
if [ "$NPM_MAJOR" -lt 11 ] || ([ "$NPM_MAJOR" -eq 11 ] && [ "$NPM_MINOR" -lt 5 ]) || ([ "$NPM_MAJOR" -eq 11 ] && [ "$NPM_MINOR" -eq 5 ] && [ "$NPM_PATCH" -lt 1 ]); then
220+
echo "::warning::npm version $NPM_VERSION may not support OIDC. Upgrading to latest..."
221+
npm install -g npm@latest
222+
echo "Updated npm version: $(npm --version)"
223+
else
224+
echo "✓ npm version $NPM_VERSION supports OIDC"
225+
fi
196226
197227
- name: Publish ${{ matrix.platform }}
198228
if: steps.check.outputs.skip != 'true'
199229
run: |
200230
cd packages/${{ matrix.platform }}
201231
202-
# Remove .npmrc files created by setup-node
203-
rm -f ~/.npmrc
204-
rm -f /home/runner/work/_temp/.npmrc 2>/dev/null || true
232+
# Ensure no .npmrc files interfere
233+
rm -f ~/.npmrc 2>/dev/null || true
234+
rm -f .npmrc 2>/dev/null || true
205235
206236
TAG_ARG=""
207237
if [ -n "${{ inputs.dist_tag }}" ]; then
208238
TAG_ARG="--tag ${{ inputs.dist_tag }}"
209239
fi
210240
211-
# Publish with provenance (OIDC authentication)
212-
# npm 11.5.1+ auto-detects OIDC environment when no token is present
213-
npm publish --access public --provenance $TAG_ARG
241+
echo "Publishing oh-my-opencode-${{ matrix.platform }}..."
242+
echo "Registry: https://registry.npmjs.org"
243+
244+
# Publish with provenance - npm will use OIDC automatically
245+
# when ACTIONS_ID_TOKEN_REQUEST_URL is set and no token is present
246+
npm publish --access public --provenance --registry https://registry.npmjs.org $TAG_ARG
214247
env:
215-
# Override setup-node env vars to disable token-based auth
216-
# This forces npm to use OIDC instead
217-
NPM_CONFIG_USERCONFIG: ""
218-
NODE_AUTH_TOKEN: ""
219-
NPM_CONFIG_PROVENANCE: "true"
220248
npm_config_fetch_timeout: "600000"
221249
npm_config_fetch_retry_maxtimeout: "120000"
222250
timeout-minutes: 15

0 commit comments

Comments
 (0)