Skip to content

Commit 625dcac

Browse files
iliapologithub-actionsrix0rrr
authored
chore: force minor version bumps for aws-cdk package (#353)
Temporary until we refactor the release process. Tested locally. When executing `yarn workspaces run bump` on `main`: ```console 👾 Number of commits since [email protected]: 5 ✔ bumping version in /Users/epolon/dev/src/github.com/aws/aws-cdk-cli/packages/aws-cdk/package.json from 2.1007.0 to 3.0.0 ✔ created /Users/epolon/dev/src/github.com/aws/aws-cdk-cli/packages/aws-cdk/dist/changelog.md ✔ outputting changes to /Users/epolon/dev/src/github.com/aws/aws-cdk-cli/packages/aws-cdk/dist/changelog.md Error: bump failed: this branch is configured to only publish v2 releases - bump resulted in 3.0.0 at bump (/Users/epolon/dev/src/github.com/aws/aws-cdk-cli/packages/aws-cdk/node_modules/projen/lib/release/bump-version.js:139:19) 👾 Task "bump" failed when executing ""/opt/homebrew/Cellar/node@20/20.18.0_2/bin/node" "/Users/epolon/dev/src/github.com/aws/aws-cdk-cli/packages/aws-cdk/node_modules/projen/lib/release/bump-version.task.js"" (cwd: /Users/epolon/dev/src/github.com/aws/aws-cdk-cli/packages/aws-cdk) ``` Which fails as expected on the major version protection. When executing on this branch: ```console 👾 Number of commits since [email protected]: 5 ✔ bumping version in /Users/epolon/dev/src/github.com/aws/aws-cdk-cli/packages/aws-cdk/package.json from 2.1007.0 to 2.1008.0 ✔ created /Users/epolon/dev/src/github.com/aws/aws-cdk-cli/packages/aws-cdk/dist/changelog.md ✔ outputting changes to /Users/epolon/dev/src/github.com/aws/aws-cdk-cli/packages/aws-cdk/dist/changelog.md ✨ Done in 6.54s. ``` Which correctly bumps from from 2.1007.0 to 2.1008.0. --- By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license --------- Signed-off-by: github-actions <[email protected]> Co-authored-by: github-actions <[email protected]> Co-authored-by: Rico Hermans <[email protected]>
1 parent 8d9eda5 commit 625dcac

File tree

3 files changed

+35
-18
lines changed

3 files changed

+35
-18
lines changed

.projenrc.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,12 @@ const cli = configureProject(
12391239
}),
12401240

12411241
// Append a specific version string for testing
1242-
nextVersionCommand: 'tsx ../../projenrc/next-version.ts maybeRc',
1242+
// force a minor for the time being. This will never release a patch but that's fine for a while.
1243+
nextVersionCommand: 'tsx ../../projenrc/next-version.ts maybeRcOrMinor',
1244+
1245+
// re-enable this once we refactor the release tasks to prevent
1246+
// major version bumps caused by breaking commits in dependencies.
1247+
// nextVersionCommand: 'tsx ../../projenrc/next-version.ts maybeRc',
12431248

12441249
releasableCommits: transitiveToolkitPackages('aws-cdk'),
12451250
majorVersion: 2,

packages/aws-cdk/.projen/tasks.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projenrc/next-version.ts

+27-15
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,17 @@ async function main() {
3737
break;
3838

3939
case 'maybeRc': {
40-
if (process.env.TESTING_CANDIDATE === 'true') {
41-
// To make an rc version for testing, we set the last component (either
42-
// patch or prerelease version) to 999.
43-
//
44-
// Adding `rc.0` causes problems for Amplify tests, which install
45-
// `aws-cdk@^2` which won't match the prerelease version.
46-
const originalPre = semver.prerelease(version);
47-
48-
if (originalPre) {
49-
version = version.replace(new RegExp('\\.' + originalPre[1] + '$'), '.999');
50-
} else {
51-
const patch = semver.patch(version);
52-
version = version.replace(new RegExp('\\.' + patch + '$'), '.999');
53-
}
54-
}
40+
version = maybeRc(version) ?? version;
5541
break;
5642
}
43+
// this is a temporary case in order to support forcing a minor
44+
// version while still preserving rc capabilities for integ testing purposes.
45+
// once we refactor the release process to prevent incorporating breaking
46+
// changes from dependencies, this can (and should) be removed.
47+
// see https://github.com/projen/projen/pull/4156
48+
case 'maybeRcOrMinor':
49+
version = maybeRc(version) ?? 'minor';
50+
break;
5751

5852
default:
5953
throw new Error(`Unknown command: ${cmd}`);
@@ -67,6 +61,24 @@ async function main() {
6761
}
6862
}
6963

64+
function maybeRc(version: string) {
65+
if (process.env.TESTING_CANDIDATE === 'true') {
66+
// To make an rc version for testing, we set the last component (either
67+
// patch or prerelease version) to 999.
68+
//
69+
// Adding `rc.0` causes problems for Amplify tests, which install
70+
// `aws-cdk@^2` which won't match the prerelease version.
71+
const originalPre = semver.prerelease(version);
72+
73+
if (originalPre) {
74+
return version.replace(new RegExp('\\.' + originalPre[1] + '$'), '.999');
75+
} else {
76+
const patch = semver.patch(version);
77+
return version.replace(new RegExp('\\.' + patch + '$'), '.999');
78+
}
79+
}
80+
}
81+
7082
main().catch((error) => {
7183
// this is a cli
7284
// eslint-disable-next-line no-console

0 commit comments

Comments
 (0)