diff --git a/.yarn/versions/85173f62.yml b/.yarn/versions/85173f62.yml new file mode 100644 index 000000000000..b8db1c186025 --- /dev/null +++ b/.yarn/versions/85173f62.yml @@ -0,0 +1,28 @@ +releases: + "@yarnpkg/cli": patch + "@yarnpkg/plugin-version": patch + +declined: + - "@yarnpkg/builder" + - "@yarnpkg/core" + - "@yarnpkg/doctor" + - "@yarnpkg/nm" + - "@yarnpkg/pnpify" + - "@yarnpkg/sdks" + - "@yarnpkg/plugin-catalog" + - "@yarnpkg/plugin-compat" + - "@yarnpkg/plugin-constraints" + - "@yarnpkg/plugin-dlx" + - "@yarnpkg/plugin-essentials" + - "@yarnpkg/plugin-init" + - "@yarnpkg/plugin-interactive-tools" + - "@yarnpkg/plugin-jsr" + - "@yarnpkg/plugin-nm" + - "@yarnpkg/plugin-npm-cli" + - "@yarnpkg/plugin-pack" + - "@yarnpkg/plugin-patch" + - "@yarnpkg/plugin-pnp" + - "@yarnpkg/plugin-pnpm" + - "@yarnpkg/plugin-stage" + - "@yarnpkg/plugin-typescript" + - "@yarnpkg/plugin-workspace-tools" diff --git a/packages/acceptance-tests/pkg-tests-specs/sources/commands/version.test.ts b/packages/acceptance-tests/pkg-tests-specs/sources/commands/version.test.ts index 004c50a6524e..1b9f7b6dd552 100644 --- a/packages/acceptance-tests/pkg-tests-specs/sources/commands/version.test.ts +++ b/packages/acceptance-tests/pkg-tests-specs/sources/commands/version.test.ts @@ -294,5 +294,21 @@ describe(`Commands`, () => { }); }), ); + + test( + `it should apply a literal semver bump against the stableVersion base when version is a prerelease (#7025)`, + makeTemporaryEnv({ + version: `1.3.1-alpha`, + stableVersion: `1.2.1`, + }, async ({path, run, source}) => { + await expect(run(`version`, `1.3.1`)).resolves.toMatchObject({ + code: 0, + }); + + await expect(xfs.readJsonPromise(`${path}/package.json` as PortablePath)).resolves.toMatchObject({ + version: `1.3.1`, + }); + }), + ); }); }); diff --git a/packages/plugin-version/sources/commands/version.ts b/packages/plugin-version/sources/commands/version.ts index db8e138af0eb..f52ace77c285 100644 --- a/packages/plugin-version/sources/commands/version.ts +++ b/packages/plugin-version/sources/commands/version.ts @@ -66,7 +66,13 @@ export default class VersionCommand extends BaseCommand { let releaseStrategy: string | null; if (isSemver) { if (workspace.manifest.version !== null) { - const suggestedStrategy = versionUtils.suggestStrategy(workspace.manifest.version, this.strategy); + // `resolveVersionFiles` (used during `version apply`) bases the bump on + // `stableVersion ?? version` when `stableVersion` is set. The strategy + // suggested here must be expressed against the same base, otherwise a + // strategy like `patch` that fits `version` (`1.3.1-alpha` → `1.3.1`) + // would later be applied to `stableVersion` (`1.2.1` → `1.2.2`). + const baseVersion = workspace.manifest.raw.stableVersion ?? workspace.manifest.version; + const suggestedStrategy = versionUtils.suggestStrategy(baseVersion, this.strategy); if (suggestedStrategy !== null) { releaseStrategy = suggestedStrategy;