# 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 # 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 a run needs, 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, of which this is one. # - The repository is public by the time a tag is pushed: the release checks read the forge without a login, and a # private repository answers them with a 404. # - 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 }}