Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17784c8b22 | ||
|
|
24ec8095f6 |
No files matched your search
@@ -1,7 +1,8 @@
|
||||
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) and Windows (.msi) need runners with those labels:
|
||||
# register one on a Mac and one on a Windows machine, then uncomment the matrix entries.
|
||||
# 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) needs a
|
||||
# runner labelled "windows": register one, then uncomment its entry.
|
||||
#
|
||||
# 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
|
||||
@@ -20,10 +21,10 @@ jobs:
|
||||
- runner: ubuntu-latest
|
||||
bundles: deb,appimage
|
||||
platform: linux-x86_64
|
||||
# - runner: macos
|
||||
# bundles: dmg,app
|
||||
# platform: darwin-universal
|
||||
# args: --target universal-apple-darwin
|
||||
- runner: macos
|
||||
bundles: dmg,app
|
||||
platform: darwin-universal
|
||||
args: --target universal-apple-darwin
|
||||
# - runner: windows
|
||||
# bundles: msi
|
||||
# platform: windows-x86_64
|
||||
@@ -46,6 +47,9 @@ jobs:
|
||||
with:
|
||||
node-version: 22
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@photoreport/desktop",
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.5",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "photoreport-desktop"
|
||||
version = "0.3.3"
|
||||
version = "0.3.5"
|
||||
edition = "2024"
|
||||
publish = false
|
||||
description = "PhotoReport desktop: the web app in a native shell, with keychain sign-in and (later) local FTP and the native engine."
|
||||
|
||||
@@ -9,6 +9,7 @@ fn main() {
|
||||
"ftp_start",
|
||||
"ftp_stop",
|
||||
"ftp_status",
|
||||
"ftp_check",
|
||||
"ftp_take",
|
||||
"ftp_retry",
|
||||
"ftp_read",
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"allow-ftp-start",
|
||||
"allow-ftp-stop",
|
||||
"allow-ftp-status",
|
||||
"allow-ftp-check",
|
||||
"allow-ftp-take",
|
||||
"allow-ftp-retry",
|
||||
"allow-ftp-read",
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# Automatically generated - DO NOT EDIT!
|
||||
|
||||
[[permission]]
|
||||
identifier = "allow-ftp-check"
|
||||
description = "Enables the ftp_check command without any pre-configured scope."
|
||||
commands.allow = ["ftp_check"]
|
||||
|
||||
[[permission]]
|
||||
identifier = "deny-ftp-check"
|
||||
description = "Denies the ftp_check command without any pre-configured scope."
|
||||
commands.deny = ["ftp_check"]
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "PhotoReport",
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.5",
|
||||
"identifier": "pt.photoreport.desktop",
|
||||
"build": {
|
||||
"devUrl": "http://localhost:5173",
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
//! The web app is loaded from the server (a remote origin), so every command it calls must be listed in build.rs
|
||||
//! (to get an ACL permission) and allowed in capabilities/default.json. A command registered in lib.rs but missing
|
||||
//! from either is refused at runtime and looks like "this desktop app is too old" in the web app.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
fn read(rel: &str) -> String {
|
||||
std::fs::read_to_string(Path::new(env!("CARGO_MANIFEST_DIR")).join(rel)).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_registered_command_is_allowed_for_the_web_app() {
|
||||
let lib = read("src/lib.rs");
|
||||
let start =
|
||||
lib.find("generate_handler![").expect("generate_handler") + "generate_handler![".len();
|
||||
let end = start + lib[start..].find(']').unwrap();
|
||||
let commands: Vec<String> = lib[start..end]
|
||||
.split(',')
|
||||
.map(|c| c.trim().rsplit("::").next().unwrap_or("").to_string())
|
||||
.filter(|c| !c.is_empty())
|
||||
.collect();
|
||||
assert!(commands.len() > 10, "{commands:?}");
|
||||
|
||||
let build = read("build.rs");
|
||||
let capabilities = read("capabilities/default.json");
|
||||
for c in &commands {
|
||||
assert!(
|
||||
build.contains(&format!("\"{c}\"")),
|
||||
"{c} is not listed in build.rs"
|
||||
);
|
||||
let permission = format!("\"allow-{}\"", c.replace('_', "-"));
|
||||
assert!(
|
||||
capabilities.contains(&permission),
|
||||
"{permission} is missing from capabilities/default.json"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -98,6 +98,11 @@ Gitea -> webhook -> the container pulls and redeploys itself. No manual `scp`/`r
|
||||
Not deployed by webhook. A tag `desktop-v*` / `agent-v*` triggers Gitea Actions to build installers per OS and
|
||||
publish a Gitea release; the Tauri updater and the agent's updater read from it.
|
||||
|
||||
macOS builds on a Mac registered once as a runner (`bash infra/desktop/macos-runner.sh`, with a registration token
|
||||
from Gitea → Actions → Runners; label `macos`, a launchd service of that user). Its builds carry the updater key, so
|
||||
apps installed from a release update themselves; an app compiled by hand without the key never does. A release made
|
||||
while the Mac is off waits for it.
|
||||
|
||||
## Importing the old app.photoreport.pt
|
||||
|
||||
`apps/api/scripts/import-legacy.ts` reads the old MySQL database, read-only. It brings over accounts, squads, events,
|
||||
|
||||
Executable
+86
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env bash
|
||||
# Turns a Mac into the macOS builder for desktop releases (run once, on the Mac that will build).
|
||||
# bash ~/Projects/photoreport-build/infra/desktop/macos-runner.sh
|
||||
#
|
||||
# It installs Gitea's act_runner as a background service of this user (starts at login, restarts if it stops) with
|
||||
# the label "macos". From then on every `desktop-v*` release also builds the signed .dmg and the macOS update, and the
|
||||
# installed apps update themselves: nobody compiles by hand again. The Mac only has to be on (and logged in) when a
|
||||
# release is made; a release made while it is off waits and builds when it comes back.
|
||||
#
|
||||
# The registration token comes from Gitea (BitReport.pt/photoreport → Definições → Actions → Runners → Criar
|
||||
# runner). The script asks for it; it is used once and not saved.
|
||||
set -Eeuo pipefail
|
||||
|
||||
VERSION="${ACT_RUNNER_VERSION:-0.2.11}"
|
||||
INSTANCE="${GITEA_URL:-https://git.bitreport.pt}"
|
||||
HOME_DIR="$HOME/.photoreport-runner"
|
||||
PLIST="$HOME/Library/LaunchAgents/pt.photoreport.act-runner.plist"
|
||||
|
||||
step() { printf '\n\033[1;34m== %s\033[0m\n' "$*"; }
|
||||
|
||||
[[ "$(uname)" == Darwin ]] || { echo "Run this on a Mac." >&2; exit 1; }
|
||||
xcode-select -p >/dev/null 2>&1 || { xcode-select --install; echo "Install the Xcode command line tools, then run this again." >&2; exit 1; }
|
||||
command -v node >/dev/null || { echo "Node.js 22 is needed: brew install node@22" >&2; exit 1; }
|
||||
|
||||
step "Rust"
|
||||
if ! command -v cargo >/dev/null; then curl -fsSL https://sh.rustup.rs | sh -s -- -y; fi
|
||||
# shellcheck disable=SC1091
|
||||
source "$HOME/.cargo/env"
|
||||
rustup target add aarch64-apple-darwin x86_64-apple-darwin wasm32-unknown-unknown >/dev/null
|
||||
|
||||
step "pnpm"
|
||||
command -v pnpm >/dev/null || corepack enable pnpm 2>/dev/null || npm install -g pnpm
|
||||
|
||||
step "act_runner $VERSION"
|
||||
mkdir -p "$HOME_DIR"
|
||||
cd "$HOME_DIR"
|
||||
arch="$(uname -m)"; [[ "$arch" == "arm64" ]] || arch="amd64"
|
||||
if [[ ! -x ./act_runner ]] || ! ./act_runner --version 2>/dev/null | grep -q "$VERSION"; then
|
||||
curl -fsSL -o act_runner "https://dl.gitea.com/act_runner/${VERSION}/act_runner-${VERSION}-darwin-${arch}"
|
||||
chmod +x act_runner
|
||||
fi
|
||||
|
||||
if [[ ! -f .runner ]]; then
|
||||
step "Register with $INSTANCE"
|
||||
token="${GITEA_RUNNER_TOKEN:-}"
|
||||
if [[ -z "$token" ]]; then read -rsp "Registration token (Gitea → Actions → Runners → Criar runner): " token; echo; fi
|
||||
[[ -n "$token" ]] || { echo "No token." >&2; exit 1; }
|
||||
./act_runner generate-config > config.yaml
|
||||
# One build at a time; jobs run on this Mac directly (no containers on macOS).
|
||||
sed -i '' 's/^ capacity: .*/ capacity: 1/' config.yaml
|
||||
./act_runner register --no-interactive --config config.yaml --instance "$INSTANCE" --token "$token" \
|
||||
--name "$(scutil --get ComputerName | tr ' ' '-')-macos" --labels "macos:host"
|
||||
fi
|
||||
|
||||
step "Background service"
|
||||
mkdir -p "$(dirname "$PLIST")"
|
||||
cat > "$PLIST" <<PLIST
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key><string>pt.photoreport.act-runner</string>
|
||||
<key>ProgramArguments</key><array><string>$HOME_DIR/act_runner</string><string>daemon</string><string>--config</string><string>$HOME_DIR/config.yaml</string></array>
|
||||
<key>WorkingDirectory</key><string>$HOME_DIR</string>
|
||||
<key>EnvironmentVariables</key><dict>
|
||||
<key>PATH</key><string>$HOME/.cargo/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
|
||||
<key>HOME</key><string>$HOME</string>
|
||||
</dict>
|
||||
<key>RunAtLoad</key><true/>
|
||||
<key>KeepAlive</key><true/>
|
||||
<key>StandardOutPath</key><string>$HOME_DIR/runner.log</string>
|
||||
<key>StandardErrorPath</key><string>$HOME_DIR/runner.log</string>
|
||||
</dict>
|
||||
</plist>
|
||||
PLIST
|
||||
launchctl bootout "gui/$(id -u)" "$PLIST" 2>/dev/null || true
|
||||
launchctl bootstrap "gui/$(id -u)" "$PLIST"
|
||||
|
||||
sleep 3
|
||||
if launchctl print "gui/$(id -u)/pt.photoreport.act-runner" >/dev/null 2>&1; then
|
||||
printf '\n\033[1;32mDone.\033[0m This Mac now builds the macOS version of every desktop release.\n'
|
||||
printf 'Log: %s/runner.log Stop: launchctl bootout gui/%s %s\n' "$HOME_DIR" "$(id -u)" "$PLIST"
|
||||
else
|
||||
echo "The service did not start; see $HOME_DIR/runner.log" >&2
|
||||
exit 1
|
||||
fi
|
||||
Reference in new issue
Block a user