OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.
release: write the release notes with OpenAI gpt-6-astra
Carl-Gerhard Lindesvärd461e86af83ef
diff --git a/.github/workflows/self-hosting-release.yml b/.github/workflows/self-hosting-release.ymlindex 808af2012..81d3d9d7b 100644--- a/.github/workflows/self-hosting-release.yml+++ b/.github/workflows/self-hosting-release.yml@@ -5,7 +5,7 @@ name: Self-hosting release# 1. its v* tag says which version it is (commits main never built have none)# 2. the images main already built and smoke-tested are copied to Docker Hub# 3. the CLI is built for every platform, stamped with the same version-# 4. Claude writes the notes for everything since the previous public release+# 4. GPT-6 Astra writes the notes for everything since the previous public release# 5. a GitHub release `vX.Y.Z` carries the notes, the CLI and checksums.txt# That release is what `openpanel upgrade` and install.sh look for, and the# previous one is where the next release's notes start.@@ -184,7 +184,7 @@ jobs:# release never waits on it.- name: Write release notesenv:- ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}run: bun tooling/release/src/release-notes.ts --from "${{ needs.resolve.outputs.previous }}" --to "v${{ needs.resolve.outputs.version }}" --out release-notes.md- uses: actions/upload-artifact@v4diff --git a/bun.lock b/bun.lockindex ef197eac8..19b413dc9 100644--- a/bun.lock+++ b/bun.lock@@ -610,7 +610,7 @@"name": "@openpanel/release","version": "0.1.0","dependencies": {- "@anthropic-ai/sdk": "0.130.0",+ "openai": "^7.25.0","semver": "7.6.0",},"devDependencies": {@@ -670,8 +670,6 @@"@ampproject/remapping": ["@ampproject/[email protected]", "", { "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw=="],- "@anthropic-ai/sdk": ["@anthropic-ai/[email protected]", "", { "dependencies": { "json-schema-to-ts": "^3.1.1", "standardwebhooks": "^1.0.0" }, "peerDependencies": { "zod": "^3.25.0 || ^4.0.0" }, "optionalPeers": ["zod"], "bin": { "anthropic-ai-sdk": "bin/cli" } }, "sha512-UMkwdFHvIdhYJHuPYkufmBTePKgk50RolnqZPUqyPclXp7LoVM7QgXsfQnx7KlmbkQtb+RhmUjN5ARYpbnz9YQ=="],-"@asamuzakjp/css-color": ["@asamuzakjp/[email protected]", "", { "dependencies": { "@csstools/css-calc": "^2.1.3", "@csstools/css-color-parser": "^3.0.9", "@csstools/css-parser-algorithms": "^3.0.4", "@csstools/css-tokenizer": "^3.0.3", "lru-cache": "^10.4.3" } }, "sha512-K1A6z8tS3XsmCMM86xoWdn7Fkdn9m6RSVtocUrJYIwZnFVkng/PvkEoWtOWmP+Scc6saYWHWZYbndEEXxl24jw=="],"@ast-grep/napi": ["@ast-grep/[email protected]", "", { "optionalDependencies": { "@ast-grep/napi-darwin-arm64": "0.40.5", "@ast-grep/napi-darwin-x64": "0.40.5", "@ast-grep/napi-linux-arm64-gnu": "0.40.5", "@ast-grep/napi-linux-arm64-musl": "0.40.5", "@ast-grep/napi-linux-x64-gnu": "0.40.5", "@ast-grep/napi-linux-x64-musl": "0.40.5", "@ast-grep/napi-win32-arm64-msvc": "0.40.5", "@ast-grep/napi-win32-ia32-msvc": "0.40.5", "@ast-grep/napi-win32-x64-msvc": "0.40.5" } }, "sha512-hJA62OeBKUQT68DD2gDyhOqJxZxycqg8wLxbqjgqSzYttCMSDL9tiAQ9abgekBYNHudbJosm9sWOEbmCDfpX2A=="],@@ -4776,6 +4774,8 @@"open": ["[email protected]", "", { "dependencies": { "define-lazy-prop": "^2.0.0", "is-docker": "^2.1.1", "is-wsl": "^2.2.0" } }, "sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ=="],+ "openai": ["[email protected]", "", { "peerDependencies": { "@aws-sdk/credential-provider-node": ">=3.972.0 <4", "@smithy/hash-node": ">=4.3.0 <5", "@smithy/signature-v4": ">=5.4.0 <6", "undici": ">=5 <9", "ws": "^8.21.0", "zod": "^3.25 || ^4.0" }, "optionalPeers": ["@aws-sdk/credential-provider-node", "@smithy/hash-node", "@smithy/signature-v4", "undici", "ws", "zod"] }, "sha512-cnk0d4QT58Vq0vl2KG+DCa/C2+cXthsK2rUeaqtprq33mKv9dlX8o7fWSS283wa2IE/aVdsRyX1+Dqwz551olg=="],+"openapi-sampler": ["[email protected]", "", { "dependencies": { "@types/json-schema": "^7.0.7", "fast-xml-parser": "^5.5.1", "json-pointer": "0.6.2" } }, "sha512-zpnod1EYNkMP3xg18bhMknvzdaxz5ePUyHakO/7zwEIq/Y8T0SsliS9a+YXCWQCvn+5LfE//UtDVoUULcKdVAQ=="],"openapi-types": ["[email protected]", "", {}, "sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw=="],diff --git a/tooling/release/package.json b/tooling/release/package.jsonindex 04b31d0af..aa40b578d 100644--- a/tooling/release/package.json+++ b/tooling/release/package.json@@ -9,7 +9,7 @@"typecheck": "tsc --noEmit"},"dependencies": {- "@anthropic-ai/sdk": "0.130.0",+ "openai": "7.25.0","semver": "7.6.0"},"devDependencies": {diff --git a/tooling/release/src/release-notes.test.ts b/tooling/release/src/release-notes.test.tsindex 4a7f6f6a6..0d3859f84 100644--- a/tooling/release/src/release-notes.test.ts+++ b/tooling/release/src/release-notes.test.ts@@ -1,5 +1,5 @@import { describe, expect, test } from 'bun:test';-import type Anthropic from '@anthropic-ai/sdk';+import type OpenAI from 'openai';import {fallbackNotes,generateNotes,@@ -25,7 +25,7 @@ const input: NotesInput = {// Just enough of the client for generateNotes; each test decides the outcome.const fakeClient = (create: () => Promise<unknown>) =>- ({ beta: { messages: { create } } }) as unknown as Anthropic;+ ({ responses: { create } }) as unknown as OpenAI;describe('release notes', () => {test('CI markers never reach the notes', () => {@@ -69,28 +69,25 @@ describe('release notes', () => {});});- test('a declined request means the fallback', async () => {+ test('an incomplete response (cut off or declined) means the fallback', async () => {const client = fakeClient(() =>- Promise.resolve({ stop_reason: 'refusal', content: [] })+ Promise.resolve({ status: 'incomplete', output_text: '## Added\n- half' }));expect(await generateNotes(input, client)).toMatchObject({source: 'fallback',- reason: 'model declined',+ reason: 'response incomplete',});});test('model text is used, with the compare link appended', async () => {const client = fakeClient(() =>Promise.resolve({- stop_reason: 'end_turn',- content: [- { type: 'thinking', thinking: '' },- { type: 'text', text: '## Added\n- Export endpoint' },- ],+ status: 'completed',+ output_text: '## Added\n- Export endpoint',}));const notes = await generateNotes(input, client);- expect(notes.source).toBe('claude');+ expect(notes.source).toBe('model');expect(notes.markdown).toStartWith('## Added\n- Export endpoint');expect(notes.markdown).toContain(input.compareUrl as string);});diff --git a/tooling/release/src/release-notes.ts b/tooling/release/src/release-notes.tsindex df31ac68f..2e67f2bb3 100644--- a/tooling/release/src/release-notes.ts+++ b/tooling/release/src/release-notes.ts@@ -1,10 +1,12 @@import { writeFileSync } from 'node:fs';import { parseArgs } from 'node:util';-import Anthropic from '@anthropic-ai/sdk';+import OpenAI from 'openai';import { git, lines } from './git';-const MODEL = 'claude-opus-5-5';-const MAX_TOKENS = 16_000;+// 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.+const MODEL = 'gpt-6-astra';+const REASONING_EFFORT = 'high';const FIELD = '\u001f';const RECORD = '\u001e';@@ -80,58 +82,43 @@ const userPrompt = (input: NotesInput): string => {return `Release v${input.version} (previous release: v${input.previous}).\n\nChanged files that can affect a self-hosted install:\n${sensitive}\n\nCommits:\n\n${commits}`;};-type Generated = {+interface Generated {markdown: string;- source: 'claude' | 'fallback';+ source: 'model' | 'fallback';reason?: string;-};+}++const fallback = (input: NotesInput, reason: string): Generated => ({+ markdown: fallbackNotes(input),+ source: 'fallback',+ reason,+});export const generateNotes = async (input: NotesInput,- client: Anthropic | null+ client: OpenAI | null): Promise<Generated> => {if (!client) {- return {- markdown: fallbackNotes(input),- source: 'fallback',- reason: 'no API key',- };+ return fallback(input, 'no API key');}try {- const response = await client.beta.messages.create({+ const response = await client.responses.create({model: MODEL,- max_tokens: MAX_TOKENS,- betas: ['server-side-fallback-2026-07-01'],- fallbacks: 'default',- output_config: { effort: 'medium' },- system: SYSTEM_PROMPT,- messages: [{ role: 'user', content: userPrompt(input) }],+ reasoning: { effort: REASONING_EFFORT },+ instructions: SYSTEM_PROMPT,+ input: userPrompt(input),});- if (response.stop_reason === 'refusal') {- return {- markdown: fallbackNotes(input),- source: 'fallback',- reason: 'model declined',- };+ // `incomplete` (cut off or declined) must not publish half a note.+ if (response.status !== 'completed') {+ return fallback(input, `response ${response.status}`);}- const text = response.content- .flatMap((block) => (block.type === 'text' ? [block.text] : []))- .join('')- .trim();+ const text = response.output_text.trim();if (!text) {- return {- markdown: fallbackNotes(input),- source: 'fallback',- reason: 'empty response',- };+ return fallback(input, 'empty response');}- return { markdown: `${text}${compareLine(input)}\n`, source: 'claude' };+ return { markdown: `${text}${compareLine(input)}\n`, source: 'model' };} catch (error) {- return {- markdown: fallbackNotes(input),- source: 'fallback',- reason: (error as Error).message,- };+ return fallback(input, (error as Error).message);}};@@ -175,12 +162,12 @@ if (import.meta.main) {? `${process.env.GITHUB_SERVER_URL ?? 'https://github.com'}/${repository}/compare/${values.from}...${values.to}`: null,};- const client = process.env.ANTHROPIC_API_KEY ? new Anthropic() : null;+ const client = process.env.OPENAI_API_KEY ? new OpenAI() : null;const notes = await generateNotes(input, client);writeFileSync(values.out, notes.markdown);const usage =- notes.source === 'claude'- ? 'written by Claude'+ notes.source === 'model'+ ? `written by ${MODEL}`: `plain commit list (${notes.reason})`;console.error(`${input.commits.length} commits, ${input.sensitivePaths.length} upgrade-sensitive files; notes ${usage} -> ${values.out}`