From 0605dbabe6d944af596f035865cf5a176515fb84 Mon Sep 17 00:00:00 2001 From: Benjamin Hardy Date: Fri, 16 Oct 2026 18:04:54 +0200 Subject: [PATCH] Improved release description and file names --- .github/scripts/release_assets.py | 97 ++++++++++++++++++++++++ .github/scripts/updater_manifest.py | 69 ----------------- .github/workflows/build.yml | 42 +++++----- CLAUDE.md | 12 ++- frontend/src/components/UpdateDialog.tsx | 9 ++- 5 files changed, 137 insertions(+), 92 deletions(-) create mode 100644 .github/scripts/release_assets.py delete mode 100644 .github/scripts/updater_manifest.py diff --git a/.github/scripts/release_assets.py b/.github/scripts/release_assets.py new file mode 100644 index 0000000..f27cd28 --- /dev/null +++ b/.github/scripts/release_assets.py @@ -0,0 +1,97 @@ +"""Lay out one release's assets under user-facing names, plus the updater's +latest.json and the release notes' Download section. + +Run by build.yml's release job: + + python3 .github/scripts/release_assets.py artifacts release \\ + --version 0.6.0 --tag v0.6.0-b42 --repo owner/konduktor + +Finds, anywhere under `artifacts`, what `tauri build` produced: the macOS +`*.dmg` and `*.app.tar.gz` (+ `.sig`) and the Windows `*-setup.exe` (+ `.sig`). +Copies them into `release` as + + Konduktor--macOS.dmg (download) + Konduktor--Windows-Setup.exe (download; the Windows updater runs it too) + Konduktor--app-updater.tar.gz (the macOS updater's package) + latest.json (the updater's manifest) + +and writes `download.md`. Renaming is safe: the signatures cover contents, +not names, and latest.json is written from the final names. `latest.json` +itself keeps its name: the app asks for releases/download//latest.json. +Fails if anything is missing: a manifest lacking a platform is refused by the +updater as a whole. +""" + +import argparse +import json +import shutil +import sys +from datetime import datetime, timezone +from pathlib import Path +from urllib.parse import quote + + +def find_one(root: Path, suffix: str) -> Path: + found = [p for p in root.rglob(f"*{suffix}") if p.is_file()] + if len(found) != 1: + sys.exit(f"expected exactly one *{suffix} under {root}, found {len(found)}") + return found[0] + + +def signature(asset: Path) -> str: + sig = asset.with_name(asset.name + ".sig") + if not sig.is_file(): + sys.exit(f"missing signature {sig}") + return sig.read_text(encoding="utf-8").strip() + + +def lay_out(artifacts: Path, out: Path, version: str, tag: str, repo: str) -> None: + def url(name: str) -> str: + return f"https://github.com/{repo}/releases/download/{quote(tag)}/{quote(name)}" + + dmg = find_one(artifacts, ".dmg") + app = find_one(artifacts, ".app.tar.gz") + setup = find_one(artifacts, "-setup.exe") + + names = { + dmg: f"Konduktor-{version}-macOS.dmg", + setup: f"Konduktor-{version}-Windows-Setup.exe", + app: f"Konduktor-{version}-app-updater.tar.gz", + } + # Tauri's platform keys -> the file that platform's updater installs. + manifest = { + "version": version, + "pub_date": datetime.now(timezone.utc).replace(microsecond=0).isoformat().replace("+00:00", "Z"), + "platforms": { + "darwin-aarch64": {"signature": signature(app), "url": url(names[app])}, + "windows-x86_64": {"signature": signature(setup), "url": url(names[setup])}, + }, + } + + out.mkdir(parents=True, exist_ok=True) + for src, name in names.items(): + shutil.copy2(src, out / name) + (out / "latest.json").write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8") + (out / "download.md").write_text( + "## Download\n" + f"- **macOS** (Apple Silicon): [{names[dmg]}]({url(names[dmg])})\n" + f"- **Windows**: [{names[setup]}]({url(names[setup])})\n", + encoding="utf-8", + ) + + +def main() -> None: + ap = argparse.ArgumentParser(description=__doc__.splitlines()[0]) + ap.add_argument("artifacts", type=Path) + ap.add_argument("out", type=Path) + ap.add_argument("--version", required=True) + ap.add_argument("--tag", required=True) + ap.add_argument("--repo", required=True) + args = ap.parse_args() + lay_out(args.artifacts, args.out, args.version, args.tag, args.repo) + for p in sorted(args.out.iterdir()): + print(p.name) + + +if __name__ == "__main__": + main() diff --git a/.github/scripts/updater_manifest.py b/.github/scripts/updater_manifest.py deleted file mode 100644 index 846a501..0000000 --- a/.github/scripts/updater_manifest.py +++ /dev/null @@ -1,69 +0,0 @@ -"""Write the Tauri updater's latest.json for one release. - -The app's update dialog finds the release itself (newest app tag on GitHub) -and points the updater at THAT release's latest.json, so each release carries -its own manifest describing its own assets. Run by build.yml's release job: - - python3 .github/scripts/updater_manifest.py artifacts \\ - --version 0.6.0 --tag v0.6.0-b42 --repo owner/konduktor - -Expects, anywhere under the folder, the macOS `*.app.tar.gz` and the Windows -`*-setup.exe`, each with its `.sig` (written by `tauri build` when -`bundle.createUpdaterArtifacts` is on). Fails if any is missing: a release -whose manifest lacks a platform would be refused by the updater as a whole. -""" - -import argparse -import json -import sys -from datetime import datetime, timezone -from pathlib import Path -from urllib.parse import quote - -# Tauri's platform keys -> the asset suffix that platform installs from. -PLATFORMS = { - "darwin-aarch64": ".app.tar.gz", - "windows-x86_64": "-setup.exe", -} - - -def find_one(root: Path, suffix: str) -> Path: - found = [p for p in root.rglob(f"*{suffix}") if p.is_file()] - if len(found) != 1: - sys.exit(f"expected exactly one *{suffix} under {root}, found {len(found)}") - return found[0] - - -def build(root: Path, version: str, tag: str, repo: str) -> dict: - platforms = {} - for key, suffix in PLATFORMS.items(): - asset = find_one(root, suffix) - sig = asset.with_name(asset.name + ".sig") - if not sig.is_file(): - sys.exit(f"missing signature {sig}") - platforms[key] = { - "signature": sig.read_text(encoding="utf-8").strip(), - "url": f"https://github.com/{repo}/releases/download/{quote(tag)}/{quote(asset.name)}", - } - return { - "version": version, - "pub_date": datetime.now(timezone.utc).replace(microsecond=0).isoformat().replace("+00:00", "Z"), - "platforms": platforms, - } - - -def main() -> None: - ap = argparse.ArgumentParser(description=__doc__.splitlines()[0]) - ap.add_argument("artifacts", type=Path) - ap.add_argument("--version", required=True) - ap.add_argument("--tag", required=True) - ap.add_argument("--repo", required=True) - args = ap.parse_args() - manifest = build(args.artifacts, args.version, args.tag, args.repo) - out = args.artifacts / "latest.json" - out.write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8") - print(f"wrote {out}") - - -if __name__ == "__main__": - main() diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 06c218d..6e738a2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -201,11 +201,24 @@ jobs: pattern: konduktor-* path: artifacts # → artifacts/konduktor-macOS/…, artifacts/konduktor-Windows/… + # The release's files under user-facing names, the in-app updater's + # latest.json (the app reads releases/download//latest.json) and the + # notes' Download section. The .sig files are folded into latest.json and + # not uploaded themselves. + - name: Release assets + run: | + python3 .github/scripts/release_assets.py artifacts release \ + --version "${{ steps.version.outputs.version }}" \ + --tag "v${{ steps.version.outputs.version }}-b${{ github.run_number }}" \ + --repo "${{ github.repository }}" + # Release notes from the "Patch notes" section of the PR that merged this # commit into main (dev → main merges carry many features in one PR, so # its title alone says little). Written under "What's Changed", the # heading the app's update dialog reads. No PR (a manual run, a direct - # push) or no such section → GitHub's generated notes, as before. + # push) or no such section → GitHub's generated notes, as before. The + # Download section always comes first (the action puts the body above + # generated notes); the dialog reads only "What's Changed". - name: Patch notes from the merged PR id: notes env: @@ -230,35 +243,26 @@ jobs: section.append(line) notes = "\n".join(section).strip() found = bool(notes) - if found: - with open("release-notes.md", "w", encoding="utf-8") as f: - f.write("## What's Changed\n\n" + notes + "\n") + with open("release-notes.md", "w", encoding="utf-8") as f: + f.write(open("release/download.md", encoding="utf-8").read()) + if found: + f.write("\n## What's Changed\n\n" + notes + "\n") with open(os.environ["GITHUB_OUTPUT"], "a") as out: out.write(f"found={'true' if found else 'false'}\n") print("Using the PR's patch notes." if found else "No patch notes section; using generated notes.") EOF - # The in-app updater's manifest for THIS release (the app's update - # dialog finds the release, then reads releases/download//latest.json). - # The .sig files are folded into it and not uploaded themselves. - - name: Updater manifest - run: | - python3 .github/scripts/updater_manifest.py artifacts \ - --version "${{ steps.version.outputs.version }}" \ - --tag "v${{ steps.version.outputs.version }}-b${{ github.run_number }}" \ - --repo "${{ github.repository }}" - - name: Publish release uses: softprops/action-gh-release@v2 with: tag_name: v${{ steps.version.outputs.version }}-b${{ github.run_number }} name: Konduktor v${{ steps.version.outputs.version }}-b${{ github.run_number }} target_commitish: ${{ github.sha }} - body_path: ${{ steps.notes.outputs.found == 'true' && 'release-notes.md' || '' }} + body_path: release-notes.md generate_release_notes: ${{ steps.notes.outputs.found != 'true' }} fail_on_unmatched_files: true files: | - artifacts/**/*.dmg - artifacts/**/*-setup.exe - artifacts/**/*.app.tar.gz - artifacts/latest.json + release/*.dmg + release/*.exe + release/*.tar.gz + release/latest.json diff --git a/CLAUDE.md b/CLAUDE.md index e165887..10138b1 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1790,9 +1790,15 @@ that number and nothing else — everything derives from it: `jq .version frontend/package.json` and tags each push `v-b` (release name `Konduktor v-b`). The `-b` suffix keeps every push's tag/release unique. Each release also - carries the in-app updater's `latest.json` (`.github/scripts/updater_manifest.py`: - `version` = package.json's, `darwin-aarch64` → `Konduktor.app.tar.gz`, - `windows-x86_64` → the NSIS `-setup.exe`, each with its signature inlined). + carries its files under user-facing names, laid out by + `.github/scripts/release_assets.py`: `Konduktor--macOS.dmg`, + `Konduktor--Windows-Setup.exe` (also the Windows update package), + `Konduktor--app-updater.tar.gz` (the macOS update package) and the + in-app updater's `latest.json` (`version` = package.json's, each platform's + URL + signature inlined; the name is fixed — the app asks for it by name). + The notes open with a "Download" section linking the two installers, above + the PR's patch notes or GitHub's generated ones; the update dialog reads + only "What's Changed" and skips "Download" when falling back. `bundle.createUpdaterArtifacts` signs those with the updater key: the repo secrets `TAURI_SIGNING_PRIVATE_KEY` / `_PASSWORD`, public half in `tauri.conf.json` `plugins.updater.pubkey`. **Losing the private key means diff --git a/frontend/src/components/UpdateDialog.tsx b/frontend/src/components/UpdateDialog.tsx index d04b2bf..da3fce8 100644 --- a/frontend/src/components/UpdateDialog.tsx +++ b/frontend/src/components/UpdateDialog.tsx @@ -78,10 +78,17 @@ function whatsChanged(body: string | null): string[] { const lines = body.split(/\r?\n/) const start = lines.findIndex((l) => /^#{2,4}\s+what'?s changed/i.test(l.trim())) const out: string[] = [] + // Every release body opens with a "Download" section (build.yml): the + // fallback must not list the installer links as changes. + let inDownload = false for (const raw of lines.slice(start + 1)) { const line = raw.trim() if (start !== -1 && (/^#{1,4}\s/.test(line) || line.startsWith('**Full Changelog**'))) break - if (line) { + if (/^#{1,4}\s/.test(line)) { + inDownload = /^#{1,4}\s+download/i.test(line) + continue + } + if (line && !inDownload) { out.push( line.replace(/^[*-]\s+/, '').replace(/\s+by\s+@[\w-]+\s+in\s+https?:\/\/\S+$/i, ''), )