Skip to content

Commit 7469b9c

Browse files
blimmerarcanis
andauthored
feat(plugin-npm): support OIDC auth for CircleCI (#7075)
## What's the problem this PR addresses? CircleCI was recently added as a supported [npm trusted publisher](https://docs.npmjs.com/trusted-publishers) provider, but Yarn's OIDC implementation only supports GitHub Actions and GitLab CI. The upstream npm CLI already supports CircleCI in [`lib/utils/oidc.js`](https://github.com/npm/cli/blob/latest/lib/utils/oidc.js) (checking `ciInfo.CIRCLE`). Since Yarn's implementation was [adapted from the npm CLI](https://github.com/yarnpkg/berry/blob/7ccf6e3da18d77d36a426d004babf8553639defa/packages/plugin-npm/sources/npmHttpUtils.ts#L587-L591), it should be updated to match. Closes #7074. ## How did you fix it? Added detection of the `CIRCLECI` environment variable in `getOidcToken()`. Like GitLab CI, CircleCI sets the `NPM_ID_TOKEN` environment variable, so the implementation follows the same pattern. Note: The upstream npm CLI notes that CircleCI doesn't support provenance yet, so the auto-provenance logic in #7017 / #7018 naturally skips CircleCI (no visibility env var to check). ## 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. Co-authored-by: Maël Nison <nison.mael@gmail.com>
1 parent 1ad7f4a commit 7469b9c

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

.yarn/versions/3f01b356.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
releases:
2+
"@yarnpkg/cli": minor
3+
"@yarnpkg/plugin-npm": minor
4+
5+
declined:
6+
- "@yarnpkg/plugin-compat"
7+
- "@yarnpkg/plugin-constraints"
8+
- "@yarnpkg/plugin-dlx"
9+
- "@yarnpkg/plugin-essentials"
10+
- "@yarnpkg/plugin-init"
11+
- "@yarnpkg/plugin-interactive-tools"
12+
- "@yarnpkg/plugin-nm"
13+
- "@yarnpkg/plugin-npm-cli"
14+
- "@yarnpkg/plugin-pack"
15+
- "@yarnpkg/plugin-patch"
16+
- "@yarnpkg/plugin-pnp"
17+
- "@yarnpkg/plugin-pnpm"
18+
- "@yarnpkg/plugin-stage"
19+
- "@yarnpkg/plugin-typescript"
20+
- "@yarnpkg/plugin-version"
21+
- "@yarnpkg/plugin-workspace-tools"
22+
- "@yarnpkg/builder"
23+
- "@yarnpkg/core"
24+
- "@yarnpkg/doctor"

packages/plugin-npm/sources/npmHttpUtils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,8 @@ async function getOidcToken(registry: string, {configuration, ident}: {configura
595595

596596
if (process.env.GITLAB_CI) {
597597
idToken = process.env.NPM_ID_TOKEN || null;
598+
} else if (process.env.CIRCLECI) {
599+
idToken = process.env.NPM_ID_TOKEN || null;
598600
} else if (process.env.GITHUB_ACTIONS) {
599601
if (!(process.env.ACTIONS_ID_TOKEN_REQUEST_URL && process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN))
600602
return null;

0 commit comments

Comments
 (0)