build(packaging): add the Forgejo workflow that tests and releases

.forgejo/workflows/flatpak.yaml, after imsd-messages' workflow, of whose
packaging scripts make-aarch64-sysroot.sh and build-aarch64.sh are the
counterparts. `check` runs the version check, the tests, the lint and
the aarch64 build of both Flatpaks for a pull request or a run by hand.
`publish` does the same but the lint for a pushed tag X.Y.Z, then
commits the service and the app into the Catcrafts Flatpak repository,
signed with the key on the runner's host, and makes the release on the
forge. A push without a tag runs nothing, so this push does not.

packaging/flatpak/release-version.sh is that app's script for Nostro:
NOSTRO_VERSION in project.cpp against the newest <release> of the app's
metainfo, and for a tag that it is that version, annotated, signed by
the owner as Forgejo verifies it, on master and newer than every
release.

Both files are after ones of imsd-messages, which are Catcrafts' own
and GPL-3.0-only, and are LGPL-3.0-only here, as nostro's packaging is
(design rule 13): a move between licences.

Not run: no runner has had the workflow. It parses as YAML and each of
its steps as shell. release-version.sh was run on this tree without a
tag, where it prints 0.1.0 and renders the notes, and with a tag that
is no version, which it refuses; what it checks of a real tag needs the
forge.

What a first run needs, and did not have on 2026-11-19, is in
AGENTS.template.md under "Releasing": a runner labelled `flatpak` for
this repository, the cache volume allowed in that runner's config, and
Crafter.Graphics' text-input change on the forge as the branch
claude/nostro-app. That change was uncommitted work in one local
checkout that day, so the app could be built nowhere else: the notes
on --graphics= now say so.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-11-19 16:14:33 +01:00
commit 1292a6eef1
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
3 changed files with 438 additions and 5 deletions

View file

