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:
parent
411ed55660
commit
57a751dbdb
6 changed files with 510 additions and 9 deletions
266
.forgejo/workflows/flatpak.yaml
Normal file
266
.forgejo/workflows/flatpak.yaml
Normal file
|
|
@ -0,0 +1,266 @@
|
|||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
# SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
||||
|
||||
name: Flatpak
|
||||
|
||||
# The aarch64 flatpak, 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 as the `stable` branch of the Catcrafts flatpak repository
|
||||
# (flatpak.catcrafts.net) with the app's ref file beside it, and release
|
||||
# X.Y.Z on the forge.
|
||||
#
|
||||
# Every push to main is a release: the owner signs its tag locally and
|
||||
# pushes it with the main it releases, and a push without one runs nothing.
|
||||
# The tag names the version, which the app and the metainfo's newest
|
||||
# <release> have to carry; that entry's description is the release notes
|
||||
# (packaging/release-version.sh).
|
||||
#
|
||||
# Two jobs, by trust. `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), this app's own build cache
|
||||
# (crafter-flatpak-messages-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. Both run on the Catcrafts organisation's privileged
|
||||
# `flatpak` runner, whose config must allow exactly those four volumes. 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.
|
||||
#
|
||||
# Crafter.Build's and Crafter.Review's workflows publish into the same
|
||||
# repository: each of the three holds /var/www/flatpak/.publish.lock while
|
||||
# it commits and updates the summary.
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
push:
|
||||
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.ImsdMessages
|
||||
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
|
||||
|
||||
jobs:
|
||||
check:
|
||||
if: github.event_name != 'push'
|
||||
runs-on: flatpak
|
||||
timeout-minutes: 150
|
||||
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/release-version.sh
|
||||
|
||||
- name: Sysroot
|
||||
run: runuser -u build -- packaging/make-flatpak-sysroot.sh
|
||||
|
||||
- name: Tests
|
||||
run: runuser -u build -- flatpak run "$CRAFTER_REF" test
|
||||
|
||||
- name: Build
|
||||
run: runuser -u build -- packaging/build-flatpak.sh repo "$BRANCH"
|
||||
|
||||
publish:
|
||||
if: github.event_name == 'push'
|
||||
runs-on: flatpak
|
||||
timeout-minutes: 150
|
||||
container:
|
||||
image: archlinux:latest
|
||||
options: >-
|
||||
-v crafter-flatpak-org-system:/var/lib/flatpak
|
||||
-v crafter-flatpak-messages-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/release-version.sh "$GITHUB_REF_NAME")
|
||||
echo "version=$version" >> "$GITHUB_OUTPUT"
|
||||
echo "version $version"
|
||||
|
||||
- name: Sysroot
|
||||
run: runuser -u build -- packaging/make-flatpak-sysroot.sh
|
||||
|
||||
- name: Tests
|
||||
run: runuser -u build -- flatpak run "$CRAFTER_REF" test
|
||||
|
||||
- name: Build
|
||||
# repo is made anew, as dist is below: root bundles and publishes
|
||||
# from it.
|
||||
run: |
|
||||
rm -rf repo
|
||||
runuser -u build -- packaging/build-flatpak.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/imsd-messages-${{ steps.meta.outputs.version }}-$ARCH.flatpak" "$APP_ID" "$BRANCH"
|
||||
|
||||
- name: Upload bundle
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: imsd-messages-${{ 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)
|
||||
# Crafter.Build's and Crafter.Review's workflows publish into the
|
||||
# same repository, and each holds this lock while it does, 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 ref and then
|
||||
# updates the repository as the other two do.
|
||||
[ -f "$REPO_DIR/config" ] || { echo "no published repository at $REPO_DIR" >&2; exit 1; }
|
||||
# The app's ref file, the repository's key in it: the checkout's,
|
||||
# read as the build user like every file of the checkout. It is
|
||||
# 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; }
|
||||
runuser -u build -- sed "s|^GPGKey=.*|GPGKey=$key|" "packaging/$APP_ID.flatpakref" > "/srv/flatpak/.$APP_ID.flatpakref.new"
|
||||
grep -qx "GPGKey=$key" "/srv/flatpak/.$APP_ID.flatpakref.new"
|
||||
flatpak build-commit-from --src-repo=repo \
|
||||
--gpg-sign="$key_id" --gpg-homedir="$GNUPGHOME" \
|
||||
"$REPO_DIR" "app/$APP_ID/$ARCH/$BRANCH"
|
||||
flatpak build-update-repo --gpg-sign="$key_id" --gpg-homedir="$GNUPGHOME" \
|
||||
--generate-static-deltas --prune "$REPO_DIR"
|
||||
mv "/srv/flatpak/.$APP_ID.flatpakref.new" "/srv/flatpak/$APP_ID.flatpakref"
|
||||
flock -u 9
|
||||
|
||||
- name: Release files
|
||||
# The ref file as published, with the repository's key (the
|
||||
# checkout's has a placeholder), and the checksums of what the
|
||||
# release carries.
|
||||
run: |
|
||||
set -eu
|
||||
cp "/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.
|
||||
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: imsd-messages ${{ steps.meta.outputs.version }}
|
||||
release-notes-file: release-notes.md
|
||||
release-dir: dist
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
94
AGENTS.md
94
AGENTS.md
|
|
@ -34,7 +34,8 @@ and §7.9 (Messaging) and §8.1 (the frozen one).
|
|||
| `tests/<Name>/main.cpp` | One test per directory, declared in `project.cpp`. |
|
||||
| `utilities/` | `fake-imsd.py`: imsd's Messaging interface on the session bus, for benches. |
|
||||
| `assets/` | The bundled font (Noto Sans, OFL 1.1). |
|
||||
| `packaging/` | The desktop entry, metainfo and icon; the flatpak's sysroot and build scripts and licence texts it ships (`licenses/`; §4 has the whole set). |
|
||||
| `packaging/` | The desktop entry, metainfo and icon; the flatpak's sysroot and build scripts, licence texts it ships (`licenses/`; §4 has the whole set), the release check (`release-version.sh`) and the ref file CI publishes (§5). |
|
||||
| `.forgejo/workflows/flatpak.yaml` | CI: the tests and the flatpak, published for a release's tag (§5). |
|
||||
|
||||
## 3. Building and testing
|
||||
|
||||
|
|
@ -42,7 +43,7 @@ and §7.9 (Messaging) and §8.1 (the frozen one).
|
|||
crafter-build # the executable
|
||||
crafter-build test # every test
|
||||
crafter-build lint # the house-style rules (Crafter.LintRules)
|
||||
crafter-build format --check # what CI gates on
|
||||
crafter-build format --check # the formatting rules
|
||||
```
|
||||
|
||||
A test is an ordinary `int main()`: exit 0 passes. Tests link the core (and
|
||||
|
|
@ -92,14 +93,93 @@ start `imsd-messages --daemon` at login (`ImsdMessages.Bus:Background`);
|
|||
the portal writes the login entry again at each request while the
|
||||
background permission allows it.
|
||||
|
||||
## 5. Making changes
|
||||
## 5. CI and publishing
|
||||
|
||||
`.forgejo/workflows/flatpak.yaml` runs for pull requests into `main`, when
|
||||
started by hand and for a pushed tag `X.Y.Z`: the sysroot, the tests,
|
||||
then the flatpak as in §4. Only a tag's run publishes: the flatpak to the
|
||||
Catcrafts repository (flatpak.catcrafts.net) as its `stable` branch, the
|
||||
app's `.flatpakref` beside the repository with the repository's key in
|
||||
it, and release `X.Y.Z` on the forge with the release notes, the bundle,
|
||||
that ref file and their `SHA256SUMS`; it keeps the bundle as an artifact
|
||||
as well. A push to `main` without a tag runs nothing.
|
||||
|
||||
Every push to `main` is a release, made by the signed tag pushed with it.
|
||||
The range's last commit has the new `version` (`ImsdMessages:Model`) and,
|
||||
at the top of the metainfo's `<releases>`, its `<release>` entry, dated
|
||||
the day of the push in UTC. The entry's description is the release notes:
|
||||
up to three sections, `<p>New</p>`, `<p>Fixes</p>` and `<p>Breaking</p>`
|
||||
in that order, each followed by a `<ul>` of its items. The owner signs the
|
||||
tag on the commit `main` is to receive, and both go out in one push:
|
||||
|
||||
```sh
|
||||
git tag -s X.Y.Z -m 'imsd-messages X.Y.Z'
|
||||
git push --atomic origin HEAD:main X.Y.Z
|
||||
```
|
||||
|
||||
`packaging/release-version.sh` prints a tree's version once the app's and
|
||||
the metainfo's agree and the notes render; CI runs it before it builds.
|
||||
For a tag it also checks that the tag is that version, that the forge has
|
||||
it on the run's commit as an annotated tag and verifies it as signed by
|
||||
the workflow's `RELEASE_SIGNER`, that the commit is on `main`, and that
|
||||
neither that version nor a newer one is released. Run it before tagging:
|
||||
without a pull request or a run started by hand, CI first sees a range at
|
||||
its tag. Release runs
|
||||
share the workflow's concurrency group and queue one behind another. A
|
||||
failed one can be run again while no newer release exists, once a release
|
||||
it left half made is deleted; when the fix needs a commit, that push is
|
||||
the next version's release.
|
||||
|
||||
Two jobs, by trust: `check` builds a pull request and a run by hand
|
||||
cold — no host volume, neither the repository nor its key; `publish`
|
||||
builds a pushed tag with the four volumes it mounts:
|
||||
`crafter-flatpak-org-system` (the crafter-build installation shared by
|
||||
every consumer repository's publish job on the runner — crafter-build
|
||||
`//stable` and its runtime; never mounted for a pull request's job),
|
||||
`crafter-flatpak-messages-cache` (this app's aarch64 Sdk,
|
||||
sysroot and build cache, kept between runs), `/var/www/flatpak` and
|
||||
`/etc/crafter-flatpak`. The last two are the repository and its signing
|
||||
key that Crafter.Build's workflow publishes with; that workflow writes the
|
||||
repository's `catcrafts.flatpakrepo`, and this one refuses to publish
|
||||
into a repository that is not there. Both jobs run on the Catcrafts
|
||||
organisation's privileged `flatpak` runner (a forgejo-runner on the
|
||||
Hetzner box that serves every repository), whose config must allow
|
||||
exactly those four volumes. The split is the workflow's own: a runner
|
||||
admits its volumes to every job it runs, so a pull request that edits
|
||||
the workflow can mount them. Forgejo holds the runs of a pull request
|
||||
whose author has no write access until someone who has approves them,
|
||||
and approving trusts all of it, not its `.forgejo/` diff alone: the
|
||||
workflow hands the repository's scripts and tests to an unprivileged
|
||||
user, which is no boundary — a step's code can add to the path of the
|
||||
steps after it, and those start as root in a privileged container.
|
||||
Approve once — an author approved always is not held again until that
|
||||
trust is revoked: by hand, with a block, or by the forge after three
|
||||
months without a pull request of theirs. The
|
||||
workflow uses no secret of the forge but the run's own token, which
|
||||
creates the release: the signing key is a file on the runner's host.
|
||||
|
||||
Crafter.Review's workflow publishes into that repository as well, and
|
||||
each of the three workflows holds an flock on
|
||||
`/var/www/flatpak/.publish.lock` while it commits and updates the
|
||||
summary.
|
||||
|
||||
## 6. Making changes
|
||||
|
||||
- Commit messages: subject `area: what changes`, the body says why; no AI
|
||||
attribution trailers; every commit GPG-signed with the repository's
|
||||
configured identity.
|
||||
- `format`, `lint` and `test` green before a push; every push goes through
|
||||
the fp6 project's `/prepush` gates.
|
||||
- `test` passing and `format --check` and `lint` reporting clean before a
|
||||
push; every push goes through the fp6 project's `/prepush` gates.
|
||||
- Every source file starts with the two SPDX lines and a blank line — after
|
||||
a shebang or an XML declaration where the file has one, as `#` comments in
|
||||
a desktop entry; the metainfo carries AppStream's single CC0-1.0 line
|
||||
instead.
|
||||
a desktop entry or a ref file; the metainfo carries AppStream's single
|
||||
CC0-1.0 line instead.
|
||||
- What a released copy leaves on a phone stays good across releases: the
|
||||
stored rows (a changed column is a version bump that keeps the old
|
||||
layout, Crafter.DB's rule) and the values of `Direction` and
|
||||
`MessageState` in them (a new one is appended); the conversation key (a
|
||||
changed `NormalizeNumber` rule re-keys the stored conversations from
|
||||
`peer`); the app id, and `imsd-messages --daemon`, which the login entry
|
||||
runs; and `org.freedesktop.Application` with its `quit` action on
|
||||
`/net/catcrafts/ImsdMessages` — after an update the old instance runs on
|
||||
until it restarts, and the new launcher forwards to it.
|
||||
|
|
|
|||
14
README.md
14
README.md
|
|
@ -6,10 +6,20 @@ app takes them; this is that app. It speaks imsd's
|
|||
`net.catcrafts.IMS1.Messaging` D-Bus interface: no ModemManager, no
|
||||
modem.
|
||||
|
||||
Nothing to install yet. The flatpak will come from the Catcrafts remote:
|
||||
Install the flatpak (aarch64) from the Catcrafts remote; its runtime comes
|
||||
from Flathub:
|
||||
|
||||
```sh
|
||||
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
|
||||
flatpak remote-add --if-not-exists catcrafts https://flatpak.catcrafts.net/catcrafts.flatpakrepo
|
||||
flatpak install catcrafts net.catcrafts.ImsdMessages
|
||||
```
|
||||
|
||||
It asks the desktop to start it at login without a window. To stop that:
|
||||
|
||||
```sh
|
||||
flatpak permission-set background background net.catcrafts.ImsdMessages no
|
||||
rm -f ~/.config/autostart/net.catcrafts.ImsdMessages.desktop
|
||||
```
|
||||
|
||||
## Building
|
||||
|
|
@ -22,6 +32,8 @@ crafter-build test # the unit tests
|
|||
crafter-build lint # the house-style rules
|
||||
```
|
||||
|
||||
The flatpak's build is in [AGENTS.md](AGENTS.md).
|
||||
|
||||
## License
|
||||
|
||||
GPL-3.0-only - see [LICENSE](LICENSE). The bundled font (Noto Sans) is under
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ import :Time;
|
|||
|
||||
export namespace ImsdMessages {
|
||||
// The app's version, for --version. A release bumps it and adds its
|
||||
// <release> to the metainfo, whose newest entry names this version.
|
||||
// <release> to the metainfo, whose newest entry names this version:
|
||||
// packaging/release-version.sh checks the two.
|
||||
inline constexpr std::string_view version = "0.0.0";
|
||||
|
||||
enum class Direction : std::uint8_t { Incoming, Outgoing };
|
||||
|
|
|
|||
14
packaging/net.catcrafts.ImsdMessages.flatpakref
Normal file
14
packaging/net.catcrafts.ImsdMessages.flatpakref
Normal 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
128
packaging/release-version.sh
Executable 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"
|
||||
Loading…
Reference in a new issue