From 3b7089c8d121a5a352eb1f2218bd360e9884195e Mon Sep 17 00:00:00 2001 From: rob thijssen Date: Wed, 16 Sep 2026 09:10:40 +0300 Subject: [PATCH] ci: a release workflow on a version tag, and bundles named for packaging Pushing vX.Y.Z runs .gitea/workflows/release.yaml on rust-gtk3: it refuses a tag that disagrees with the workspace version (script/stamp-version.sh, which also stamps tauri.conf.json and ui/package.json from Cargo.toml), builds the webview and the deb, rpm and AppImage bundles through the npm Tauri CLI, checks the binary answers --version with the tag, and attaches the bundles, the bare binary and SHA256SUMS to a Gitea release for the tag using the repository's own Actions token. The product is now `blackbeard-wallet`, no space: that name is the binary, the rpm and deb package, and every release asset, so `dnf install blackbeard-wallet` reads right. The window title and the desktop entry keep "blackbeard wallet" through a desktop template. The binary answers --version and --help before touching the display. Bundled locally on Fedora 44: deb, rpm (name, license and URL right, desktop entry installed) and a 114 MB AppImage that prints "blackbeard-wallet 0.1.0". The AppImage step needs librsvg2-devel for linuxdeploy's GTK plugin, which the rust-gtk3 runner image does not carry yet; that is a one-line change in gongfoo, without which the workflow's bundle step fails on the AppImage. Refs #32 Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_014ftBXYuba8ARhQeF74oUgW --- .gitea/workflows/release.yaml | 106 ++++++++++++++++++++ crates/wallet-app/blackbeard-wallet.desktop | 15 +++ crates/wallet-app/src/main.rs | 27 +++++ crates/wallet-app/tauri.conf.json | 17 +++- script/stamp-version.sh | 31 ++++++ 5 files changed, 191 insertions(+), 5 deletions(-) create mode 100644 .gitea/workflows/release.yaml create mode 100644 crates/wallet-app/blackbeard-wallet.desktop create mode 100755 script/stamp-version.sh diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml new file mode 100644 index 0000000..7a2be36 --- /dev/null +++ b/.gitea/workflows/release.yaml @@ -0,0 +1,106 @@ +name: release + +# A release is a tag on the workspace version. Push `vX.Y.Z` where X.Y.Z is +# `version` in Cargo.toml (script/stamp-version.sh refuses anything else), +# and this builds the Linux bundles and attaches them to a Gitea release for +# that tag. Packaging for rpm.lair.cafe hangs off the release (#33); the +# Windows and macOS builders are their own child (#34). + +on: + push: + tags: ["v*"] + +concurrency: + group: release-${{ github.ref }} + cancel-in-progress: false + +jobs: + linux: + # `rust-gtk3`: tauri-build and the bundler need GTK and WebKitGTK dev + # libraries (gitea-runners.md ยง3). The Tauri CLI comes from npm as a + # prebuilt binary rather than `cargo install`, which would rebuild it + # on every ephemeral runner. + runs-on: rust-gtk3 + env: + # linuxdeploy ships as an AppImage; without FUSE in the container it + # must extract itself first. Stripping is left to the bundler's + # defaults per target, not linuxdeploy's. + APPIMAGE_EXTRACT_AND_RUN: "1" + NO_STRIP: "true" + steps: + - uses: actions/checkout@v4 + + - name: the tag is the workspace version + id: version + run: | + set -euo pipefail + script/stamp-version.sh "${GITHUB_REF_NAME}" + echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" + + - name: webview dependencies + working-directory: ui + run: pnpm install --frozen-lockfile + + - name: bundle + # `beforeBuildCommand` in tauri.conf.json builds the webview first. + run: | + set -euo pipefail + pnpm --dir ui dlx @tauri-apps/cli@^2 build \ + --config crates/wallet-app/tauri.conf.json \ + --bundles deb,rpm,appimage + ls -l target/release/bundle/*/ + + - name: the binary says the version + run: | + set -euo pipefail + got="$(target/release/wallet-app --version)" + echo "$got" + [ "$got" = "blackbeard-wallet ${{ steps.version.outputs.version }}" ] + + - name: collect + run: | + set -euo pipefail + mkdir -p dist + cp target/release/bundle/deb/*.deb dist/ + cp target/release/bundle/rpm/*.rpm dist/ + cp target/release/bundle/appimage/*.AppImage dist/ + # The bare binary too: the rpm.lair.cafe spec packages it (#33). + install -m 0755 target/release/wallet-app "dist/blackbeard-wallet-${{ steps.version.outputs.version }}-x86_64-linux-gnu" + (cd dist && sha256sum * > SHA256SUMS) + ls -l dist + + - name: release + # The repository's own Actions token can create a release and + # upload assets; no personal token is involved. + env: + TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail + api="${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases" + tag="${GITHUB_REF_NAME}" + body="blackbeard wallet ${tag}. Linux bundles built on Fedora 44 (deb, rpm, AppImage); SHA256SUMS lists every asset." + existing="$(curl -sf -H "Authorization: token ${TOKEN}" "${api}/tags/${tag}" | jq -r '.id' || true)" + if [ -n "${existing}" ] && [ "${existing}" != "null" ]; then + id="${existing}" + else + id="$(curl -sf -X POST "${api}" \ + -H "Authorization: token ${TOKEN}" -H "Content-Type: application/json" \ + -d "$(jq -n --arg t "${tag}" --arg b "${body}" '{tag_name: $t, name: $t, body: $b, draft: false, prerelease: false}')" \ + | jq -r '.id')" + fi + [ -n "${id}" ] && [ "${id}" != "null" ] || { echo "no release id"; exit 1; } + for f in dist/*; do + name="$(basename "$f")" + echo "uploading ${name}" + curl -sf -X POST "${api}/${id}/assets?name=${name}" \ + -H "Authorization: token ${TOKEN}" -H "Content-Type: application/octet-stream" \ + --data-binary "@${f}" > /dev/null + done + echo "release ${tag}: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${tag}" + + - name: keep the bundles for the packaging job + uses: actions/upload-artifact@v3 + with: + name: linux-bundles + path: dist/ + retention-days: 7 diff --git a/crates/wallet-app/blackbeard-wallet.desktop b/crates/wallet-app/blackbeard-wallet.desktop new file mode 100644 index 0000000..f15e29f --- /dev/null +++ b/crates/wallet-app/blackbeard-wallet.desktop @@ -0,0 +1,15 @@ +# The desktop entry Tauri's deb and rpm bundlers install. A template rather +# than the generated default so the app grid reads "blackbeard wallet", not +# the hyphenated product name that has to serve as the binary and package +# name. Handlebars: {{exec}} and {{icon}} are filled by the bundler. +[Desktop Entry] +Type=Application +Name=blackbeard wallet +GenericName=Wallet +Comment=A desktop wallet for post-quantum chains +Exec={{exec}} %U +Icon={{icon}} +Terminal=false +Categories=Finance;Network; +Keywords=wallet;quantus;post-quantum; +StartupWMClass=blackbeard-wallet diff --git a/crates/wallet-app/src/main.rs b/crates/wallet-app/src/main.rs index f34f0dc..5454b66 100644 --- a/crates/wallet-app/src/main.rs +++ b/crates/wallet-app/src/main.rs @@ -2,5 +2,32 @@ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] fn main() { + // A packaged binary must be able to say which version it is without + // opening a window: `--version` is what a bug report and the release + // gate ask for. + let mut args = std::env::args().skip(1); + if let Some(flag) = args.next() { + match flag.as_str() { + "--version" | "-V" => { + println!("blackbeard-wallet {}", env!("CARGO_PKG_VERSION")); + return; + } + "--help" | "-h" => { + println!( + "blackbeard-wallet {}\n\nA desktop wallet for post-quantum chains. Runs as a window; \ + the only flags are --version and --help.\n\nEnvironment:\n \ + WALLET_DATA_DIR where wallets, settings and the history cache live\n \ + WALLET_KEYSTORE_DIR wallets alone, e.g. ~/.quantus/wallets to share with the CLI\n \ + WALLET_WEBKIT_DMABUF on|off, forces the WebKitGTK renderer path on Linux", + env!("CARGO_PKG_VERSION") + ); + return; + } + other => { + eprintln!("blackbeard-wallet: unknown argument {other:?}; see --help"); + std::process::exit(2); + } + } + } wallet_app_lib::run() } diff --git a/crates/wallet-app/tauri.conf.json b/crates/wallet-app/tauri.conf.json index 58b0f1a..93743f1 100644 --- a/crates/wallet-app/tauri.conf.json +++ b/crates/wallet-app/tauri.conf.json @@ -1,6 +1,6 @@ { "$schema": "https://schema.tauri.app/config/2", - "productName": "blackbeard wallet", + "productName": "blackbeard-wallet", "version": "0.1.0", "identifier": "cafe.lair.blackbeard.wallet", "build": { @@ -63,14 +63,21 @@ "depends": [ "webkit2gtk4.1", "gtk3" - ] + ], + "desktopTemplate": "blackbeard-wallet.desktop" }, "deb": { "depends": [ "libwebkit2gtk-4.1-0", "libgtk-3-0" - ] + ], + "desktopTemplate": "blackbeard-wallet.desktop" } - } - } + }, + "longDescription": "A desktop wallet for post-quantum chains: Quantus first, with ML-DSA signatures, reversible transfers and history from blackbeard.observer.", + "homepage": "https://git.lair.cafe/blackbeard/wallet", + "license": "GPL-3.0-or-later", + "publisher": "blackbeard" + }, + "mainBinaryName": "blackbeard-wallet" } diff --git a/script/stamp-version.sh b/script/stamp-version.sh new file mode 100755 index 0000000..049606b --- /dev/null +++ b/script/stamp-version.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# Stamp the workspace version into the two files that cannot read it +# themselves: tauri.conf.json (Tauri's CLI wants a literal) and +# ui/package.json. Refuses a tag that disagrees with Cargo.toml, so the +# workspace stays the one source of truth and a release is a tag on it. +# +# script/stamp-version.sh # stamp from Cargo.toml +# script/stamp-version.sh v0.2.0 # also assert the tag matches +set -euo pipefail +here="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +version="$(sed -nE 's/^version = "([^"]+)"$/\1/p' "${here}/Cargo.toml" | head -1)" +[ -n "${version}" ] || { echo "no workspace version in Cargo.toml" >&2; exit 1; } +if [ "${1:-}" != "" ]; then + tag="${1#v}" + if [ "${tag}" != "${version}" ]; then + echo "tag v${tag} does not match the workspace version ${version}; bump Cargo.toml first" >&2 + exit 1 + fi +fi +python3 - "${version}" "${here}/crates/wallet-app/tauri.conf.json" "${here}/ui/package.json" <<'PY' +import json, sys +version, *files = sys.argv[1:] +for f in files: + with open(f) as fh: + d = json.load(fh) + d["version"] = version + with open(f, "w") as fh: + json.dump(d, fh, indent=2) + fh.write("\n") + print(f"{f}: {version}") +PY