Skip to content

Failure to publish via OIDC when using readonly token for private package install #1054

@pyoor

Description

@pyoor

I have a private package which depends on other private packages. I'm attempting to use semantic-release to publish that package but it appears that the read only token that I provide in order to install other private dependencies is conflicting with the OIDC token. What's the correct way to proceed here?

  # ci.yaml
  release:
    # Only run on push to main, not on PRs
    if: github.event_name == 'push' && github.ref == 'refs/heads/main'
    needs: [ lint, test ]
    runs-on: ubuntu-latest
    
    permissions:
      contents: write # to be able to publish a GitHub release
      issues: write # to be able to comment on released issues
      pull-requests: write # to be able to comment on released pull requests
      id-token: write # to enable use of OIDC for trusted publishing and npm provenance
    
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '22'
          cache: 'npm'
          registry-url: 'https://registry.npmjs.org'
      - run: npm ci
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_READ_TOKEN }}
      - name: Release
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: npx semantic-release

Output from gh-actions:

npx semantic-release
...
[11:48:46 PM] [semantic-release] › ✔  Allowed to push to the Git repository
[11:48:46 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/npm"
[11:48:46 PM] [semantic-release] [@semantic-release/npm] › ℹ  Verifying OIDC context for publishing from GitHub Actions
[11:48:47 PM] [semantic-release] [@semantic-release/npm] › ℹ  OIDC token exchange with the npm registry succeeded
...
[11:48:48 PM] [semantic-release] › ✔  Completed step "prepare" of plugin "@semantic-release/npm"
[11:48:49 PM] [semantic-release] › ✔  Created tag v9.0.1
[11:48:49 PM] [semantic-release] › ℹ  Start step "publish" of plugin "@semantic-release/npm"
[11:48:49 PM] [semantic-release] [@semantic-release/npm] › ℹ  Publishing version 9.0.1 to npm registry on dist-tag latest
...
npm notice total files: 25
npm notice
npm error code ENEEDAUTH

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions