Replaces the hand-written login/build/push/logout steps with ygg/actions/push-image@v2. Tags stay the same (X.Y.Z and latest, same image name); it adds OCI source/revision/created/version labels and logs in through a temporary DOCKER_CONFIG, so the registry token never touches the shared runner's ~/.docker. The job now exposes the version and digest as outputs, ready for a deploy job. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8.9 KiB
Release process & CI/CD
Shared reference for all three Tern repos (tern-server, tern-web, tern-android). Lives here because the server defines the API contract the clients build against, so it's the natural anchor.
1. Release cycle
Tag-driven, phase-paced, lockstep minor versions.
masteris always green. Every push runs CI (build + test + lint). Nothing publishes.- Tags publish. Pushing
v0.3.0to a repo triggers its release workflow. Nothing else does. - Cadence follows the build order, not the calendar. One minor release per completed phase from
server-architecture-spec.md§9 — sov0.3.0lands when the webapp read-only view is done,v0.4.0when sending works, and so on. A solo project doesn't benefit from date-based trains; it benefits from "this is the version where sending started working." - Patch releases (
v0.3.1) for fixes against a released phase, any time. - Stay on
0.xuntil the API is stable. Under semver,0.xexplicitly means breaking changes are allowed in minor bumps, which is honest about where this is.
Why lockstep minors across three repos
Server v0.4.x and web v0.4.x are known-compatible. That's the whole benefit: no compatibility matrix to maintain, no "which webapp works with which server" question when deploying at 1am.
The cost is version bumps in repos that didn't meaningfully change — web might jump 0.4.0 → 0.5.0 having only gained a version number. That's a real downside, and the alternative (independent versions plus a documented compatibility matrix) is more precise. For one developer deploying all three pieces to one server, the bookkeeping saved is worth more than the precision lost. Worth revisiting if the clients ever get released to people who don't control the server.
Suggested sequence for a release
# server first — it's the contract
cd server && git tag v0.4.0 && git push origin v0.4.0
# then clients, once the server image is published
cd ../web && git tag v0.4.0 && git push origin v0.4.0
cd ../android && git tag v0.4.0 && git push origin v0.4.0
Server first matters: a client release that expects an endpoint the deployed server doesn't have yet is the one ordering mistake that actually bites.
2. What each workflow produces
| Repo | On push to master |
On tag v* |
|---|---|---|
tern-server |
cargo fmt --check, clippy -D warnings, cargo test |
Docker image → Gitea registry, tagged :X.Y.Z and :latest |
tern-web |
svelte-check, vite build |
tern-web-X.Y.Z.tgz (+ .sha256) → Gitea release |
tern-android |
assembleDebug, assert no Play Services/Firebase |
Signed tern-X.Y.Z.apk (+ .sha256) → Gitea release |
The web .tgz archives the contents of dist/, so it untars straight into an nginx web root:
tar -xzf tern-web-0.4.0.tgz -C /var/www/tern
3. Android signing
This is the part with real consequences, because the signing key is permanent. Android identifies an app by package name plus signing certificate. Change the key and existing users can't upgrade in place — they must uninstall first, losing local cache and settings. There's no recovery path, and since Tern is self-distributed (sideloaded, not Play Store), there's no Play App Signing safety net either.
Options considered
| Approach | Pro | Con |
|---|---|---|
| A. Keystore in CI secrets (base64) | Fully automated releases | Key compromise if the Gitea instance or a runner is breached — and it's unrotatable |
| B. CI builds unsigned, you sign locally | Key never leaves your machine | Manual step per release; the published artifact isn't what CI built |
| C. Debug-key builds only | Zero setup | Well-known private key; anyone can forge an update. Not distributable |
Recommendation: A, with a dedicated key
The workflows implement A. The risk calculus is unusually favourable here: the Gitea instance is self-hosted on a private Yggdrasil mesh rather than a public CI service, so "attacker has your CI secrets" largely implies "attacker already has your server." Given that, the automation is worth more than the marginal key safety of B.
Two conditions make this safe enough:
- Generate a key used for nothing but Tern. Never reuse a key that signs anything else.
- Back the keystore up offline, outside Gitea — encrypted USB, password manager, paper. If you lose it, you lose the ability to ship upgrades to every existing install, permanently. This is the single most important sentence in this document.
If you'd rather have B, the change is small: drop the keystore steps and let the workflow publish app-release-unsigned.apk, then sign with apksigner sign locally before attaching.
One-time setup
keytool -genkeypair -v \
-keystore tern-release.jks \
-alias tern \
-keyalg RSA -keysize 4096 -validity 10000 \
-dname "CN=Tern, O=mtps, C=PL"
-validity 10000 (~27 years) is deliberate: an expired signing certificate means no more updates.
Then base64 it for the secret:
base64 -w0 tern-release.jks > tern-release.jks.b64
Add to the tern-android repo secrets: ANDROID_KEYSTORE_B64, ANDROID_KEYSTORE_PASSWORD, ANDROID_KEY_ALIAS (tern), ANDROID_KEY_PASSWORD.
Then delete tern-release.jks.b64 from disk and store the original .jks somewhere offline.
Guard rails already in the workflow
- Refuses to run if
ANDROID_KEYSTORE_B64is missing, rather than silently publishing something unsigned. - Runs
apksigner verify --print-certsafter the build and fails if the APK isn't properly signed. signingConfigresolves to null when no keystore is configured, so a localassembleReleaseproduces an unsigned APK rather than falling back to the debug key (a genuinely dangerous default).- Deletes the decoded keystore with
if: always(), so it doesn't survive a failed run.
versionCode
Derived from the tag: 0.3.1 → 301, 1.12.0 → 11200. Android requires versionCode to increase monotonically forever, and deriving it from the tag means it can't drift from the version users see. Note this caps minor and patch at 99 each — fine, and if 1.100.0 ever looms, switch to a commit count.
4. Prerequisites
All three workflows target runs-on: rocky-10 and follow the conventions already proven on that runner by the mtps/homepage pipeline: actions/checkout@v4, actions/setup-* to provision toolchains, akkuman/gitea-release-action@v1 for releases, and the automatic secrets.GITHUB_TOKEN. Nothing needs installing on the runner host — the setup actions handle Rust, Node, the JDK and the Android SDK.
What still needs doing, in order of how likely it is to bite:
REGISTRY_TOKENsecret ontern-server— a token withwrite:packagescope, for pushing the image. The automaticGITHUB_TOKENcan't push packages on this instance. The secret is passed to the sharedygg/actions/push-imageaction as an input, because actions can't read secrets themselves.- The container registry is enabled, and
gitea.server_urlmatches the registry host.push-imagederives the registry from it rather than hardcoding one, and pushesgit.app.ygg/mtps/tern-server. - Android signing secrets — see §3 above:
ANDROID_KEYSTORE_B64,ANDROID_KEYSTORE_PASSWORD,ANDROID_KEY_ALIAS,ANDROID_KEY_PASSWORD. docker buildavailable to the job — already proven on this runner.
Host packages on the runner
The runner executes jobs on the host, not in a container, so build toolchains that a container image would normally provide have to exist on the box. Rust needs a C toolchain for linking (every Rust build does, even pure-Rust crates — proc-macro build scripts get linked like anything else), and openssl-sys needs OpenSSL headers:
sudo dnf install -y gcc openssl-devel pkgconf-pkg-config unzip
(unzip is for the Android SDK's cmdline-tools, not Rust.)
This was found the direct way: the first CI run failed in 12 seconds with linker `cc` not found while compiling proc-macro2's build script.
openssl-devel is in there because async-native-tls → native-tls → openssl-sys links against system OpenSSL. It isn't needed yet at the point the build currently fails, but it's the very next thing that would break, so it's worth installing in the same command rather than discovering it on the next run.
Possible cleanup, not urgent: the project currently carries two TLS stacks — rustls (via sqlx, for Postgres) and OpenSSL (via async-native-tls, for IMAP). Switching the IMAP side to
tokio-rustlswould drop theopenssl-develdependency and leave one TLS implementation. Worth doing at some point for build simplicity; deliberately not done now because it's off the spec's build order and the TLS path has no integration test yet (the Greenmail test runs plaintext). If it happens, userustls-native-certsrather thanwebpki-roots, so a mail server using an internal CA keeps working.