@ -0,0 +1,295 @@
# SPDX-License-Identifier: LGPL-3.0-only
# SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
name: Flatpak
# Nostro's two Flatpaks for aarch64, a phone's architecture: the service with the nostro command
# (net.catcrafts.Nostrod) and the app (net.catcrafts.Nostro). They are built after the tests for a pull request, when
# started by hand, and for a pushed tag X.Y.Z. Only the tag's run publishes: both as the `stable` branch of the
# Catcrafts Flatpak repository (flatpak.catcrafts.net), each with its ref file beside it, and release X.Y.Z on the forge.
#
# A release is a tag: the owner signs it locally and pushes it with the master it releases, and a push without one runs
# nothing. The tag names the version, which NOSTRO_VERSION in project.cpp and the app's metainfo's newest <release>
# have to carry; that entry's description is the release notes (packaging/flatpak/release-version.sh).
#
# Two jobs, by trust, as imsd-messages' workflow has them, which this one follows step for step. `check` builds what is
# no release (a pull request, a run by hand) cold: no host volume, neither the published repository nor its key.
# `publish` builds a pushed tag with the four volumes it mounts: the crafter-build installation every consumer
# repository's publish job on the runner shares (crafter-flatpak-org-system: crafter-build //stable and its runtime),
# Nostro's own build cache (crafter-flatpak-nostro-cache: the aarch64 Sdk, the sysroot and the build directories, kept
# between runs), /var/www/flatpak (the published repository) and /etc/crafter-flatpak (its signing key, which never
# enters the forge): the repository and the key Crafter.Build's workflow publishes with. The shared installation is for
# publish jobs only: a pull request's job runs as root in a privileged container and must never reach it.
#
# What the runner has to have before the first run, none of which this file can bring about:
# - Both jobs run on the privileged runner labelled `flatpak` (bubblewrap needs the privilege). That is the Catcrafts
# organisation's, which serves the organisation's repositories: a repository outside it needs that runner, or one
# like it, registered for itself.
# - The runner's config has to allow the four volumes of `publish`, of which crafter-flatpak-nostro-cache is new.
# - The app is built against a Crafter.Graphics checkout for as long as project.cpp takes one (--graphics=): the
# branch $GRAPHICS_REF has to be on the forge. Once project.cpp names Crafter.Graphics at a commit itself, the
# step that fetches it goes, and $NOSTRO_GRAPHICS with it.
#
# Crafter.Build's, Crafter.Review's and imsd-messages' workflows publish into the same repository: each holds
# /var/www/flatpak/.publish.lock while it commits and updates the summary, and so does this one.
#
# Written on 2026-11-19 and not run before it was pushed: the first run is its test.
on:
pull_request:
branches: [master]
push:
# Bare semver tags, spelled with globs so it means the same whether the forge reads it as a workflow pattern or as
# a plain glob.
tags: ['[0-9]*.[0-9]*.[0-9]*']
workflow_dispatch:
# Pushes are tags only, so every release run is in one group and queues behind the one before it. A pull request's
# group also holds its number, which only a pull request's event carries, so a new push to it cancels its own outdated
# run and no other.
concurrency:
group: flatpak-${{ github.event_name }}-${{ github.event.pull_request.number }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
APP_ID: net.catcrafts.Nostro
SERVICE_ID: net.catcrafts.Nostrod
ARCH: aarch64
BRANCH: stable
CRAFTER_REF: net.catcrafts.CrafterBuild//stable
REPO_DIR: /srv/flatpak/repo
# A release tag carries a signature Forgejo verifies for this address.
RELEASE_SIGNER: jorijnvdgraaf@catcrafts.net
# The Crafter.Graphics the app is built against: see the head of this file.
GRAPHICS_URL: https://forgejo.catcrafts.net/Catcrafts/Crafter.Graphics.git
GRAPHICS_REF: claude/nostro-app
GRAPHICS_DIR: /home/build/Crafter.Graphics
jobs:
check:
if: github.event_name != 'push'
runs-on: flatpak
timeout-minutes: 210
container:
image: archlinux:latest
steps:
- name: Install tools
# A mirror answering 502 can fail a pacman transaction even with another mirror behind it; a retry starts over.
run: |
retry() { for i in 1 2 3 4 5; do "$@" && return 0; echo "attempt $i of 5 failed: $*" >&2; [ "$i" = 5 ] || sleep 30; done; return 1; }
pacman-key --init
pacman-key --populate archlinux
retry pacman -Sy --noconfirm --needed archlinux-keyring
retry pacman -Syu --noconfirm --needed flatpak ostree appstream binutils curl xz gnupg git nodejs util-linux python jq
git config --global --add safe.directory '*'
- name: crafter-build
# The Crafter.Build Flatpak's stable branch, which moves only with its releases; its Sdk comes from Flathub.
# Flathub's CDN answers 502 now and then, which flatpak reports as a missing runtime: each of these gets five
# tries.
run: |
retry() { for i in 1 2 3 4 5; do "$@" && return 0; echo "attempt $i of 5 failed: $*" >&2; [ "$i" = 5 ] || sleep 30; done; return 1; }
retry flatpak remote-add --if-not-exists catcrafts https://flatpak.catcrafts.net/catcrafts.flatpakrepo
retry flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
retry flatpak install -y --noninteractive catcrafts "$CRAFTER_REF"
retry flatpak update -y --noninteractive
flatpak info "$CRAFTER_REF" | sed -n 's/^ *\(Version\|Commit\|Date\): */crafter-build \1: /p'
- name: Checkout
# No step pushes, so the token is not kept in the checkout.
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Build user
# crafter-build and the scripts run as a user; root installs.
run: |
id build >/dev/null 2>&1 || useradd -m build
chown -R build: "$GITHUB_WORKSPACE" /home/build
- name: Version
run: runuser -u build -- packaging/flatpak/release-version.sh
- name: Tests
# Against the fake bunq and the fake system bus the tests bring: no bank and no system bus is reached.
run: runuser -u build -- flatpak run "$CRAFTER_REF" test --banks=bunq
- name: Lint
# The library, the command and the tests, which the step before built. The headers are named through the
# environment until Crafter.Build's issue #46 is fixed (AGENTS.template.md, Code style).
run: runuser -u build -- flatpak run --env=CPLUS_INCLUDE_PATH=/app/include/c++/v1 "$CRAFTER_REF" lint --banks=bunq
- name: Crafter.Graphics
run: |
set -eu
rm -rf "$GRAPHICS_DIR"
if ! runuser -u build -- git clone --quiet --depth 1 --branch "$GRAPHICS_REF" "$GRAPHICS_URL" "$GRAPHICS_DIR"; then
echo "no $GRAPHICS_REF at $GRAPHICS_URL: the app is built against it, see the head of .forgejo/workflows/flatpak.yaml" >&2
exit 1
fi
echo "Crafter.Graphics $(git -C "$GRAPHICS_DIR" rev-parse HEAD)"
- name: Sysroot
run: runuser -u build -- packaging/flatpak/make-aarch64-sysroot.sh
- name: Build
run: runuser -u build -- env NOSTRO_GRAPHICS="$GRAPHICS_DIR/project.cpp" packaging/flatpak/build-aarch64.sh repo "$BRANCH"
publish:
if: github.event_name == 'push'
runs-on: flatpak
timeout-minutes: 210
container:
image: archlinux:latest
options: >-
-v crafter-flatpak-org-system:/var/lib/flatpak
-v crafter-flatpak-nostro-cache:/home/build/.cache
-v /var/www/flatpak:/srv/flatpak
-v /etc/crafter-flatpak:/run/crafter-flatpak:ro
steps:
- name: Install tools
# A mirror answering 502 can fail a pacman transaction even with another mirror behind it; a retry starts over.
run: |
retry() { for i in 1 2 3 4 5; do "$@" && return 0; echo "attempt $i of 5 failed: $*" >&2; [ "$i" = 5 ] || sleep 30; done; return 1; }
pacman-key --init
pacman-key --populate archlinux
retry pacman -Sy --noconfirm --needed archlinux-keyring
retry pacman -Syu --noconfirm --needed flatpak ostree appstream binutils curl xz gnupg git nodejs util-linux python jq
git config --global --add safe.directory '*'
- name: crafter-build
# The Crafter.Build Flatpak's stable branch, which moves only with its releases; its Sdk comes from Flathub.
# Flathub's CDN answers 502 now and then, which flatpak reports as a missing runtime: each of these gets five
# tries.
run: |
retry() { for i in 1 2 3 4 5; do "$@" && return 0; echo "attempt $i of 5 failed: $*" >&2; [ "$i" = 5 ] || sleep 30; done; return 1; }
retry flatpak remote-add --if-not-exists catcrafts https://flatpak.catcrafts.net/catcrafts.flatpakrepo
retry flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
retry flatpak install -y --noninteractive catcrafts "$CRAFTER_REF"
retry flatpak update -y --noninteractive
flatpak info "$CRAFTER_REF" | sed -n 's/^ *\(Version\|Commit\|Date\): */crafter-build \1: /p'
- name: Checkout
# Every branch and tag, for the release checks; no step pushes, so the token is not kept in the checkout.
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Build user
# crafter-build and the scripts run as a user; root installs and publishes.
run: |
id build >/dev/null 2>&1 || useradd -m build
chown -R build: "$GITHUB_WORKSPACE" /home/build
- name: Version
id: meta
# The release checks, before anything is built; the notes go to release-notes.md, for the release.
env:
RELEASE_NOTES: release-notes.md
run: |
set -eu
version=$(runuser -u build -- packaging/flatpak/release-version.sh "$GITHUB_REF_NAME")
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "version $version"
- name: Tests
# Against the fake bunq and the fake system bus the tests bring: no bank and no system bus is reached.
run: runuser -u build -- flatpak run "$CRAFTER_REF" test --banks=bunq
- name: Crafter.Graphics
run: |
set -eu
rm -rf "$GRAPHICS_DIR"
if ! runuser -u build -- git clone --quiet --depth 1 --branch "$GRAPHICS_REF" "$GRAPHICS_URL" "$GRAPHICS_DIR"; then
echo "no $GRAPHICS_REF at $GRAPHICS_URL: the app is built against it, see the head of .forgejo/workflows/flatpak.yaml" >&2
exit 1
fi
echo "Crafter.Graphics $(git -C "$GRAPHICS_DIR" rev-parse HEAD)"
- name: Sysroot
run: runuser -u build -- packaging/flatpak/make-aarch64-sysroot.sh
- name: Build
# repo is made anew, as dist is below: root bundles and publishes from it.
run: |
rm -rf repo
runuser -u build -- env NOSTRO_GRAPHICS="$GRAPHICS_DIR/project.cpp" packaging/flatpak/build-aarch64.sh repo "$BRANCH"
- name: Bundle
# dist is made anew: the release carries every file in it, and a checkout can bring a dist of its own, or a
# link by that name.
run: |
rm -rf dist
mkdir dist
flatpak build-bundle --arch="$ARCH" --runtime-repo=https://dl.flathub.org/repo/flathub.flatpakrepo \
repo "dist/nostrod-${{ steps.meta.outputs.version }}-$ARCH.flatpak" "$SERVICE_ID" "$BRANCH"
flatpak build-bundle --arch="$ARCH" --runtime-repo=https://dl.flathub.org/repo/flathub.flatpakrepo \
repo "dist/nostro-${{ steps.meta.outputs.version }}-$ARCH.flatpak" "$APP_ID" "$BRANCH"
- name: Upload bundles
uses: actions/upload-artifact@v3
with:
name: nostro-${{ steps.meta.outputs.version }}-aarch64
path: dist/*.flatpak
if-no-files-found: error
- name: Publish to the Catcrafts repository
run: |
set -eu
if [ ! -s /run/crafter-flatpak/signing-key.asc ] || [ ! -s /run/crafter-flatpak/key-id ]; then
echo "no signing key under /etc/crafter-flatpak on the runner host" >&2
exit 1
fi
export GNUPGHOME=$(mktemp -d)
gpg --batch --quiet --import /run/crafter-flatpak/signing-key.asc
key_id=$(cat /run/crafter-flatpak/key-id)
# The other workflows that publish into this repository each hold this lock while they do, so a commit and
# the summary update of one never interleave with another's.
exec 9> /srv/flatpak/.publish.lock
flock 9
# The repository's catcrafts.flatpakrepo, which an install adds, is Crafter.Build's to write, so a repository
# that is not there is not this workflow's to start; it commits its own refs and then updates the repository
# as the others do.
[ -f "$REPO_DIR/config" ] || { echo "no published repository at $REPO_DIR" >&2; exit 1; }
# Each one's ref file, the repository's key in it: the checkout's, read as the build user like every file of
# the checkout. They are made before anything is published, so a file that cannot carry the key publishes
# nothing, and moved beside the repository after it.
key=$(gpg --export "$key_id" | base64 --wrap=0)
[ -n "$key" ] || { echo "the signing key did not export" >&2; exit 1; }
for id in "$SERVICE_ID" "$APP_ID"; do
runuser -u build -- sed "s|^GPGKey=.*|GPGKey=$key|" "packaging/flatpak/$id.flatpakref" > "/srv/flatpak/.$id.flatpakref.new"
grep -qx "GPGKey=$key" "/srv/flatpak/.$id.flatpakref.new"
done
# The service and the app in one commit to the repository: the app is of no use without the service of its
# release.
flatpak build-commit-from --src-repo=repo \
--gpg-sign="$key_id" --gpg-homedir="$GNUPGHOME" \
"$REPO_DIR" "app/$SERVICE_ID/$ARCH/$BRANCH" "app/$APP_ID/$ARCH/$BRANCH"
flatpak build-update-repo --gpg-sign="$key_id" --gpg-homedir="$GNUPGHOME" \
--generate-static-deltas --prune "$REPO_DIR"
for id in "$SERVICE_ID" "$APP_ID"; do
mv "/srv/flatpak/.$id.flatpakref.new" "/srv/flatpak/$id.flatpakref"
done
flock -u 9
- name: Release files
# The ref files as published, with the repository's key (the checkout's have a placeholder), and the checksums
# of what the release carries.
run: |
set -eu
cp "/srv/flatpak/$SERVICE_ID.flatpakref" "/srv/flatpak/$APP_ID.flatpakref" dist/
(cd dist && sha256sum * > SHA256SUMS && ls -la)
- name: Publish release
# The notes are release-notes.md, which the Version step wrote. No `override`: it would delete a tag that has
# moved off this commit since the Version step and tag the old commit instead.
uses: https://code.forgejo.org/actions/forgejo-release@v2
with:
direction: upload
url: ${{ github.server_url }}
repo: ${{ github.repository }}
tag: ${{ steps.meta.outputs.version }}
title: Nostro ${{ steps.meta.outputs.version }}
release-notes-file: release-notes.md
release-dir: dist
token: ${{ secrets.GITHUB_TOKEN }}

View file

@ -34,7 +34,8 @@ Five C++26 modules, and a sixth in one build:
| `project.cpp` | The build description: reads `--banks=`, `--lib`, `--dbus`, `--product=`, `--graphics=`, `--debug-api`, `--coverage` and `--profile-runtime=`, forwards the other args to the dependencies (with `--no-quic` for Crafter.Network, except in the app's debug build), returns the product. It names each dependency at a commit ("Dev environment"). It also holds what the app is as a Flatpak (`app.flatpak`) and the `fake` run script. | | `project.cpp` | The build description: reads `--banks=`, `--lib`, `--dbus`, `--product=`, `--graphics=`, `--debug-api`, `--coverage` and `--profile-runtime=`, forwards the other args to the dependencies (with `--no-quic` for Crafter.Network, except in the app's debug build), returns the product. It names each dependency at a commit ("Dev environment"). It also holds what the app is as a Flatpak (`app.flatpak`) and the `fake` run script. |
| `packaging/dbus/` | The published D-Bus interfaces, `net.catcrafts.Nostro1.xml` and `net.catcrafts.Nostro1.Checkout.xml`. | | `packaging/dbus/` | The published D-Bus interfaces, `net.catcrafts.Nostro1.xml` and `net.catcrafts.Nostro1.Checkout.xml`. |
| `packaging/system/` | What a Flatpak cannot install: the polkit policy, the D-Bus policy and activation files, `nostrod.service`, the sysusers entry, the `nostro` command, `install.sh` and `uninstall.sh`. | | `packaging/system/` | What a Flatpak cannot install: the polkit policy, the D-Bus policy and activation files, `nostrod.service`, the sysusers entry, the `nostro` command, `install.sh` and `uninstall.sh`. |
| `packaging/flatpak/`, `packaging/licenses/`, `packaging/arch/` | nostrod's Flatpak manifest (on crafter-build's Flatpak as its base app), each Flatpak's metainfo and `.flatpakref`, the app's desktop entry and icon, and the two scripts that cross-build both Flatpaks for aarch64; the licence texts the Flatpaks carry, with a `NOTICE` of what each covers; the Arch package of the system files, `nostro-system`. | | `.forgejo/workflows/flatpak.yaml` | The one workflow: the tests and both aarch64 Flatpaks for a pull request or a run by hand, and for a signed tag `X.Y.Z` their publication; see "Releasing". |
| `packaging/flatpak/`, `packaging/licenses/`, `packaging/arch/` | nostrod's Flatpak manifest (on crafter-build's Flatpak as its base app), each Flatpak's metainfo and `.flatpakref`, the app's desktop entry and icon, the two scripts that cross-build both Flatpaks for aarch64, and `release-version.sh`, which checks what a tree releases; the licence texts the Flatpaks carry, with a `NOTICE` of what each covers; the Arch package of the system files, `nostro-system`. |
| `lib/json.hpp` | nlohmann/json (MIT), included in the global module fragment of `:Bunq` and of the `Connector`, `Bunq` and `BunqPayments` implementation units. Not a release: `single_include/nlohmann/json.hpp` as upstream's `develop` had it at commit `95e9a5931c828cd7306eff36090a5b38e0e3f598` (2026-09-25), which still calls itself 3.12.0, the release of 2025-04-11. It is that file byte for byte, so `git hash-object lib/json.hpp` gives its id there, `4981c3b02e0367e22419b17c37345873d7813076`: keep it so, and name the commit here and in `packaging/licenses/NOTICE` when it is replaced. | | `lib/json.hpp` | nlohmann/json (MIT), included in the global module fragment of `:Bunq` and of the `Connector`, `Bunq` and `BunqPayments` implementation units. Not a release: `single_include/nlohmann/json.hpp` as upstream's `develop` had it at commit `95e9a5931c828cd7306eff36090a5b38e0e3f598` (2026-09-25), which still calls itself 3.12.0, the release of 2025-04-11. It is that file byte for byte, so `git hash-object lib/json.hpp` gives its id there, `4981c3b02e0367e22419b17c37345873d7813076`: keep it so, and name the commit here and in `packaging/licenses/NOTICE` when it is replaced. |
| `tests/<Name>/main.cpp`, `tests/Support/`, `tests/FakeSystem/`, `tests/coverage.sh` | The tests, their checks, fake bunq and fake system bus, the made-up system built from those, and the coverage run; see "Testing instructions". | | `tests/<Name>/main.cpp`, `tests/Support/`, `tests/FakeSystem/`, `tests/coverage.sh` | The tests, their checks, fake bunq and fake system bus, the made-up system built from those, and the coverage run; see "Testing instructions". |
| `docs/screenshots/` | The README's pictures of the app, on a phone's screen and in a desktop window, and `take.sh`, which takes them again on the made-up system; see "Looking at the app". | | `docs/screenshots/` | The README's pictures of the app, on a phone's screen and in a desktop window, and `take.sh`, which takes them again on the made-up system; see "Looking at the app". |
@ -132,7 +133,7 @@ crafter-build is the only build tool. It compiles with its clang 23 and libc++,
- Every dependency `project.cpp` names is at a commit: Crafter.Network (nostro builds it `--no-quic`, so without msquic) and Crafter.DB are `GitProject`s with a `.commit`, and Crafter.LintRules and Crafter.Debug's build helper `#pragma crafter dependency` lines with `commit "<sha>"`. crafter-build clones each from `forgejo.catcrafts.net` once and builds from that clone, and the notes at the end of this file are those commits' notes. They were pinned on 2026-11-19, to what the tests had run against that day: a build runs each dependency's own `project.cpp` and links its code into the program that holds every user's bank keys. Moving one forward is a change to `project.cpp`, with the tests run again. - Every dependency `project.cpp` names is at a commit: Crafter.Network (nostro builds it `--no-quic`, so without msquic) and Crafter.DB are `GitProject`s with a `.commit`, and Crafter.LintRules and Crafter.Debug's build helper `#pragma crafter dependency` lines with `commit "<sha>"`. crafter-build clones each from `forgejo.catcrafts.net` once and builds from that clone, and the notes at the end of this file are those commits' notes. They were pinned on 2026-11-19, to what the tests had run against that day: a build runs each dependency's own `project.cpp` and links its code into the program that holds every user's bank keys. Moving one forward is a change to `project.cpp`, with the tests run again.
- Two things still follow a branch, so a build still needs the network. Crafter.Thread comes behind Crafter.Network, whose own project file names it without a commit: pinning it is Crafter.Network's to do. And the app's `--debug-api` build takes Crafter.Network without a commit, because Crafter.Debug does: with one library named two ways crafter-build stops with "module Crafter.Network is built twice for nostro-app", as tried on 2026-11-19. - Two things still follow a branch, so a build still needs the network. Crafter.Thread comes behind Crafter.Network, whose own project file names it without a commit: pinning it is Crafter.Network's to do. And the app's `--debug-api` build takes Crafter.Network without a commit, because Crafter.Debug does: with one library named two ways crafter-build stops with "module Crafter.Network is built twice for nostro-app", as tried on 2026-11-19.
- The app needs a Wayland compositor and a Vulkan device to run, and nothing else of nostro does. No test opens a window. `--product=app` takes `--graphics=<a Crafter.Graphics checkout's project.cpp>` for now: the app asks the input method for a field's purpose and hints, which Crafter.Graphics has on its branch `claude/nostro-app` and not yet on master. Once that is merged, name it as a `GitProject` at a pinned commit in `project.cpp` and drop the flag. - The app needs a Wayland compositor and a Vulkan device to run, and nothing else of nostro does. No test opens a window. `--product=app` takes `--graphics=<a Crafter.Graphics checkout's project.cpp>` for now: the app asks the input method for a field's purpose and hints (`TextInputPurpose`), which Crafter.Graphics' master does not have. The change is meant for its branch `claude/nostro-app`. On 2026-11-19 neither was on the forge: it was uncommitted work in one local checkout, so the app could be built on that machine and nowhere else, CI included. Once it is pushed, CI finds it by that branch's name; once it is merged, name Crafter.Graphics as a `GitProject` at a pinned commit in `project.cpp` and drop the flag, and the workflow's step that fetches it.
- The app's `--debug-api` build links Crafter.Debug, which talks QUIC: that one build has Crafter.Network with msquic (crafter-build builds it with CMake once, for minutes, and keeps it in its cache), and its binaries carry a runpath into that cache. - The app's `--debug-api` build links Crafter.Debug, which talks QUIC: that one build has Crafter.Network with msquic (crafter-build builds it with CMake once, for minutes, and keeps it in its cache), and its binaries carry a runpath into that cache.
- Where the connectors live depends on who runs the library. nostrod's worker keeps each user's under `<state>/users/<uid>/`: `connectors.json`, the transaction tables, `checkouts.cdb`, `checkout-account` and `owner`, with `<state>` from `--state`, else `$XDG_DATA_HOME`, else `$HOME/.local/share`. Installed, that is `/var/lib/nostro/.var/app/net.catcrafts.Nostrod/data/`, readable by the user `nostro` alone. The library used directly reads `connectors.json` from `$XDG_CONFIG_HOME/.config/nostro/` (sic, see "Gotchas") or `$HOME/.config/nostro/`, and keeps the transaction tables under `$XDG_CACHE_HOME/nostro/transactions/` or `$HOME/.cache/nostro/transactions/`. A real connectors file holds a real API key: point every experiment elsewhere. - Where the connectors live depends on who runs the library. nostrod's worker keeps each user's under `<state>/users/<uid>/`: `connectors.json`, the transaction tables, `checkouts.cdb`, `checkout-account` and `owner`, with `<state>` from `--state`, else `$XDG_DATA_HOME`, else `$HOME/.local/share`. Installed, that is `/var/lib/nostro/.var/app/net.catcrafts.Nostrod/data/`, readable by the user `nostro` alone. The library used directly reads `connectors.json` from `$XDG_CONFIG_HOME/.config/nostro/` (sic, see "Gotchas") or `$HOME/.config/nostro/`, and keeps the transaction tables under `$XDG_CACHE_HOME/nostro/transactions/` or `$HOME/.cache/nostro/transactions/`. A real connectors file holds a real API key: point every experiment elsewhere.
- No test uses the system bus: they run on `tests/Support/FakeBus.inc`. Running anything by hand that talks to `net.catcrafts.Nostro1` reaches the installed nostrod, if there is one, and its dialogs: the CLI, and the app, which reads the accounts as soon as it starts. A Flatpak sandbox with the system bus (`flatpak run`) sets `DBUS_SYSTEM_BUS_ADDRESS` itself, over an `--env` of yours: keep a sandboxed experiment off the bus with `--nosocket=system-bus`. To look at the app, run it on the made-up system, `nostro-fake-system`, which sets that address for what it starts ("Looking at the app"). - No test uses the system bus: they run on `tests/Support/FakeBus.inc`. Running anything by hand that talks to `net.catcrafts.Nostro1` reaches the installed nostrod, if there is one, and its dialogs: the CLI, and the app, which reads the accounts as soon as it starts. A Flatpak sandbox with the system bus (`flatpak run`) sets `DBUS_SYSTEM_BUS_ADDRESS` itself, over an `--env` of yours: keep a sandboxed experiment off the bus with `--nosocket=system-bus`. To look at the app, run it on the made-up system, `nostro-fake-system`, which sets that address for what it starts ("Looking at the app").
@ -162,10 +163,27 @@ crafter-build --banks=bunq --product=app --graphics=… --packaging=flatpak --ma
packaging/flatpak/make-aarch64-sysroot.sh && packaging/flatpak/build-aarch64.sh <repo> # both Flatpaks for aarch64, into a repository packaging/flatpak/make-aarch64-sysroot.sh && packaging/flatpak/build-aarch64.sh <repo> # both Flatpaks for aarch64, into a repository
``` ```
`--banks=` is mandatory except for `--product=checkout`: without it `project.cpp` throws "must enable atleast one bank" and nothing is built; an unknown name throws "unknown connector", an unknown product "unknown product". flatpak-builder needs crafter-build's own Flatpak (`net.catcrafts.CrafterBuild`, stable) installed as its base app, the network during the build, and, run as a Flatpak itself, `--filesystem=` for a build directory outside your home, or the build commands cannot find it. Install the result for a test with `sudo packaging/system/install.sh --repo <dir>/repo`. There is no CI. The tests run every line, function and region of the library, the CLI, nostrod, the toolkit and the app without its window (2026-11-19), and a change keeps them doing so; the README's rule for contributed connectors applies on top: not blind, also tried against the sandbox or the live API ("Testing instructions"). `--banks=` is mandatory except for `--product=checkout`: without it `project.cpp` throws "must enable atleast one bank" and nothing is built; an unknown name throws "unknown connector", an unknown product "unknown product". flatpak-builder needs crafter-build's own Flatpak (`net.catcrafts.CrafterBuild`, stable) installed as its base app, the network during the build, and, run as a Flatpak itself, `--filesystem=` for a build directory outside your home, or the build commands cannot find it. Install the result for a test with `sudo packaging/system/install.sh --repo <dir>/repo`. CI is `.forgejo/workflows/flatpak.yaml` ("Releasing" below): it runs for a pull request, by hand and for a release's tag, so a plain push is tested by nobody but whoever pushed it. The tests run every line, function and region of the library, the CLI, nostrod, the toolkit and the app without its window (2026-11-19), and a change keeps them doing so; the README's rule for contributed connectors applies on top: not blind, also tried against the sandbox or the live API ("Testing instructions").
The app's packaging: `--packaging=flatpak` makes `bin/nostro-app-<variant>/files/` (the program with its fonts and shaders in `bin/`, the C++ runtime in `lib/`, the desktop entry, icon, metainfo and licences in `share/`), `bundle` a `.flatpak` beside it and `install` an installation for the user who runs it; both print the permissions, which `project.cpp` lists. That is x86_64, on the Platform crafter-build's Flatpak runs on. For aarch64, a phone, there is no crafter-build to build with, so both Flatpaks are cross builds: `make-aarch64-sysroot.sh` makes a sysroot of the Freedesktop Sdk for aarch64 with LLVM's libc++ (in `~/.cache/nostro-flatpak`, or `$NOSTRO_FLATPAK_CACHE`), and `build-aarch64.sh <repo>` builds the CLI, nostrod and the app against it and assembles `net.catcrafts.Nostrod` and `net.catcrafts.Nostro` into an OSTree repository, which `install.sh --repo <repo> --app` installs on the phone. The app's permissions are in two places because of it, `project.cpp` and that script: change them together. The app's packaging: `--packaging=flatpak` makes `bin/nostro-app-<variant>/files/` (the program with its fonts and shaders in `bin/`, the C++ runtime in `lib/`, the desktop entry, icon, metainfo and licences in `share/`), `bundle` a `.flatpak` beside it and `install` an installation for the user who runs it; both print the permissions, which `project.cpp` lists. That is x86_64, on the Platform crafter-build's Flatpak runs on. For aarch64, a phone, there is no crafter-build to build with, so both Flatpaks are cross builds: `make-aarch64-sysroot.sh` makes a sysroot of the Freedesktop Sdk for aarch64 with LLVM's libc++ (in `~/.cache/nostro-flatpak`, or `$NOSTRO_FLATPAK_CACHE`), and `build-aarch64.sh <repo>` builds the CLI, nostrod and the app against it and assembles `net.catcrafts.Nostrod` and `net.catcrafts.Nostro` into an OSTree repository, which `install.sh --repo <repo> --app` installs on the phone. The app's permissions are in two places because of it, `project.cpp` and that script: change them together.
### Releasing
`.forgejo/workflows/flatpak.yaml` is the one workflow, and follows imsd-messages' step for step, since `make-aarch64-sysroot.sh` and `build-aarch64.sh` are the counterparts of that app's scripts. It has two jobs, both on the privileged runner labelled `flatpak` (bubblewrap needs the privilege), in an `archlinux` container with crafter-build's stable Flatpak:
- `check`, for a pull request and a run by hand: the version check, the tests, the lint of the library, the CLI and the tests, and then both Flatpaks for aarch64. It runs cold and mounts nothing of the host.
- `publish`, for a pushed tag `X.Y.Z`: the release checks, the tests and both Flatpaks. It then commits the two as `stable` into the Catcrafts Flatpak repository on the runner's host (`/var/www/flatpak`, signed with the key under `/etc/crafter-flatpak`, under the lock the other publishing workflows hold), puts each one's `.flatpakref` beside it with the repository's key in it, and makes release `X.Y.Z` on the forge with the two bundles, the ref files and their checksums.
A release is a tag, as it is for Crafter.Build and imsd-messages: a push without one runs nothing. `packaging/flatpak/release-version.sh` holds `NOSTRO_VERSION` in `project.cpp` to the newest `<release>` of the app's metainfo, whose description is the release notes. For a tag it also checks that the tag is that version, annotated, signed by the owner as Forgejo verifies it, on master, and newer than every release there is. So a release is: bump both, commit, `git tag -s X.Y.Z -m 'Nostro X.Y.Z'`, and push master and the tag together.
The workflow was written on 2026-11-19 and pushed without having run once: its first run is its test. What it needs, and did not have that day:
- A runner. The `flatpak` runner is the Catcrafts organisation's and serves that organisation's repositories, and the repository was pushed to `jorijnvdgraaf/Nostro`. There a job waits until a runner with that label is registered for the repository, or the repository is moved.
- The runner's config has to allow the four volumes `publish` mounts. Three are the ones imsd-messages' job mounts; `crafter-flatpak-nostro-cache` is new.
- Crafter.Graphics' text-input change on the forge, as the branch the workflow's `GRAPHICS_REF` names ("Dev environment"). Until then the app's build fails in the step that fetches it, and with it both jobs.
Only aarch64 is published, a phone's architecture. An x86_64 machine builds its own Flatpaks with the commands above, which the README's "Installing" does not say yet. The system files are not in a release either: they come from a checkout (`packaging/system/install.sh`) or the Arch package.
## Testing instructions ## Testing instructions
`crafter-build test --banks=bunq` builds and runs `tests/<Name>/main.cpp` for each name in `project.cpp`'s lists, each linked against what it tests (the library, the toolkit, or the app without its window), in parallel; a test exits 0 when every check passed and prints each failed one with its line. None needs Crafter.Graphics, a compositor or a graphics device. They are: `crafter-build test --banks=bunq` builds and runs `tests/<Name>/main.cpp` for each name in `project.cpp`'s lists, each linked against what it tests (the library, the toolkit, or the app without its window), in parallel; a test exits 0 when every check passed and prints each failed one with its line. None needs Crafter.Graphics, a compositor or a graphics device. They are:
@ -278,7 +296,7 @@ The checklist, from the bunq connector:
- Take the commit voice from the sibling Crafter repositories: `type(scope): imperative summary` with `feat`, `fix`, `refactor`, `docs` or `build`, and the partition or the CLI as the scope (`bunq`, `account`, `currency`, `connector`, `file`, `bus`, `client`, `daemon`, `checkout`, `cli`, `ui`, `app`, `shell`, `debug`, `build`, `packaging`). The body says what was wrong, why, and how it was verified against the sandbox. Add a `Co-Authored-By:` trailer when an agent wrote it. - Take the commit voice from the sibling Crafter repositories: `type(scope): imperative summary` with `feat`, `fix`, `refactor`, `docs` or `build`, and the partition or the CLI as the scope (`bunq`, `account`, `currency`, `connector`, `file`, `bus`, `client`, `daemon`, `checkout`, `cli`, `ui`, `app`, `shell`, `debug`, `build`, `packaging`). The body says what was wrong, why, and how it was verified against the sandbox. Add a `Co-Authored-By:` trailer when an agent wrote it.
- The README is the manual: keep its CLI section true to `main.cpp` and "The app" true to the screens: what the one can do, the other can. Update `AGENTS.consumer.md` in the same change when a signature, a path, a default, a file format or an error behaviour consumers lean on changes; consumers pick it up on their next build. - The README is the manual: keep its CLI section true to `main.cpp` and "The app" true to the screens: what the one can do, the other can. Update `AGENTS.consumer.md` in the same change when a signature, a path, a default, a file format or an error behaviour consumers lean on changes; consumers pick it up on their next build.
- A change to how the app looks or is laid out says in its commit how it was looked at: which screens, at which sizes, on what. When it changes a screen the README shows, the pictures are taken again (`docs/screenshots/take.sh`) in the same commit. - A change to how the app looks or is laid out says in its commit how it was looked at: which screens, at which sizes, on what. When it changes a screen the README shows, the pictures are taken again (`docs/screenshots/take.sh`) in the same commit.
- The app's version is `NOSTRO_VERSION` in `project.cpp`, and the newest release in `packaging/flatpak/net.catcrafts.Nostro.metainfo.xml` is the same. - The app's version is `NOSTRO_VERSION` in `project.cpp`, and the newest release in `packaging/flatpak/net.catcrafts.Nostro.metainfo.xml` is the same: `packaging/flatpak/release-version.sh` fails on a tree where they differ, and CI runs it first.
- A change to `Transaction` is a schema change (design rule 5), and the commit message says so. - A change to `Transaction` is a schema change (design rule 5), and the commit message says so.
- A change to the D-Bus interfaces or the polkit policy changes the published contract (design rule 10); the XML, the policy and the test that holds them change together. - A change to the D-Bus interfaces or the polkit policy changes the published contract (design rule 10); the XML, the policy and the test that holds them change together.
- A change that moves code between the library and the app moves it between two licences (design rule 13), and its commit message says so. - A change that moves code between the library and the app moves it between two licences (design rule 13), and its commit message says so.
@ -299,7 +317,7 @@ The checklist, from the bunq connector:
- TLS is Crafter.Network's default `TLSClientCredentials{}`: the chain against the system store and the hostname. Do not reach for `insecureNoServerValidation`. - TLS is Crafter.Network's default `TLSClientCredentials{}`: the chain against the system store and the hostname. Do not reach for `insecureNoServerValidation`.
- The private key signs every request body (`SignBody`, RSA SHA-256). Key material lives in `Crypto::Key`s (freed with the last copy) for the process's life; there is no zeroisation. - The private key signs every request body (`SignBody`, RSA SHA-256). Key material lives in `Crypto::Key`s (freed with the last copy) for the process's life; there is no zeroisation.
- `project.cpp` executes the `project.cpp` of each dependency on every build, and the Flatpak build does the same with the network on. Those it names itself are at a commit since 2026-11-19: Crafter.Network, Crafter.DB, Crafter.LintRules and Crafter.Debug's build helper ("Dev environment"). What still follows a branch, fetched from the Catcrafts Forgejo at HEAD: Crafter.Thread, which Crafter.Network names; in the app's build Crafter.Graphics, a checkout given with `--graphics=`, which brings Crafter.Event, Crafter.Math, Crafter.Asset and the Khronos headers, unpinned; and in its debug build Crafter.Debug's library with a Crafter.Network that has msquic in it. Pin those where they are named for a build that is reproducible and offline after the first fetch. - `project.cpp` executes the `project.cpp` of each dependency on every build, and the Flatpak build does the same with the network on. Those it names itself are at a commit since 2026-11-19: Crafter.Network, Crafter.DB, Crafter.LintRules and Crafter.Debug's build helper ("Dev environment"). What still follows a branch, fetched from the Catcrafts Forgejo at HEAD: Crafter.Thread, which Crafter.Network names; in the app's build Crafter.Graphics, a checkout given with `--graphics=`, which brings Crafter.Event, Crafter.Math, Crafter.Asset and the Khronos headers, unpinned; and in its debug build Crafter.Debug's library with a Crafter.Network that has msquic in it. Pin those where they are named for a build that is reproducible and offline after the first fetch.
- `install.sh --repo` installs from an unsigned local repository, for a build of your own, and so does a bundle crafter-build made. A published Flatpak comes from the GPG-signed Catcrafts remote, which is how the README installs both: the remote `catcrafts`, added from `https://flatpak.catcrafts.net/catcrafts.flatpakrepo`, Crafter.Build's own remote. `install.sh` without `--repo` installs from that remote in the system installation, where nostrod runs from, and does not add it itself. On 2026-11-19 the remote did not carry nostro's two Flatpaks yet: the README describes the channel they are to be published on. The two `.flatpakref`s in `packaging/flatpak/` carry the same placeholder for the key as Crafter.Build's, for the publishing side to fill in. - `install.sh --repo` installs from an unsigned local repository, for a build of your own, and so does a bundle crafter-build made. A published Flatpak comes from the GPG-signed Catcrafts remote, which is how the README installs both: the remote `catcrafts`, added from `https://flatpak.catcrafts.net/catcrafts.flatpakrepo`, Crafter.Build's own remote. `install.sh` without `--repo` installs from that remote in the system installation, where nostrod runs from, and does not add it itself. On 2026-11-19 the remote did not carry nostro's two Flatpaks yet: the README describes the channel they are to be published on. The two `.flatpakref`s in `packaging/flatpak/` carry the same placeholder for the key as Crafter.Build's, for the publishing side to fill in, which is the workflow's `publish` job. The key it signs with lives on the runner's host and never in the forge, and a release is published only for a tag the owner signed ("Releasing").
- Input from the bank is parsed with nlohmann/json's `at()` and `get()`, which throw on a missing key or a wrong type: a malformed response is an exception, not undefined behaviour. `ParseAmount` and `ParseTimestamp` reject anything outside their grammar. - Input from the bank is parsed with nlohmann/json's `at()` and `get()`, which throw on a missing key or a wrong type: a malformed response is an exception, not undefined behaviour. `ParseAmount` and `ParseTimestamp` reject anything outside their grammar.
## Gotchas ## Gotchas

View file

@ -0,0 +1,120 @@
#!/bin/sh
# SPDX-License-Identifier: LGPL-3.0-only
# SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
# release-version.sh: prints the version this tree releases, checked. After imsd-messages' script of the same name.
#
# packaging/flatpak/release-version.sh # any tree
# packaging/flatpak/release-version.sh <tag> # CI's run for a pushed tag
#
# The version is that of the app's metainfo's newest <release>, its first one, and NOSTRO_VERSION in project.cpp has to
# be the same. The entry's description is the release notes: it has to render some, and they are written as Markdown
# to the file $RELEASE_NOTES names, when it names one.
#
# For a tag the release is checked as well: the tag is that version, annotated and signed by $RELEASE_SIGNER as Forgejo
# verifies it, on master, and newer than every release the forge has published. Those checks read $GITHUB_SERVER_URL,
# $GITHUB_REPOSITORY and $GITHUB_SHA, and the checkout's tags and origin/master. Needs python3, and for a tag curl, jq
# and git.
set -eu
SRC=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
METAINFO=packaging/flatpak/net.catcrafts.Nostro.metainfo.xml
# The metainfo is parsed, once, for both the version and the notes: a comment or another attribute order would mislead
# a text search. AppStream has no headings, so a paragraph that introduces a list is one: <p>New</p><ul>...</ul> comes
# out as "## New" over its items, and a paragraph on its own stays a paragraph. <em> and <code> get their Markdown
# spelling.
newest=$(python3 - "$SRC/$METAINFO" "${RELEASE_NOTES:-}" <<'EOF'
import sys
import xml.etree.ElementTree as ET
release = ET.parse(sys.argv[1]).getroot().find("releases/release")
desc = None if release is None else release.find("description")
def text(el):
parts = [el.text or ""]
for child in el:
inner = text(child)
parts.append({"em": f"*{inner}*", "code": f"`{inner}`"}.get(child.tag, inner))
parts.append(child.tail or "")
return " ".join("".join(parts).split())
blocks = [] if desc is None else list(desc)
out = []
for i, el in enumerate(blocks):
heads_list = i + 1 < len(blocks) and blocks[i + 1].tag in ("ul", "ol")
if el.tag == "p":
out.append(f"## {text(el)}" if heads_list else text(el))
elif el.tag == "ul":
out.append("\n".join(f"- {text(li)}" for li in el))
elif el.tag == "ol":
out.append("\n".join(f"{n}. {text(li)}" for n, li in enumerate(el, 1)))
notes = "\n\n".join(out)
if not notes.strip():
sys.exit("the metainfo needs a <release> at the top of <releases> whose <description> renders release notes")
if sys.argv[2]:
with open(sys.argv[2], "w") as f:
print(notes, file=f)
print(release.get("version", ""))
EOF
)
app=$(sed -n 's/.*{"NOSTRO_VERSION", "\(.*\)"}.*/\1/p' "$SRC/project.cpp")
if [ "$app" != "$newest" ]; then
echo "the app's version is \"$app\", but the metainfo's newest release is \"$newest\": a release bumps NOSTRO_VERSION in project.cpp and adds its <release> entry at the top of $METAINFO" >&2
exit 1
fi
[ $# -ge 1 ] || { echo "$newest"; exit 0; }
# A release. The tag itself is read from the forge: the checkout fetches a pushed tag again as a plain ref to its
# commit, so the local one is never the annotated tag.
version=$1
if ! printf '%s\n' "$version" | grep -qxE '[0-9]+\.[0-9]+\.[0-9]+'; then
echo "the tag $version is not a version of the form X.Y.Z" >&2
exit 1
fi
api="$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY"
tag=$(curl -sSf "$api/tags/$version")
object=$(printf '%s' "$tag" | jq -r .id)
commit=$(printf '%s' "$tag" | jq -r .commit.sha)
if [ "$commit" != "$GITHUB_SHA" ]; then
echo "the forge has the tag $version on $commit, not on this run's commit $GITHUB_SHA" >&2
exit 1
fi
if [ "$object" = "$commit" ]; then
echo "$version is a lightweight tag; a release tag is annotated and signed: git tag -s $version -m 'Nostro $version'" >&2
exit 1
fi
# Forgejo verifies a signed tag's own signature, and for an unsigned one falls back to its commit's, so the verdict
# also has to cover the tag's payload, not the commit's.
signed=$(curl -sSf "$api/git/tags/$object" |
jq -r --arg c "$commit" --arg v "$version" '"\(.verification.verified) \(.verification.signer.email // "") \(.verification.payload // "" | startswith("object \($c)\ntype commit\ntag \($v)\n"))"')
if [ "$signed" != "true $RELEASE_SIGNER true" ]; then
echo "Forgejo does not verify the tag $version itself as signed by $RELEASE_SIGNER (verified, signer, over the tag's payload: $signed)" >&2
exit 1
fi
if ! git -C "$SRC" merge-base --is-ancestor "$GITHUB_SHA" origin/master; then
echo "the tag $version is on $(git -C "$SRC" rev-parse --short "$GITHUB_SHA"), which is not on master: push the tag with the master it releases" >&2
exit 1
fi
# Newer than every release the forge has published, its own included, and not every tag: a later tag whose run still
# queues behind this one has no release yet, and a tag that is no X.Y.Z version never gets one.
for t in $(git -C "$SRC" tag --list | awk '/^[0-9]+\.[0-9]+\.[0-9]+$/' | sort -V); do
[ "$(printf '%s\n%s\n' "$t" "$version" | sort -V | tail -n 1)" = "$t" ] || continue
code=$(curl -s -o /dev/null -w '%{http_code}' "$api/releases/tags/$t")
case "$code" in
404) ;;
200)
if [ "$t" = "$version" ]; then
echo "$version is released already; to re-run after a release left half made, delete that release first" >&2
else
echo "$version is not newer than the release $t" >&2
fi
exit 1 ;;
*) echo "the forge answered $code when asked whether $t is released" >&2; exit 1 ;;
esac
done
if [ "$newest" != "$version" ]; then
echo "the metainfo's newest release is \"$newest\", but the tag is $version: the tagged commit needs the <release> entry for $version at the top of $METAINFO" >&2
exit 1
fi
echo "$version"