The installer job was waiting on a commented matrix row, USB stayed on Image Capture, face detection could not read the Windows CPU, and notarisation had nowhere to put an Apple account.
162 lines
8.0 KiB
YAML
162 lines
8.0 KiB
YAML
name: desktop-release
|
|
# Tag `desktop-vX.Y.Z` builds the desktop installers and attaches them to a Gitea release.
|
|
# Linux builds on the standard runner. macOS (.dmg) builds on a Mac registered as a runner with the label "macos"
|
|
# (infra/desktop/macos-runner.sh, once); a release made while that Mac is off waits for it. Windows (.msi) builds
|
|
# on a runner labelled "windows" (Git bash, plus the WebView2 step). No Windows runner is registered yet, so a
|
|
# tag waits on that job until one is online. Notarisation runs only when the Apple secrets below are set.
|
|
#
|
|
# Self-updates (apps/desktop/src-tauri/src/updater.rs): with the secret TAURI_SIGNING_PRIVATE_KEY (and
|
|
# TAURI_SIGNING_PRIVATE_KEY_PASSWORD) and the variable TAURI_UPDATER_PUBKEY set (`tauri signer generate`), each job
|
|
# also signs its installer and attaches update-<platform>.json; the API serves those to installed apps
|
|
# (DESKTOP_RELEASES_API / DESKTOP_RELEASES_TOKEN on the API). Without them, installers are built as before.
|
|
on:
|
|
push:
|
|
tags: ["desktop-v*"]
|
|
|
|
jobs:
|
|
build:
|
|
defaults:
|
|
run:
|
|
# Windows runners default to PowerShell. Git bash is what the rest of this job is written for.
|
|
shell: bash
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- runner: ubuntu-latest
|
|
bundles: deb,appimage
|
|
platform: linux-x86_64
|
|
- runner: macos
|
|
bundles: dmg,app
|
|
platform: darwin-universal
|
|
args: --target universal-apple-darwin
|
|
- runner: windows
|
|
bundles: msi
|
|
platform: windows-x86_64
|
|
args: ""
|
|
runs-on: ${{ matrix.runner }}
|
|
env:
|
|
VITE_API_URL: https://api.next.photoreport.pt
|
|
PHOTOREPORT_API_URL: https://api.next.photoreport.pt
|
|
PHOTOREPORT_UPDATER_PUBKEY: ${{ vars.TAURI_UPDATER_PUBKEY }}
|
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
|
# Empty until a Developer ID and an app-specific password (or an App Store Connect API key) are stored.
|
|
# Tauri notarises only when a full set is present; the install step drops blank values so a missing
|
|
# secret does not turn into a failed notarisation.
|
|
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
|
|
APPLE_ID: ${{ secrets.APPLE_ID }}
|
|
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
|
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
|
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
|
|
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
|
|
APPLE_API_KEY_PATH: ${{ secrets.APPLE_API_KEY_PATH }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: System libraries (Linux)
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev libsecret-1-dev libgphoto2-dev pkg-config
|
|
- uses: pnpm/action-setup@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 24.22.1
|
|
- name: Rust
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
if [[ -x "$HOME/.cargo/bin/rustup" ]]; then
|
|
export PATH="$HOME/.cargo/bin:$PATH"
|
|
fi
|
|
if ! command -v rustup >/dev/null 2>&1; then
|
|
curl --proto '=https' --tlsv1.2 --retry 5 --retry-all-errors --retry-delay 5 -fsSL https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
|
|
export PATH="$HOME/.cargo/bin:$PATH"
|
|
fi
|
|
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
|
ok=0
|
|
for i in 1 2 3 4 5; do
|
|
if rustup toolchain install stable --profile minimal && rustup default stable; then
|
|
ok=1
|
|
break
|
|
fi
|
|
echo "rustup download failed ($i/5), retrying"
|
|
sleep 15
|
|
done
|
|
test "$ok" = 1
|
|
- name: WebView2 runtime (Windows)
|
|
if: runner.os == 'Windows'
|
|
shell: powershell
|
|
run: powershell -NoProfile -ExecutionPolicy Bypass -File infra/desktop/windows-webview2.ps1
|
|
- name: Both Mac processors (universal app)
|
|
if: runner.os == 'macOS'
|
|
run: rustup target add aarch64-apple-darwin x86_64-apple-darwin
|
|
- name: Photo engine (WebAssembly)
|
|
run: |
|
|
rustup target add wasm32-unknown-unknown
|
|
cargo install wasm-bindgen-cli --version "$(sed -n 's/^wasm-bindgen = "=\(.*\)"/\1/p' engine/wasm/Cargo.toml)" --locked
|
|
bash infra/engine/build-wasm.sh
|
|
- run: pnpm install
|
|
- run: pnpm --filter "./packages/*" build
|
|
- run: pnpm --filter @photoreport/desktop icons
|
|
- name: Installers
|
|
shell: bash
|
|
run: |
|
|
# Blank Apple secrets must not look "set", or Tauri tries to notarise with an empty account.
|
|
for name in APPLE_SIGNING_IDENTITY APPLE_ID APPLE_PASSWORD APPLE_TEAM_ID APPLE_API_ISSUER APPLE_API_KEY APPLE_API_KEY_PATH; do
|
|
if [[ -z "${!name:-}" ]]; then
|
|
unset "$name"
|
|
fi
|
|
done
|
|
extra=()
|
|
# Updater artifacts when the release key is there. A Developer ID also turns on the hardened
|
|
# runtime with the entitlements the bundled ONNX library needs, which is what notarisation requires.
|
|
config="$(node -e '
|
|
const bundle = {};
|
|
const plugins = {};
|
|
if (process.env.TAURI_SIGNING_PRIVATE_KEY) {
|
|
bundle.createUpdaterArtifacts = true;
|
|
plugins.updater = { pubkey: process.env.PHOTOREPORT_UPDATER_PUBKEY };
|
|
}
|
|
if (process.platform === "darwin" && process.env.APPLE_SIGNING_IDENTITY) {
|
|
bundle.macOS = { hardenedRuntime: true, entitlements: "entitlements.plist" };
|
|
}
|
|
const cfg = {};
|
|
if (Object.keys(bundle).length) cfg.bundle = bundle;
|
|
if (Object.keys(plugins).length) cfg.plugins = plugins;
|
|
if (Object.keys(cfg).length) process.stdout.write(JSON.stringify(cfg));
|
|
')"
|
|
if [[ -n "$config" ]]; then
|
|
extra=(--config "$config")
|
|
fi
|
|
pnpm --filter @photoreport/desktop exec tauri build --bundles ${{ matrix.bundles }} ${{ matrix.args }} "${extra[@]}"
|
|
- name: Update manifest
|
|
if: env.TAURI_SIGNING_PRIVATE_KEY != ''
|
|
shell: bash
|
|
run: |
|
|
# The bundle folder: target/<triple>/release/bundle (cross builds) or target/release/bundle. (A plain `ls` of
|
|
# both exits 2 for the one that doesn't exist, which ended the step under pipefail.)
|
|
dir=""
|
|
for d in apps/desktop/src-tauri/target/*/release/bundle apps/desktop/src-tauri/target/release/bundle; do
|
|
if [[ -d "$d" ]]; then dir="$d"; break; fi
|
|
done
|
|
node infra/desktop/update-manifest.mjs "$dir" ${{ matrix.platform }} "${GITHUB_REF_NAME}"
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: desktop-${{ matrix.runner }}
|
|
path: apps/desktop/src-tauri/target/**/bundle/**
|
|
- name: Attach to the release
|
|
shell: bash
|
|
env:
|
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
api="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
|
tag="${GITHUB_REF_NAME}"
|
|
id=$(curl -fsS -H "Authorization: token $TOKEN" "$api/releases/tags/$tag" | node -pe 'JSON.parse(require("fs").readFileSync(0)).id' 2>/dev/null || true)
|
|
if [[ -z "$id" || "$id" == "undefined" ]]; then
|
|
id=$(curl -fsS -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
|
-d "{\"tag_name\":\"$tag\",\"name\":\"PhotoReport $tag\"}" "$api/releases" | node -pe 'JSON.parse(require("fs").readFileSync(0)).id')
|
|
fi
|
|
find apps/desktop/src-tauri/target -path '*/bundle/*' -type f \( -name '*.dmg' -o -name '*.app.tar.gz' -o -name '*.msi' -o -name '*-setup.exe' -o -name '*.deb' -o -name '*.AppImage' -o -name '*.sig' -o -name 'update-*.json' \) |
|
|
while read -r f; do curl -fsS -H "Authorization: token $TOKEN" -F "attachment=@$f" "$api/releases/$id/assets?name=$(basename "$f")" >/dev/null; echo "attached $(basename "$f")"; done
|