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): ignore marketing-site commits and count every feat (#558)

Carl-Gerhard Lindesvärd82ece23dbddb
diff --git a/AGENTS.md b/AGENTS.md
index 92dadfbc5..f02ca1354 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -219,6 +219,10 @@ to PR titles, which become the commit on a squash merge.
upgrade. That is what the release notes' "Upgrade notes" are built from; add
the matching `openpanel doctor` check in the same change (`self-hosting/cli`).
- One logical change per commit. No "WIP", "fixes", or "address review".
+- A commit that only touches `apps/public` (the marketing site) never bumps
+ the version and is left out of the release notes
+ (`tooling/release/src/release-scope.ts`). Keep site changes in their own
+ commits and PRs so they stay out of the product's releases.
**Agents never mark a commit as breaking.** Do not write `!` after the type
(`feat!:`), a `BREAKING CHANGE:` footer, or `[major]`, even when the change
diff --git a/tooling/release/src/decide.test.ts b/tooling/release/src/decide.test.ts
index c82c9c666..0d22a90ca 100644
--- a/tooling/release/src/decide.test.ts
+++ b/tooling/release/src/decide.test.ts
@@ -1,9 +1,10 @@
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
import { execFileSync } from 'node:child_process';
-import { mkdtempSync, rmSync } from 'node:fs';
+import { appendFileSync, mkdirSync, mkdtempSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
-import { join } from 'node:path';
+import { dirname, join } from 'node:path';
import { decide } from './next-version';
+import { readCommits } from './release-notes';
// A git hook (pre-push runs this suite) exports GIT_DIR and friends, which win
// over `cwd`: this suite once committed, tagged and set user/core.bare on the
@@ -26,8 +27,17 @@ process.env.GIT_CONFIG_GLOBAL = '/dev/null';
const run = (...args: string[]) =>
execFileSync('git', args, { cwd: repo, encoding: 'utf8' }).trim();
-const commit = (message: string) => {
- run('commit', '--allow-empty', '-q', '-m', message);
+const PRODUCT_FILE = 'packages/core/src/index.ts';
+const PUBLIC_FILE = 'apps/public/content/page.mdx';
+
+const commit = (message: string, paths: string[] = [PRODUCT_FILE]) => {
+ for (const path of paths) {
+ const file = join(repo, path);
+ mkdirSync(dirname(file), { recursive: true });
+ appendFileSync(file, `${message}\n`);
+ }
+ run('add', '-A');
+ run('commit', '-q', '-m', message);
return run('rev-parse', 'HEAD');
};
const originalCwd = process.cwd();
@@ -81,4 +91,50 @@ describe('decide', () => {
run('tag', 'v3.1.1', newer);
expect(decide(older)).toEqual({ kind: 'superseded', by: '3.1.1' });
});
+
+ test('a feat followed by a fix is still a minor bump', () => {
+ commit('feat(api): earlier feature');
+ const head = commit('fix(api): later fix');
+ expect(decide(head)).toMatchObject({
+ kind: 'new',
+ version: '3.2.0',
+ bump: 'minor',
+ });
+ run('tag', 'v3.2.0', head);
+ });
+
+ test('a feat that only touches the marketing site does not bump the version', () => {
+ commit('feat(public): new compare page', [PUBLIC_FILE]);
+ const head = commit('fix(api): small thing');
+ expect(decide(head)).toMatchObject({
+ kind: 'new',
+ version: '3.2.1',
+ bump: 'patch',
+ });
+ run('tag', 'v3.2.1', head);
+ });
+
+ test('a feat that also changes product code still counts', () => {
+ const head = commit('feat: dashboard and docs together', [
+ PRODUCT_FILE,
+ PUBLIC_FILE,
+ ]);
+ expect(decide(head)).toMatchObject({
+ kind: 'new',
+ version: '3.3.0',
+ bump: 'minor',
+ });
+ run('tag', 'v3.3.0', head);
+ });
+});
+
+describe('readCommits', () => {
+ test('leaves out commits that only touch the marketing site', () => {
+ commit('chore(public): rewrite an article', [PUBLIC_FILE]);
+ commit('fix(api): keep this one');
+ const subjects = readCommits('v3.3.0', 'HEAD').map(
+ (entry) => entry.subject
+ );
+ expect(subjects).toEqual(['fix(api): keep this one']);
+ });
});
diff --git a/tooling/release/src/next-version.ts b/tooling/release/src/next-version.ts
index 2ce1dab70..330dcd70b 100644
--- a/tooling/release/src/next-version.ts
+++ b/tooling/release/src/next-version.ts
@@ -1,6 +1,7 @@
import { appendFileSync } from 'node:fs';
import semver from 'semver';
import { git, gitOrNull, lines } from './git';
+import { RELEASE_PATHSPEC } from './release-scope';
export type Bump = 'patch' | 'minor' | 'major';
@@ -23,7 +24,8 @@ export const bumpFor = (message: string): Bump => {
if (message.includes(MAJOR_MARKER)) {
return 'major';
}
- const subject = message.split('\n', 1)[0]?.trim() ?? '';
+ // Every `git log` entry after the first starts with the newline that ended the previous one.
+ const subject = message.trim().split('\n', 1)[0] ?? '';
const isFeature =
message.includes(MINOR_MARKER) || FEATURE_SUBJECT.test(subject);
return isFeature ? 'minor' : 'patch';
@@ -86,7 +88,7 @@ export const decide = (sha: string): Decision => {
);
const previous = previousTag ? versionOf(previousTag) : null;
const range = previousTag ? `${previousTag}..${sha}` : sha;
- const messages = git('log', '--format=%B%x00', range)
+ const messages = git('log', '--format=%B%x00', range, ...RELEASE_PATHSPEC)
.split('\0')
.filter((message) => message.trim());
const bump = highestBump(messages);
diff --git a/tooling/release/src/release-notes.ts b/tooling/release/src/release-notes.ts
index 2e67f2bb3..d6eedee10 100644
--- a/tooling/release/src/release-notes.ts
+++ b/tooling/release/src/release-notes.ts
@@ -2,6 +2,7 @@ import { writeFileSync } from 'node:fs';
import { parseArgs } from 'node:util';
import OpenAI from 'openai';
import { git, lines } from './git';
+import { RELEASE_PATHSPEC } from './release-scope';
// OpenAI's top model: there are only a handful of public releases a year, and
// these notes are what self-hosters read, so quality wins over cost here.
@@ -127,7 +128,8 @@ export const readCommits = (from: string, to: string): Commit[] =>
'log',
'--no-merges',
`--format=%H${FIELD}%s${FIELD}%b${RECORD}`,
- `${from}..${to}`
+ `${from}..${to}`,
+ ...RELEASE_PATHSPEC
)
.split(RECORD)
.map((record) => record.trim())
diff --git a/tooling/release/src/release-scope.ts b/tooling/release/src/release-scope.ts
new file mode 100644
index 000000000..bec44c877
--- /dev/null
+++ b/tooling/release/src/release-scope.ts
@@ -0,0 +1,12 @@
+// The marketing site deploys on its own and ships nothing in the release
+// images, so a commit that only touches it neither bumps the version nor
+// appears in the release notes. A commit that also changes product code still
+// counts in full.
+const EXCLUDED_PATHS = ['apps/public'];
+
+// `top` anchors the pathspec at the repository root, whatever the cwd is.
+export const RELEASE_PATHSPEC = [
+ '--',
+ ':(top)',
+ ...EXCLUDED_PATHS.map((path) => `:(top,exclude)${path}`),
+];