Skip to content

AI-native design editor. Open-source Figma alternative.

ci: derive GitHub Release metadata from changelog (#536)

Danila Poyarkov54c1373d3e98
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 517f41762..e8f41c411 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -54,48 +54,18 @@ jobs:
- uses: ./.github/actions/setup-bun
- name: Extract release notes
+ if: startsWith(github.ref, 'refs/tags/v')
id: changelog
shell: bash
run: |
+ VERSION="${GITHUB_REF_NAME#v}"
+ NOTES_FILE="$RUNNER_TEMP/release-notes.md"
+ bun tools/release-packages/src/extract-release-notes.ts "$VERSION" "$NOTES_FILE"
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "release_notes<<$EOF" >> "$GITHUB_OUTPUT"
- awk '/^## /{if(found)exit; found=1; next} found{print}' CHANGELOG.md >> "$GITHUB_OUTPUT"
+ cat "$NOTES_FILE" >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
- - name: Add new contributors to release notes
- if: startsWith(github.ref, 'refs/tags/v')
- id: release_body
- shell: bash
- env:
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- RELEASE_NOTES: ${{ steps.changelog.outputs.release_notes }}
- run: |
- PREV_TAG=$(git tag -l 'v*' --sort=-version:refname | sed -n '2p')
- NEW=""
- if [ -n "$PREV_TAG" ]; then
- PREV=$(git log "$PREV_TAG" --format='%aE' | sort -u)
- NEW=$(comm -23 \
- <(git log "${PREV_TAG}..${{ github.ref_name }}" --format='%aE' | sort -u) \
- <(echo "$PREV") \
- | while read -r email; do
- git log "${PREV_TAG}..${{ github.ref_name }}" --format="%aE %aN" \
- | grep "^${email} " | head -1 | sed 's/^[^ ]* //'
- done)
- fi
-
- EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
- {
- echo "body<<$EOF"
- printf '%s\n' "$RELEASE_NOTES"
- if [ -n "$NEW" ]; then
- echo ""
- echo "### New Contributors"
- echo ""
- echo "$NEW" | while read -r name; do echo "- $name"; done
- fi
- echo "$EOF"
- } >> "$GITHUB_OUTPUT"
-
- name: Build Tauri
uses: tauri-apps/tauri-action@v0
env:
@@ -111,8 +81,8 @@ jobs:
tauriScript: bunx tauri
args: --target ${{ matrix.target }}
tagName: ${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || '' }}
- releaseName: ${{ startsWith(github.ref, 'refs/tags/v') && format('OpenPencil {0}', github.ref_name) || '' }}
- releaseBody: ${{ steps.release_body.outputs.body || steps.changelog.outputs.release_notes }}
+ releaseName: ${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || '' }}
+ releaseBody: ${{ steps.changelog.outputs.release_notes }}
releaseDraft: true
uploadUpdaterJson: true
uploadUpdaterSignatures: true
diff --git a/AGENTS.md b/AGENTS.md
index c3ae314aa..0e83e77ad 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -83,13 +83,14 @@ App dialogs compose the Reka-backed components under `src/components/ui/dialog/`
2. Update `CHANGELOG.md` — move "Unreleased" items under new version heading with date
3. Commit: `Release v0.x.y`
4. Tag: `git tag v0.x.y && git push --tags`
-5. Ensure GitHub release secrets include `TAURI_SIGNING_PRIVATE_KEY` (and `TAURI_SIGNING_PRIVATE_KEY_PASSWORD` if the updater key is password-protected); the public updater key is configured in `desktop/tauri.conf.json`.
+5. Ensure GitHub release secrets include `TAURI_SIGNING_PRIVATE_KEY` (and `TAURI_SIGNING_PRIVATE_KEY_PASSWORD` if the updater key is password-protected); the public updater key is configured in `desktop/tauri.conf.json`. macOS signing and notarization additionally require `APPLE_CERTIFICATE`, `APPLE_CERTIFICATE_PASSWORD`, `APPLE_ID`, `APPLE_PASSWORD`, and `APPLE_TEAM_ID`.
6. The `build.yml` workflow triggers on `v*` tags and:
- Builds Tauri binaries for macOS (arm64 + x64), Windows (x64 + arm64), Linux (x64)
- - Creates a draft GitHub Release with all platform binaries
- - Publishes public workspace packages to npm with provenance. Keep the exact package list in sync with `.github/workflows/build.yml`.
+ - Creates a draft GitHub Release whose title exactly matches the tag and whose body is the matching version section from `CHANGELOG.md`
+ - Uploads platform installers, updater signatures, and `latest.json`
+ - Publishes public workspace packages to npm with provenance. Keep the exact package list in sync with `.github/workflows/build.yml` and `tools/release-packages/src/publish-dirs.ts`.
7. The production web app/docs deploy workflows (`app.yml`, `docs.yml`) also trigger on `v*` tags. They do **not** deploy on ordinary `master` pushes.
-8. Go to GitHub Releases → edit the draft → paste changelog section → publish
+8. Verify the draft’s title and changelog-derived body, then publish it. Publishing the GitHub Release triggers `homebrew.yml`, which updates the Homebrew cask from the signed macOS updater archives.
### CI workflows
diff --git a/bun.lock b/bun.lock
index be8488e81..8853e684c 100644
--- a/bun.lock
+++ b/bun.lock
@@ -103,6 +103,7 @@
"@wdio/mocha-framework": "9.30.1",
"@wdio/spec-reporter": "9.30.1",
"@wdio/tauri-service": "1.3.0",
+ "changelog-parser": "^4.1.0",
"cloudflare-redirect-parser": "^1.0.0",
"esbuild": "^0.27.3",
"expect-webdriverio": "5.7.0",
@@ -1798,6 +1799,8 @@
"chalk": ["[email protected]", "", { "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } }, "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA=="],
+ "changelog-parser": ["[email protected]", "", { "dependencies": { "remove-markdown": "^0.6.4" }, "bin": { "changelog-parser": "dist/cli.js" } }, "sha512-FzpTTPllU+AhXrlR2R8kFjHeyz+c/htnK58GqpwBBtduFqjiRNA/fPg1rHKiJVGcMZDamWEuYMJZ93jyWVvd+A=="],
+
"char-regex": ["[email protected]", "", {}, "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw=="],
"character-entities": ["[email protected]", "", {}, "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ=="],
@@ -3152,6 +3155,8 @@
"remark-stringify": ["[email protected]", "", { "dependencies": { "@types/mdast": "^4.0.0", "mdast-util-to-markdown": "^2.0.0", "unified": "^11.0.0" } }, "sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw=="],
+ "remove-markdown": ["[email protected]", "", {}, "sha512-BompiLClzjfh46irZmzv+1Q61jZYlKN3iq/hzae9EOUwf7ctr/5wpD4qwgn/FWDAYE18RORO7z/yr+HXZJCY8Q=="],
+
"repeat-string": ["[email protected]", "", {}, "sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w=="],
"reprism": ["[email protected]", "", {}, "sha512-VsxDR5QxZo08M/3nRypNlScw5r3rKeSOPdU/QhDmu3Ai3BJxHn/qgfXGWQp/tAxUtzwYNo9W6997JZR0tPLZsA=="],
diff --git a/package.json b/package.json
index 5b64432a9..401090fe2 100644
--- a/package.json
+++ b/package.json
@@ -16,7 +16,6 @@
"packages/docs",
"tools/docs"
],
- "packageManager": "[email protected]",
"type": "module",
"scripts": {
"dev": "vite",
@@ -162,6 +161,7 @@
"@wdio/mocha-framework": "9.30.1",
"@wdio/spec-reporter": "9.30.1",
"@wdio/tauri-service": "1.3.0",
+ "changelog-parser": "^4.1.0",
"cloudflare-redirect-parser": "^1.0.0",
"esbuild": "^0.27.3",
"expect-webdriverio": "5.7.0",
@@ -197,5 +197,6 @@
"overrides": {
"protobufjs": "7.5.5",
"websocket-driver": "0.7.5"
- }
+ },
+ "packageManager": "[email protected]"
}
diff --git a/tools/release-packages/src/extract-release-notes.ts b/tools/release-packages/src/extract-release-notes.ts
new file mode 100644
index 000000000..9c0584334
--- /dev/null
+++ b/tools/release-packages/src/extract-release-notes.ts
@@ -0,0 +1,12 @@
+import { writeFile } from 'node:fs/promises'
+import { resolve } from 'node:path'
+
+import { readReleaseNotes } from './release-notes'
+
+const [version, outputPath] = process.argv.slice(2)
+if (!version || !outputPath) {
+ throw new Error('Usage: bun extract-release-notes.ts <version> <output-path>')
+}
+
+const notes = await readReleaseNotes(resolve('CHANGELOG.md'), version)
+await writeFile(resolve(outputPath), notes)
diff --git a/tools/release-packages/src/release-notes.ts b/tools/release-packages/src/release-notes.ts
new file mode 100644
index 000000000..2895d2b0f
--- /dev/null
+++ b/tools/release-packages/src/release-notes.ts
@@ -0,0 +1,11 @@
+import { parseChangelog } from 'changelog-parser'
+
+export async function readReleaseNotes(path: string, version: string): Promise<string> {
+ const changelog = await parseChangelog({ filePath: path, removeMarkdown: false })
+ const release = changelog.versions.find((entry) => entry.version === version)
+ if (!release) throw new Error(`Changelog section not found for ${version}`)
+
+ const notes = release.body.trim()
+ if (!notes) throw new Error(`Changelog section is empty for ${version}`)
+ return `${notes}\n`
+}
diff --git a/tools/release-packages/tests/release-notes.test.ts b/tools/release-packages/tests/release-notes.test.ts
new file mode 100644
index 000000000..b2f3975a5
--- /dev/null
+++ b/tools/release-packages/tests/release-notes.test.ts
@@ -0,0 +1,63 @@
+import { describe, expect, test } from 'bun:test'
+import { mkdir, writeFile } from 'node:fs/promises'
+import { tmpdir } from 'node:os'
+import { join } from 'node:path'
+
+import { readReleaseNotes } from '../src/release-notes'
+
+const changelog = `# Changelog
+
+## Unreleased
+
+### Added
+
+- Pending work.
+
+## 1.2.0 — 2026-08-16
+
+### Added
+
+- Shipped **feature**.
+
+### Fixed
+
+- Corrected behavior.
+
+## 1.1.0 — 2026-08-01
+
+### Fixed
+
+- Previous fix.
+`
+
+async function changelogPath(contents = changelog) {
+ const directory = join(tmpdir(), `open-pencil-release-notes-${crypto.randomUUID()}`)
+ await mkdir(directory, { recursive: true })
+ const path = join(directory, 'CHANGELOG.md')
+ await writeFile(path, contents)
+ return path
+}
+
+describe('readReleaseNotes', () => {
+ test('extracts the requested version without its heading and preserves Markdown', async () => {
+ expect(await readReleaseNotes(await changelogPath(), '1.2.0')).toBe(
+ `### Added
+
+- Shipped **feature**.
+
+### Fixed
+
+- Corrected behavior.
+`
+ )
+ })
+
+ test('rejects missing and empty release sections', async () => {
+ await expect(readReleaseNotes(await changelogPath(), '9.9.9')).rejects.toThrow(
+ 'Changelog section not found for 9.9.9'
+ )
+ await expect(
+ readReleaseNotes(await changelogPath('## 1.2.0 — 2026-08-16\n'), '1.2.0')
+ ).rejects.toThrow('Changelog section is empty for 1.2.0')
+ })
+})