mirror of
https://github.com/JoshiCodes/knock.git
synced 2026-12-04 15:19:41 +01:00
Signed auto-updates for macOS and Windows
- Tauri updater with the release signing key; macOS and Windows offer Install and restart in the update notice, with download progress - The release workflow signs the macOS app archive and the Windows installer when the key secret is present and publishes latest.json - Linux keeps the notice; updates there come from the package manager
This commit is contained in:
@@ -19,6 +19,9 @@ jobs:
|
||||
macos:
|
||||
if: github.event_name == 'push' || inputs.platforms == 'all' || contains(inputs.platforms, 'macos')
|
||||
runs-on: macos-latest
|
||||
env:
|
||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
@@ -31,8 +34,19 @@ jobs:
|
||||
- run: npm ci
|
||||
- name: Test
|
||||
run: cargo test -p knock-core --locked
|
||||
- name: App (universal .app and .dmg)
|
||||
run: npx tauri build --target universal-apple-darwin --bundles app,dmg
|
||||
- name: App (universal .app and .dmg, plus a signed update package)
|
||||
run: |
|
||||
# Update packages only when the signing key is available.
|
||||
extra=""
|
||||
if [ -n "$TAURI_SIGNING_PRIVATE_KEY" ]; then extra='--config {"bundle":{"createUpdaterArtifacts":true}}'; fi
|
||||
npx tauri build --target universal-apple-darwin --bundles app,dmg $extra
|
||||
v=$(node -p "require('./src-tauri/tauri.conf.json').version")
|
||||
mkdir -p dist-update
|
||||
b=target/universal-apple-darwin/release/bundle/macos
|
||||
if [ -f "$b/knock.app.tar.gz" ]; then
|
||||
cp "$b/knock.app.tar.gz" "dist-update/knock_${v}_universal.app.tar.gz"
|
||||
cp "$b/knock.app.tar.gz.sig" "dist-update/knock_${v}_universal.app.tar.gz.sig"
|
||||
fi
|
||||
- name: CLI (universal binary)
|
||||
run: |
|
||||
cargo build --release --locked -p knock-cli --target aarch64-apple-darwin
|
||||
@@ -53,12 +67,16 @@ jobs:
|
||||
path: |
|
||||
target/universal-apple-darwin/release/bundle/dmg/*.dmg
|
||||
knock-cli-macos-universal.tar.gz
|
||||
dist-update/*
|
||||
|
||||
# Best effort per the spec.
|
||||
windows:
|
||||
if: github.event_name == 'push' || inputs.platforms == 'all' || contains(inputs.platforms, 'windows')
|
||||
runs-on: windows-latest
|
||||
continue-on-error: true
|
||||
env:
|
||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-node@v5
|
||||
@@ -67,8 +85,14 @@ jobs:
|
||||
cache: npm
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: npm ci
|
||||
- name: App (.msi and setup .exe)
|
||||
run: npx tauri build --bundles msi,nsis
|
||||
- name: App (.msi and setup .exe, signed for updates)
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -n "$TAURI_SIGNING_PRIVATE_KEY" ]; then
|
||||
npx tauri build --bundles msi,nsis --config '{"bundle":{"createUpdaterArtifacts":true}}'
|
||||
else
|
||||
npx tauri build --bundles msi,nsis
|
||||
fi
|
||||
- name: CLI
|
||||
shell: pwsh
|
||||
run: |
|
||||
@@ -80,6 +104,7 @@ jobs:
|
||||
path: |
|
||||
target/release/bundle/msi/*.msi
|
||||
target/release/bundle/nsis/*.exe
|
||||
target/release/bundle/nsis/*.exe.sig
|
||||
knock-cli-windows-x64.zip
|
||||
|
||||
# Native amd64 Linux build on Ubuntu 22.04, with the AppImage the arm64
|
||||
@@ -170,6 +195,32 @@ jobs:
|
||||
with:
|
||||
path: artifacts
|
||||
merge-multiple: true
|
||||
- name: Update manifest for macOS and Windows
|
||||
env:
|
||||
TAG: ${{ github.ref_name }}
|
||||
REPO: ${{ github.repository }}
|
||||
run: |
|
||||
cd artifacts
|
||||
v="${TAG#v}"
|
||||
base="https://github.com/$REPO/releases/download/$TAG"
|
||||
mac=$(ls *_universal.app.tar.gz 2>/dev/null | head -1 || true)
|
||||
win=$(ls *-setup.exe 2>/dev/null | head -1 || true)
|
||||
if [ -z "$mac$win" ]; then echo "no signed update packages, skipping latest.json"; exit 0; fi
|
||||
python3 - "$v" "$base" "$mac" "$win" <<'PY'
|
||||
import json, sys, datetime, os
|
||||
v, base, mac, win = sys.argv[1:5]
|
||||
platforms = {}
|
||||
def sig(f):
|
||||
return open(f + ".sig").read().strip() if f and os.path.exists(f + ".sig") else None
|
||||
if mac and sig(mac):
|
||||
for p in ("darwin-aarch64", "darwin-x86_64"):
|
||||
platforms[p] = {"signature": sig(mac), "url": f"{base}/{mac}"}
|
||||
if win and sig(win):
|
||||
platforms["windows-x86_64"] = {"signature": sig(win), "url": f"{base}/{win}"}
|
||||
json.dump({"version": v, "notes": f"knock {v}", "pub_date": datetime.datetime.now(datetime.timezone.utc).isoformat(), "platforms": platforms}, open("latest.json", "w"), indent=2)
|
||||
print(open("latest.json").read())
|
||||
PY
|
||||
|
||||
- name: Checksums
|
||||
run: |
|
||||
cd artifacts
|
||||
|
||||
Reference in New Issue
Block a user