Implemented self-updating

This commit is contained in:
patben8 committed 2026-10-16 17:38:35 +02:00
1 parent 422297d890
commit 0eac972173
12 files changed
+1016 -80

No files matched your search

+69
View File
@@ -0,0 +1,69 @@
"""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()
+28 -2
View File
@@ -86,20 +86,31 @@ jobs:
working-directory: frontend
run: npm ci
# createUpdaterArtifacts also signs the in-app update packages
# (Konduktor.app.tar.gz / the NSIS setup.exe) with the updater key, whose
# public half is plugins.updater.pubkey in tauri.conf.json. Losing the
# private key means installed copies can never update themselves again.
- name: Build Tauri app
working-directory: frontend
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
run: npx tauri build
# Stage the single installer per OS into a flat folder. Uploading one
# directory (not multiple bundle subpaths) keeps the artifact root at
# ./installer, so the zip holds the bare file — no nested dmg/ or nsis/
# folder. We ship the DMG on macOS and the NSIS -setup.exe on Windows
# (the .msi is intentionally left out).
# (the .msi is intentionally left out), plus what the in-app updater
# installs: the .app.tar.gz on macOS (the setup.exe on Windows) and the
# .sig files the release job folds into latest.json.
- name: Stage installer (macOS)
if: runner.os == 'macOS'
run: |
mkdir -p installer
cp frontend/src-tauri/target/release/bundle/dmg/*.dmg installer/
cp frontend/src-tauri/target/release/bundle/macos/*.app.tar.gz installer/
cp frontend/src-tauri/target/release/bundle/macos/*.app.tar.gz.sig installer/
- name: Stage installer (Windows)
if: runner.os == 'Windows'
@@ -107,6 +118,7 @@ jobs:
run: |
New-Item -ItemType Directory -Force installer | Out-Null
Copy-Item frontend/src-tauri/target/release/bundle/nsis/*-setup.exe installer/
Copy-Item frontend/src-tauri/target/release/bundle/nsis/*-setup.exe.sig installer/
- name: Upload installer
uses: actions/upload-artifact@v4
@@ -226,6 +238,16 @@ jobs:
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/<tag>/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:
@@ -235,4 +257,8 @@ jobs:
body_path: ${{ steps.notes.outputs.found == 'true' && 'release-notes.md' || '' }}
generate_release_notes: ${{ steps.notes.outputs.found != 'true' }}
fail_on_unmatched_files: true
files: artifacts/**/*
files: |
artifacts/**/*.dmg
artifacts/**/*-setup.exe
artifacts/**/*.app.tar.gz
artifacts/latest.json