|
30 | 30 | id: publish |
31 | 31 | run: npx . publish "./test" --webhook "${{ secrets.DISCORD_WEBHOOK_TEST_RELEASE }}" --access-token "${{ secrets.NPM_TOKEN }}" --version+hash --tag github --version+tag --create-tag "test/" --llm-api-key "${{ secrets.LLM_API_KEY }}" |
32 | 32 |
|
33 | | - - name: Print output |
| 33 | + - name: Print output |
34 | 34 | run: | |
35 | 35 | echo "Package version: ${{ steps.publish.outputs.package-version }}" |
36 | 36 |
|
|
42 | 42 |
|
43 | 43 | - name: Just add a tag |
44 | 44 | run: npx . publish "./test" --webhook "${{ secrets.DISCORD_WEBHOOK_TEST_RELEASE }}" --access-token "${{ secrets.NPM_TOKEN }}" --tag github-2 |
| 45 | + |
| 46 | + # OIDC-based publishing (Trusted Publishing) |
| 47 | + # NOTE: First publish of a package MUST use --access-token. OIDC only works for existing packages. |
| 48 | + # |
| 49 | + # To enable OIDC for this package: |
| 50 | + # 1. Ensure the package exists on npmjs.com (publish once with --access-token) |
| 51 | + # 2. Go to https://www.npmjs.com/package/publish-helper-test-package/access |
| 52 | + # 3. Click "Settings" → "Trusted Publisher" → "GitHub Actions" |
| 53 | + # 4. Configure: owner (needle-tools), repository (npm-publish-helper), workflow (test.yml) |
| 54 | + publish-oidc: |
| 55 | + runs-on: ubuntu-latest |
| 56 | + timeout-minutes: 5 |
| 57 | + permissions: |
| 58 | + contents: read |
| 59 | + id-token: write # Required for OIDC authentication |
| 60 | + defaults: |
| 61 | + run: |
| 62 | + working-directory: ./ |
| 63 | + |
| 64 | + steps: |
| 65 | + - uses: actions/checkout@v4 |
| 66 | + |
| 67 | + - name: Setup Node.js |
| 68 | + uses: actions/setup-node@v4 |
| 69 | + with: |
| 70 | + node-version: '22' |
| 71 | + # Note: Do NOT set registry-url here for OIDC - it creates .npmrc expecting NODE_AUTH_TOKEN |
| 72 | + # which conflicts with OIDC. Let npm use its default registry. |
| 73 | + |
| 74 | + - name: Update npm to latest (OIDC requires npm >= 11.5) |
| 75 | + run: | |
| 76 | + echo "Current npm version: $(npm --version)" |
| 77 | + npm install -g npm@latest |
| 78 | + echo "Updated npm version: $(npm --version)" |
| 79 | +
|
| 80 | + - name: Check environment for OIDC |
| 81 | + run: | |
| 82 | + echo "=== Node/npm versions ===" |
| 83 | + echo "npm version: $(npm --version)" |
| 84 | + echo "node version: $(node --version)" |
| 85 | + echo "" |
| 86 | + echo "=== OIDC Environment Variables ===" |
| 87 | + echo "GITHUB_ACTIONS: $GITHUB_ACTIONS" |
| 88 | + echo "ACTIONS_ID_TOKEN_REQUEST_URL: ${ACTIONS_ID_TOKEN_REQUEST_URL:-(not set)}" |
| 89 | + echo "ACTIONS_ID_TOKEN_REQUEST_TOKEN: ${ACTIONS_ID_TOKEN_REQUEST_TOKEN:+****(set)}" |
| 90 | + echo "" |
| 91 | + echo "=== Token Environment Variables (should be unset for OIDC) ===" |
| 92 | + echo "NPM_TOKEN: ${NPM_TOKEN:-(not set)}" |
| 93 | + echo "NODE_AUTH_TOKEN: ${NODE_AUTH_TOKEN:-(not set)}" |
| 94 | + echo "" |
| 95 | + echo "=== npmrc contents (if any) ===" |
| 96 | + cat ~/.npmrc 2>/dev/null || echo "(no ~/.npmrc)" |
| 97 | + cat .npmrc 2>/dev/null || echo "(no ./.npmrc)" |
| 98 | + echo "" |
| 99 | + echo "=== npm config list ===" |
| 100 | + npm config list |
| 101 | +
|
| 102 | + - name: Install dependencies |
| 103 | + run: npm install |
| 104 | + |
| 105 | + - name: Test direct npm publish with OIDC (debug) |
| 106 | + working-directory: ./test |
| 107 | + continue-on-error: true |
| 108 | + run: | |
| 109 | + echo "Testing direct npm publish with --provenance..." |
| 110 | + npm version 2.0.0-oidc-direct-test.$(git rev-parse --short HEAD) --no-git-tag-version |
| 111 | + npm publish --access public --provenance --tag oidc-direct --dry-run || echo "Direct test failed" |
| 112 | +
|
| 113 | + - name: Run publish with OIDC |
| 114 | + id: publish-oidc |
| 115 | + run: npx . publish "./test" --webhook "${{ secrets.DISCORD_WEBHOOK_TEST_RELEASE }}" --oidc --version+hash --tag oidc --version+tag |
| 116 | + |
| 117 | + - name: Print output |
| 118 | + run: | |
| 119 | + echo "Package version: ${{ steps.publish-oidc.outputs.package-version }}" |
0 commit comments