Skip to content

Commit f6872cf

Browse files
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

File tree

.yarn/versions/59c10b8d.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
releases:
2+
"@yarnpkg/cli": patch
3+
"@yarnpkg/plugin-npm-cli": patch
4+
5+
declined:
6+
- "@yarnpkg/core"
7+
- "@yarnpkg/plugin-catalog"
8+
- "@yarnpkg/plugin-compat"
9+
- "@yarnpkg/plugin-constraints"
10+
- "@yarnpkg/plugin-dlx"
11+
- "@yarnpkg/plugin-essentials"
12+
- "@yarnpkg/plugin-exec"
13+
- "@yarnpkg/plugin-file"
14+
- "@yarnpkg/plugin-git"
15+
- "@yarnpkg/plugin-github"
16+
- "@yarnpkg/plugin-http"
17+
- "@yarnpkg/plugin-init"
18+
- "@yarnpkg/plugin-interactive-tools"
19+
- "@yarnpkg/plugin-jsr"
20+
- "@yarnpkg/plugin-link"
21+
- "@yarnpkg/plugin-nm"
22+
- "@yarnpkg/plugin-npm"
23+
- "@yarnpkg/plugin-pack"
24+
- "@yarnpkg/plugin-patch"
25+
- "@yarnpkg/plugin-pnp"
26+
- "@yarnpkg/plugin-pnpm"
27+
- "@yarnpkg/plugin-stage"
28+
- "@yarnpkg/plugin-typescript"
29+
- "@yarnpkg/plugin-version"
30+
- "@yarnpkg/plugin-workspace-tools"
31+
- "@yarnpkg/builder"
32+
- "@yarnpkg/doctor"
33+
- "@yarnpkg/extensions"
34+
- "@yarnpkg/nm"
35+
- "@yarnpkg/pnpify"
36+
- "@yarnpkg/sdks"

packages/plugin-npm-cli/sources/commands/npm/publish.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export default class NpmPublishCommand extends BaseCommand {
168168
ident,
169169
otp: this.otp,
170170
jsonResponse: true,
171-
allowOidc: Boolean(process.env.CI && (process.env.GITHUB_ACTIONS || process.env.GITLAB_CI)),
171+
allowOidc: Boolean(process.env.CI && (process.env.GITHUB_ACTIONS || process.env.GITLAB_CI || process.env.CIRCLECI)),
172172
});
173173
}
174174

0 commit comments

Comments
 (0)