Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

fix(release): only [major] bumps the major version

Carl-Gerhard Lindesvärdf6ec51dd5a35
diff --git a/tooling/release/src/next-version.test.ts b/tooling/release/src/next-version.test.ts
index 8980b5aad..e5b5e9e52 100644
--- a/tooling/release/src/next-version.test.ts
+++ b/tooling/release/src/next-version.test.ts
@@ -14,13 +14,14 @@ describe('bumpFor', () => {
['feat: funnels by cohort', 'minor'],
['feat(api): export endpoint', 'minor'],
['self-hosting: new doctor check [minor]', 'minor'],
- ['feat!: drop the v1 ingest route', 'major'],
- ['fix(api)!: rename the events field', 'major'],
+ ['merge the rewrite [major]', 'major'],
+ // Breaking markers never bump the major on their own (see bumpFor).
+ ['feat!: drop the v1 ingest route', 'minor'],
+ ['fix(api)!: rename the events field', 'patch'],
[
'refactor: move ingest\n\nBREAKING CHANGE: KAFKA_BROKERS is required',
- 'major',
+ 'patch',
],
- ['merge the rewrite [major]', 'major'],
] as const)('%s -> %s', (message, bump) => {
expect(bumpFor(message)).toBe(bump);
});
@@ -33,7 +34,8 @@ describe('bumpFor', () => {
describe('highestBump', () => {
test('a push takes the largest bump among its commits', () => {
expect(highestBump(['fix: a', 'feat: b', 'ci: c'])).toBe('minor');
- expect(highestBump(['fix: a', 'feat!: b'])).toBe('major');
+ expect(highestBump(['fix: a', 'feat!: b'])).toBe('minor');
+ expect(highestBump(['fix: a', 'chore: b [major]'])).toBe('major');
expect(highestBump([])).toBe('patch');
});
});
diff --git a/tooling/release/src/next-version.ts b/tooling/release/src/next-version.ts
index c57e35a03..91df4817e 100644
--- a/tooling/release/src/next-version.ts
+++ b/tooling/release/src/next-version.ts
@@ -13,21 +13,18 @@ const TAG_PATTERN = 'v[0-9]*';
const BUMP_RANK: Record<Bump, number> = { patch: 0, minor: 1, major: 2 };
const MAJOR_MARKER = '[major]';
const MINOR_MARKER = '[minor]';
-// Conventional commits: `feat!:` / `fix(api)!:` and a BREAKING CHANGE footer are
-// breaking, `feat:` / `feat(scope):` is a feature. Every other subject is a patch.
-const BREAKING_SUBJECT = /^[a-z]+(\([^)]*\))?!:/i;
-const BREAKING_FOOTER = /^BREAKING[ -]CHANGE:/m;
-const FEATURE_SUBJECT = /^feat(\([^)]*\))?:/i;
+// `feat:` / `feat(scope):` / `feat!:` is a feature; every other subject is a patch.
+const FEATURE_SUBJECT = /^feat(\([^)]*\))?!?:/i;
+// A major bump needs `[major]`, typed by the maintainer. Conventional-commit
+// breaking markers (`feat!:`, a BREAKING CHANGE footer) are ignored on
+// purpose: agents write most commits and add them out of habit, and a new
+// major version is a release decision, not a side effect of one commit.
export const bumpFor = (message: string): Bump => {
- const subject = message.split('\n', 1)[0]?.trim() ?? '';
- const isBreaking =
- message.includes(MAJOR_MARKER) ||
- BREAKING_SUBJECT.test(subject) ||
- BREAKING_FOOTER.test(message);
- if (isBreaking) {
+ if (message.includes(MAJOR_MARKER)) {
return 'major';
}
+ const subject = message.split('\n', 1)[0]?.trim() ?? '';
const isFeature =
message.includes(MINOR_MARKER) || FEATURE_SUBJECT.test(subject);
return isFeature ? 'minor' : 'patch';