Skip to content

feat(plugin-npm): support OIDC auth for CircleCI#7075

Merged
arcanis merged 3 commits intoyarnpkg:masterfrom
blimmer:circleci-oidc-support
Mar 30, 2026
Merged

feat(plugin-npm): support OIDC auth for CircleCI#7075
arcanis merged 3 commits intoyarnpkg:masterfrom
blimmer:circleci-oidc-support

Conversation

@blimmer
Copy link
Copy Markdown
Contributor

@blimmer blimmer commented Mar 15, 2026

What's the problem this PR addresses?

CircleCI was recently added as a supported npm trusted publisher 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 (checking ciInfo.CIRCLE). Since Yarn's implementation was adapted from the npm CLI, 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

  • I have read the Contributing Guide.
  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@blimmer blimmer force-pushed the circleci-oidc-support branch 2 times, most recently from 670a26b to 37a015d Compare March 15, 2026 22:28
@@ -0,0 +1,3 @@
releases:
"@yarnpkg/cli": minor
"@yarnpkg/plugin-npm": minor
Copy link
Copy Markdown
Contributor Author

@blimmer blimmer Mar 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my first time contributing, so please let me know if I'm missing anything here. I believe we only need to update the plugin and the CLI.


if (process.env.GITLAB_CI) {
idToken = process.env.NPM_ID_TOKEN || null;
} else if (process.env.CIRCLECI) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are the docs that this is set in all CircleCI jobs: https://circleci.com/docs/reference/variables/#built-in-environment-variables

@blimmer blimmer marked this pull request as ready for review March 15, 2026 22:29
CircleCI was recently added as a supported npm trusted publisher
provider. Like GitLab CI, it sets the NPM_ID_TOKEN environment
variable. This adds detection of the CIRCLECI env var to enable
OIDC token exchange during `yarn npm publish`.

Closes yarnpkg#7074
@blimmer blimmer force-pushed the circleci-oidc-support branch from 37a015d to 55f5ad8 Compare March 15, 2026 22:35
@blimmer
Copy link
Copy Markdown
Contributor Author

blimmer commented Mar 28, 2026

Hey @arcanis - we'd love to be able to switch from using static tokens to OIDC publishing. This is a pretty small change following the existing patterns. Any chance I could request a review on it? TYIA!

@arcanis arcanis merged commit 7469b9c into yarnpkg:master Mar 30, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Support OIDC auth for CircleCI in yarn npm publish

2 participants