ci: build the aarch64 flatpak and publish it

The flatpak is built after the tests for pull requests, when started by
hand and for a pushed tag X.Y.Z. Only the tag's run publishes: the
flatpak to the Catcrafts flatpak repository as its stable branch, the
app's ref file beside the repository with the repository's key in it —
the checkout's file, read as the build user like every file of the
checkout, made before anything is published, so a file that cannot carry
the key publishes nothing, and moved into place after it — and release
X.Y.Z on the forge with the metainfo's notes, the bundle and that ref
file. A push to main without a tag runs nothing. That is the release
model of Crafter.Build 6: every push to main is a release, made by the
tag the owner signs and pushes with it. packaging/release-version.sh
makes that workflow's checks — the tag is the version of the app and of
the metainfo's newest release, annotated and signed by the owner as
Forgejo verifies it, on main, and newer than every release published —
and in every run checks the app's version against the metainfo's, as the
version's comment in Model.cppm now says. Release runs share a
concurrency group, so one queues behind another.

Two jobs, by trust: check builds a pull request or a run by hand with
neither the published repository nor its key, publish builds a pushed
tag, and only its volumes feed what is signed. Both run on the
organisation's privileged flatpak runner: check cold, with no host
volume; publish with the four volumes it mounts — the crafter-build
installation the organisation's publish jobs share, this app's own
cache, the repository and the key — which the runner's config must
allow. It publishes into the repository Crafter.Build's and
Crafter.Review's workflows publish to, under the lock each of them holds
while it commits and updates the summary, signed with the same key,
which stays on the runner host, and keeps its bundle as an artifact. The
pacman and flatpak downloads get five tries, 30 s apart: Flathub's CDN
and Arch's Fastly mirror answer 502 now and then, flatpak reports a
summary it could not fetch as a missing runtime, and a mirror answering
502 can fail a pacman transaction even with another mirror behind it.

The README says how to install it and how to stop it starting at login;
AGENTS.md describes CI, a release, what guards the volumes and which of
them the runner must allow, and names what a released copy leaves on a
phone that later releases keep good: the stored rows and their
enumerators, the conversation key, the app id and the login entry's
command, the instance's interface.
This commit is contained in:
Jorijn van der Graaf 2026-10-20 23:50:39 +02:00
commit 57a751dbdb
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
6 changed files with 510 additions and 9 deletions

View file

@ -0,0 +1,14 @@
# SPDX-License-Identifier: GPL-3.0-only
# SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
[Flatpak Ref]
Title=Messages
Name=net.catcrafts.ImsdMessages
Branch=stable
Url=https://flatpak.catcrafts.net/repo/
SuggestRemoteName=catcrafts
Homepage=https://forgejo.catcrafts.net/Catcrafts/imsd-messages
Comment=Text messages through imsd
RuntimeRepo=https://dl.flathub.org/repo/flathub.flatpakrepo
IsRuntime=false
GPGKey=GPG_KEY_BASE64_PLACEHOLDER

128
packaging/release-version.sh Executable file
View file

@ -0,0 +1,128 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-3.0-only
# SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
# release-version.sh — prints the version this tree releases, checked.
#
# packaging/release-version.sh # any tree
# packaging/release-version.sh <tag> # CI's run for a pushed tag
#
# The version is that of the metainfo's newest <release>, its first one,
# and the app's `version` 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 main,
# 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/main. Needs python3, and for a tag curl, jq
# and git.
set -eu
SRC=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
METAINFO=packaging/net.catcrafts.ImsdMessages.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/.*constexpr std::string_view version = "\(.*\)";.*/\1/p' "$SRC/interfaces/ImsdMessages-Model.cppm")
if [ "$app" != "$newest" ]; then
echo "the app's version is \"$app\", but the metainfo's newest release is \"$newest\": a release bumps \`version\` in interfaces/ImsdMessages-Model.cppm 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 'imsd-messages $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/main; then
echo "the tag $version is on $(git -C "$SRC" rev-parse --short "$GITHUB_SHA"), which is not on main: push the tag with the main 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"