Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .yarn/versions/5f0ffe17.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
releases:
"@yarnpkg/cli": patch
"@yarnpkg/core": patch
"@yarnpkg/plugin-npm": minor
"@yarnpkg/plugin-npm-cli": minor

declined:
- "@yarnpkg/plugin-catalog"
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-exec"
- "@yarnpkg/plugin-file"
- "@yarnpkg/plugin-git"
- "@yarnpkg/plugin-github"
- "@yarnpkg/plugin-http"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-jsr"
- "@yarnpkg/plugin-link"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/builder"
- "@yarnpkg/doctor"
- "@yarnpkg/extensions"
- "@yarnpkg/nm"
- "@yarnpkg/pnpify"
- "@yarnpkg/sdks"
24 changes: 22 additions & 2 deletions packages/plugin-npm-cli/sources/commands/npm/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,21 @@ export default class NpmPublishCommand extends BaseCommand {
});

provenance = Option.Boolean(`--provenance`, false, {
description: `Generate provenance for the package. Only available in GitHub Actions and GitLab CI. Can be set globally through the \`npmPublishProvenance\` setting or the \`YARN_NPM_CONFIG_PROVENANCE\` environment variable, or per-package through the \`publishConfig.provenance\` field in package.json.`,
description: `
Generate provenance for the package. Only available in GitHub Actions and GitLab CI.

Can be set globally through the \`npmPublishProvenance\` setting or the \`YARN_NPM_CONFIG_PROVENANCE\` environment variable, or per-package through the \`publishConfig.provenance\` field in package.json.

Defaults to \`true\` in trusted CI environments (GitHub Actions and GitLab CI) with properly setup credentials, unless explicitly disabled with \`--no-provenance\`.
`,
});

noProvenance = Option.Boolean(`--no-provenance`, false, {
description: `
Do not generate provenance for the package. This overrides any other provenance settings.

Set \`--no-provenance\` to enable OIDC without provenance (e.g. for private repositories).
`,
});
Comment on lines +56 to 62
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As far as I understand, you can remove the default value from the --provenance flag. It would allow you to distinguish yarn npm publish, yarn npm publish --provenance, and yarn npm publish --no-provenance by this.provenance being undefined, true, and false respectively.


dryRun = Option.Boolean(`-n,--dry-run`, false, {
Expand Down Expand Up @@ -129,7 +143,10 @@ export default class NpmPublishCommand extends BaseCommand {

let provenance = false;
let provenanceMessage = ``;
if (workspace.manifest.publishConfig && `provenance` in workspace.manifest.publishConfig) {
if (this.noProvenance) {
provenance = false;
provenanceMessage = `Skipping provenance statement because \`--no-provenance\` flag is set.`;
} else if (workspace.manifest.publishConfig && `provenance` in workspace.manifest.publishConfig) {
provenance = Boolean(workspace.manifest.publishConfig.provenance);
provenanceMessage = provenance
? `Generating provenance statement because \`publishConfig.provenance\` field is set.`
Expand All @@ -140,6 +157,9 @@ export default class NpmPublishCommand extends BaseCommand {
} else if (configuration.get(`npmPublishProvenance`)) {
provenance = true;
provenanceMessage = `Generating provenance statement because \`npmPublishProvenance\` setting is set.`;
} else if (process.env.CI && (process.env.GITHUB_ACTIONS && process.env.ACTIONS_ID_TOKEN_REQUEST_URL || process.env.GITLAB_CI && process.env.SIGSTORE_ID_TOKEN)) {
provenance = true;
provenanceMessage = `Generating provenance statement because running in a trusted CI environment. Set \`npmPublishProvenance\` to false to disable provenance.`;
}

if (provenanceMessage) {
Expand Down