Commit f6872cf
authored
fix(plugin-npm-cli): enable OIDC publish on CircleCI (#7122)
## What's the problem this PR addresses?
`yarn npm publish` skips the OIDC code path on CircleCI, even though
[#7075](#7075) was supposed to add
CircleCI support. That PR updated `getOidcToken()` in
`packages/plugin-npm/sources/npmHttpUtils.ts` to read `NPM_ID_TOKEN`
when `process.env.CIRCLECI` is set, but the gating expression in
`packages/plugin-npm-cli/sources/commands/npm/publish.ts` that decides
whether to pass `allowOidc: true` to `npmHttpUtils.put` was not updated:
```ts
allowOidc: Boolean(process.env.CI && (process.env.GITHUB_ACTIONS || process.env.GITLAB_CI)),
```
So on CircleCI, `allowOidc` is always `false`, `getOidcToken()` is never
called, and the publish either fails (no other auth) or falls back to a
long-lived token. This contradicts the stated intent of #7075 ("CircleCI
was recently added as a supported npm trusted publisher provider, but
Yarn's OIDC implementation only supports GitHub Actions and GitLab CI").
Reproduction: a CircleCI release pipeline that mints an OIDC token via
`circleci run oidc get --claims '{"aud":"npm:registry.npmjs.org"}'`,
exports it as `NPM_ID_TOKEN`, then runs `yarn npm publish` against a
package configured for trusted publishing. Expected: yarn exchanges the
id-token for a single-use publish token. Actual: yarn never attempts the
exchange, because the `allowOidc` gate excludes CircleCI.
Refs #7074, #7075.
## How did you fix it?
Added `process.env.CIRCLECI` to the disjunction, mirroring the branch
that #7075 already added in `getOidcToken()`:
```ts
allowOidc: Boolean(process.env.CI && (process.env.GITHUB_ACTIONS || process.env.GITLAB_CI || process.env.CIRCLECI)),
```
This keeps the gate consistent with the providers `getOidcToken()`
actually handles, and matches the same one-line shape as the GitLab fix
in [#6938](#6938).
No new tests: the change is an additional disjunct in a Boolean gate;
there were no tests covering the GitHub Actions or GitLab CI cases of
this expression either, and #7075 / #6938 were merged without tests for
the same reason.
## Checklist
- [x] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).
- [x] I have set the packages that need to be released for my changes to
be effective.
- [x] I will check that all automated PR checks pass before the PR gets
reviewed.1 parent 20dd169 commit f6872cf
2 files changed
Lines changed: 37 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | | - | |
| 171 | + | |
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| |||
0 commit comments