ci: a merge to main is the public release; every dev push dry-runs it (#8358)
release / web (push) Successful in 1m29s
release / go (push) Successful in 1m54s
release / govulncheck (push) Successful in 18s
release / integration (push) Successful in 2m44s
release / android (push) Successful in 2m9s
release / Build signed APK (push) Successful in 2m1s
release / Build + push container image (push) Failing after 4s
release / web (push) Successful in 1m29s
release / go (push) Successful in 1m54s
release / govulncheck (push) Successful in 18s
release / integration (push) Successful in 2m44s
release / android (push) Successful in 2m9s
release / Build signed APK (push) Successful in 2m1s
release / Build + push container image (push) Failing after 4s
Every push now builds its image from the git archive export, after the changelog and the leak gate have run on it, so a dev push is the public release's dry run. A push to main then also commits and tags the export on github.com/Fabled-Sword/minstrel as AmateurDungeoneer, publishes ghcr.io/fabled-sword/minstrel :<name> and :latest, and creates the release page on GitHub (public changelog) and on this forge (private changelog). The scripts are Librarian's (ci/changelog.sh, ci/leakgate.sh, ci/releases.mjs, with their tests), with Minstrel's false positives and a changelog that ignores the forge-only v* tags from before the public releases, so the first public release is the fixed note. The tag build, its APK attach and its verify job, and the manual GHCR dispatch are gone: phones get the app from the server image, and no release carries a file. The push trigger has no path filter, because the README, docs and tests ship in the public release too. The README's image tags now name what GHCR carries: :latest and :<version>. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+233
-458
@@ -1,17 +1,20 @@
|
|||||||
name: release
|
name: release
|
||||||
|
|
||||||
# Builds and pushes the minstrel container image to the Gitea registry.
|
# Builds and pushes the minstrel container image to the Gitea registry, and on
|
||||||
|
# main also makes the public release.
|
||||||
#
|
#
|
||||||
# push to dev → :dev (freshly-built dev APK bundled)
|
# push to dev → :dev (freshly-built dev APK bundled), and the
|
||||||
# push to main → :latest + :<sha> (freshly-built stable APK bundled)
|
# public release's dry run
|
||||||
# push tag vYYYY.MM.DD.HHMM → :latest (fresh APK bundled, and attached to the Release)
|
# push to main → :latest + :<sha> (freshly-built stable APK bundled), then
|
||||||
# workflow_dispatch → manual trigger (same rules based on the ref)
|
# THE PUBLIC RELEASE: one commit and tag v<name> on
|
||||||
# workflow_dispatch, ghcr_release → ghcr.io/fabled-sword/minstrel:<version> + :latest,
|
# github.com/Fabled-Sword/minstrel, the image
|
||||||
# built from the public export (ghcr-release),
|
# ghcr.io/fabled-sword/minstrel :<name> + :latest, and a
|
||||||
# and nothing on the private registry
|
# release page with its changelog on both forges
|
||||||
|
# workflow_dispatch → the same as a push to the dispatched branch, private
|
||||||
|
# half only; force_red checks the gate (see below)
|
||||||
#
|
#
|
||||||
# That is the whole tag map. The rest of this header is about the private
|
# That is the whole tag map. The rest of this header is about the private
|
||||||
# registry; the public release image is described at ghcr-release.
|
# registry; the public release is described at image-release.
|
||||||
#
|
#
|
||||||
# :<sha> on main is the ROLLBACK UNIT — every production commit addressable
|
# :<sha> on main is the ROLLBACK UNIT — every production commit addressable
|
||||||
# without a release ceremony. It is minted only on main, where rollback is
|
# without a release ceremony. It is minted only on main, where rollback is
|
||||||
@@ -47,33 +50,24 @@ name: release
|
|||||||
#
|
#
|
||||||
# Every branch build carries the app built from its own commit, so a merge to
|
# Every branch build carries the app built from its own commit, so a merge to
|
||||||
# main is all it takes to put a new app in front of stable phones: `:latest`
|
# main is all it takes to put a new app in front of stable phones: `:latest`
|
||||||
# serves it from /api/client/apk and the in-app update offers it. A release
|
# serves it from /api/client/apk and the in-app update offers it. The app is
|
||||||
# is an optional bookmark — a named point in history with the APK attached
|
# never published on its own; it reaches phones only through the server.
|
||||||
# for download — never a step the app has to wait for.
|
|
||||||
#
|
#
|
||||||
# Release model: the tag IS the artifact's version name with a `v` in front.
|
# Release model: a merge to main IS the release. Its name is v<YYYY.MM.DD.HHMM>
|
||||||
# `v2026.09.10.1432` and `2026.09.10.1432` are the same string, derived from
|
# from the merge commit's UTC time, so every merge has its own. The run makes
|
||||||
# the tagged commit's UTC timestamp — so there is no mismatch to reconcile
|
# the tag on both forges; nobody tags by hand.
|
||||||
# between what the tag says and what the APK reports, and nothing to look up
|
|
||||||
# when minting one.
|
|
||||||
#
|
#
|
||||||
# TAGS ARE IMMUTABLE. Never move, retarget or delete a published tag. A
|
# TAGS ARE IMMUTABLE. Never move, retarget or delete a published tag. A re-run
|
||||||
# same-day second release is not a collision — HHMM makes every tag unique
|
# finds its tag already published: on the same tree it goes on, on another it
|
||||||
# by construction, so the answer is simply another tag. Anyone installing
|
# stops. A failed public half is fixed on dev, and the next merge carries a new
|
||||||
# from a moved tag would hold something the tag no longer points at, which
|
# name.
|
||||||
# is a worse failure than an extra row in the tag list.
|
|
||||||
#
|
#
|
||||||
# :latest is updated by every main push AND every tag push, so it always
|
# APK pipeline: on every push the android-release job builds + signs the
|
||||||
# reflects the newest blessed image.
|
# Android APK and uploads it as a workflow artifact. The image-release job
|
||||||
#
|
# declares `needs: android-release` and requires its success, so the docker
|
||||||
# APK pipeline: on every push — dev, main and tags alike — the
|
# image cannot start building until the APK is guaranteed-ready — no polling,
|
||||||
# android-release job builds + signs the Android APK and uploads it as a
|
# no race, no silent-failure mode, and no image that moves a channel without
|
||||||
# workflow artifact. The image-release job declares `needs: android-release`
|
# an app inside it.
|
||||||
# and requires its success, so the docker image cannot start building until
|
|
||||||
# the APK is guaranteed-ready — no polling, no race, no silent-failure mode,
|
|
||||||
# and no image that moves a channel without an app inside it. Attaching the
|
|
||||||
# APK to the gitea Release is its own job (release-assets), tags only, behind
|
|
||||||
# the test gate below.
|
|
||||||
#
|
#
|
||||||
# THE GATE. Every verifying lane lives in this file —
|
# THE GATE. Every verifying lane lives in this file —
|
||||||
# Go (vet, lint, short tests), the Postgres integration suite, the web app
|
# Go (vet, lint, short tests), the Postgres integration suite, the web app
|
||||||
@@ -92,42 +86,30 @@ name: release
|
|||||||
# path filters for the same reason: a web-only push still runs the Go suite,
|
# path filters for the same reason: a web-only push still runs the Go suite,
|
||||||
# because "not run" must never read as "passed".
|
# because "not run" must never read as "passed".
|
||||||
#
|
#
|
||||||
# What publishes, and is therefore gated: the image tags (image-release) and
|
# What publishes, and is therefore gated: everything image-release pushes, the
|
||||||
# the APK + version sidecar attached to a tag's Release (release-assets).
|
# private image tags and the whole public release. android-release only BUILDS
|
||||||
# android-release only BUILDS the signed APK into a workflow artifact, which
|
# the signed APK into a workflow artifact, which nobody outside this run can
|
||||||
# nobody outside this run can pull, so it runs in parallel with the lanes
|
# pull, so it runs in parallel with the lanes instead of after them.
|
||||||
# instead of after them; attaching it to the Release is the publishing half,
|
|
||||||
# and that half waits for the gate.
|
|
||||||
#
|
#
|
||||||
# To watch the gate refuse: dispatch this workflow with force_red=true. The go
|
# To watch the gate refuse: dispatch this workflow with force_red=true. The go
|
||||||
# lane fails on purpose, and both publishing jobs must report skipped.
|
# lane fails on purpose, and the publishing job must report skipped.
|
||||||
|
|
||||||
|
# No path filter. The README, docs and tests ship in the public release too,
|
||||||
|
# so a merge to main that changes only them must still run, or it would not
|
||||||
|
# release.
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main, dev]
|
branches: [main, dev]
|
||||||
tags: ['v*']
|
|
||||||
paths-ignore:
|
|
||||||
- 'docs/**'
|
|
||||||
- '**/*.md'
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
force_red:
|
force_red:
|
||||||
description: Fail the go lane on purpose, to check that nothing publishes on red
|
description: Fail the go lane on purpose, to check that nothing publishes on red
|
||||||
type: boolean
|
type: boolean
|
||||||
default: false
|
default: false
|
||||||
ghcr_release:
|
|
||||||
description: Build the public release image from the exported tree for GHCR (ghcr-release), instead of the private channel image
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
ghcr_dry_run:
|
|
||||||
description: With ghcr_release, build and check but push nothing. Untick only for the real release, run on main
|
|
||||||
type: boolean
|
|
||||||
default: true
|
|
||||||
|
|
||||||
# A rapid re-push to main supersedes the in-flight build: the later commit
|
# A rapid re-push to main supersedes the in-flight build: the later commit
|
||||||
# wins. Tags are immutable and unique, so no tag build can be superseded by
|
# wins. The event name is in the group so a dispatch and a push on the same
|
||||||
# another run on the same ref. The event name is in the group so a dispatch
|
# ref never cancel each other.
|
||||||
# and a push on the same ref never cancel each other.
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
@@ -454,12 +436,10 @@ jobs:
|
|||||||
|
|
||||||
android-release:
|
android-release:
|
||||||
name: Build signed APK
|
name: Build signed APK
|
||||||
# Builds on every ref, so each channel's image carries the app from its
|
# Builds on both branches, so each channel's image carries the app from
|
||||||
# own commit: `dev` for the test channel, `main` for stable phones, and a
|
# its own commit: `dev` for the test channel, `main` for stable phones.
|
||||||
# tag for the copy attached to its Release.
|
|
||||||
if: >-
|
if: >-
|
||||||
startsWith(github.ref, 'refs/tags/v')
|
github.ref == 'refs/heads/dev'
|
||||||
|| github.ref == 'refs/heads/dev'
|
|
||||||
|| github.ref == 'refs/heads/main'
|
|| github.ref == 'refs/heads/main'
|
||||||
runs-on: flutter-ci
|
runs-on: flutter-ci
|
||||||
container:
|
container:
|
||||||
@@ -523,32 +503,6 @@ jobs:
|
|||||||
echo "channel=${channel}" >> "$GITHUB_OUTPUT"
|
echo "channel=${channel}" >> "$GITHUB_OUTPUT"
|
||||||
echo "::notice::APK $(printf '%s' "${out}" | tr '\n' ' ') channel=${channel}"
|
echo "::notice::APK $(printf '%s' "${out}" | tr '\n' ' ') channel=${channel}"
|
||||||
|
|
||||||
# Checked BEFORE the expensive work, not after it. "Attach APK to gitea
|
|
||||||
# Release" below resolves the release by tag and fails if it is absent —
|
|
||||||
# but that is the final step, so a tag pushed without a release would
|
|
||||||
# build an APK for several minutes first and only then find it has
|
|
||||||
# nowhere to put it. Same check, seconds in instead of minutes.
|
|
||||||
#
|
|
||||||
# Releases are normally created through the API (which creates the tag and
|
|
||||||
# the release together, so this passes). A bare `git push origin vX` is the
|
|
||||||
# case this catches.
|
|
||||||
- name: Release must exist for this tag
|
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
|
||||||
shell: bash
|
|
||||||
working-directory: ${{ github.workspace }}
|
|
||||||
env:
|
|
||||||
CI_TOKEN: ${{ secrets.CI_TOKEN }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
TAG="${GITHUB_REF#refs/tags/}"
|
|
||||||
if ! curl -fsSL -o /dev/null \
|
|
||||||
-H "Authorization: token ${CI_TOKEN}" \
|
|
||||||
"https://git.fabledsword.com/api/v1/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG}"; then
|
|
||||||
echo "::error::no release exists for ${TAG}. Create the release (which creates the tag) rather than pushing a bare tag — otherwise there is nothing to attach the APK to."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "::notice::release found for ${TAG}"
|
|
||||||
|
|
||||||
- name: Cache Gradle dirs
|
- name: Cache Gradle dirs
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
@@ -629,98 +583,21 @@ jobs:
|
|||||||
# artifact existing, so an empty upload must fail here, not there.
|
# artifact existing, so an empty upload must fail here, not there.
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
# Publishes the signed APK and its version sidecar on the tag's Release.
|
# The image, and on main the public release.
|
||||||
# Split out of android-release so the APK can be BUILT in parallel with the
|
#
|
||||||
# lanes while being PUBLISHED only once they have all passed.
|
# Every push builds its image FROM THE EXPORT, `git archive` of this commit,
|
||||||
release-assets:
|
# and runs the changelog and the leak gate on it first. So a dev push is the
|
||||||
name: Attach APK to the Release (tag releases only)
|
# public release's dry run: an export that leaks or does not build is red the
|
||||||
needs: [go, integration, web, android, govulncheck, android-release]
|
# day it lands, not at the merge.
|
||||||
if: >-
|
#
|
||||||
${{
|
# A push to main is also the PUBLIC release, after the private push:
|
||||||
!cancelled()
|
# 1. the export becomes one commit on github.com/Fabled-Sword/minstrel's
|
||||||
&& needs.go.result == 'success'
|
# main, tagged v<name>, authored by AmateurDungeoneer and dated in UTC;
|
||||||
&& needs.integration.result == 'success'
|
# 2. that tree is built into ghcr.io/fabled-sword/minstrel :<name> and
|
||||||
&& needs.web.result == 'success'
|
# :latest, labelled with the public repository and commit;
|
||||||
&& needs.android.result == 'success'
|
# 3. a GitHub Release with the public changelog, and a release on this forge
|
||||||
&& needs.govulncheck.result == 'success'
|
# with the private one, both v<name>, both naming the image.
|
||||||
&& needs.android-release.result == 'success'
|
# <name> is YYYY.MM.DD.HHMM from the merge commit's time.
|
||||||
&& startsWith(github.ref, 'refs/tags/v') }}
|
|
||||||
runs-on: go-ci
|
|
||||||
container:
|
|
||||||
image: git.fabledsword.com/bvandeusen/ci-go:1.26
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Download signed APK artifact
|
|
||||||
uses: actions/download-artifact@v8
|
|
||||||
with:
|
|
||||||
name: minstrel-apk
|
|
||||||
path: release-apk/
|
|
||||||
|
|
||||||
- name: Attach APK to gitea Release
|
|
||||||
# Tag releases only. A branch build has no Release to hang assets on
|
|
||||||
# and does not need one — its image bundles the APK, and the server
|
|
||||||
# serves it from /api/client/apk.
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
CI_TOKEN: ${{ secrets.CI_TOKEN }}
|
|
||||||
VERSION_NAME: ${{ needs.android-release.outputs.version_name }}
|
|
||||||
VERSION_CODE: ${{ needs.android-release.outputs.version_code }}
|
|
||||||
run: |
|
|
||||||
set -euxo pipefail
|
|
||||||
TAG="${GITHUB_REF#refs/tags/}"
|
|
||||||
REPO="${GITHUB_REPOSITORY}"
|
|
||||||
APK_PATH="release-apk/app-release.apk"
|
|
||||||
ls -lh "${APK_PATH}"
|
|
||||||
|
|
||||||
# Publish the version sidecar as a release asset next to the APK.
|
|
||||||
#
|
|
||||||
# This is what lets a later :latest build stop RECONSTRUCTING the
|
|
||||||
# bundled APK's version and simply read what was recorded. The
|
|
||||||
# ordering key in particular cannot be re-derived after the fact —
|
|
||||||
# it is build-time minutes, so once this job ends the value exists
|
|
||||||
# nowhere else. Reconstruction could only ever recover the name,
|
|
||||||
# and only by duplicating a formula that then has to be kept in
|
|
||||||
# step across two files.
|
|
||||||
SIDECAR_PATH="/tmp/minstrel.apk.version"
|
|
||||||
printf '{"name":"%s","code":%s,"channel":"stable"}\n' \
|
|
||||||
"${VERSION_NAME}" "${VERSION_CODE}" > "${SIDECAR_PATH}"
|
|
||||||
cat "${SIDECAR_PATH}"
|
|
||||||
|
|
||||||
RELEASE_JSON="$(curl -fsSL \
|
|
||||||
-H "Authorization: token ${CI_TOKEN}" \
|
|
||||||
"https://git.fabledsword.com/api/v1/repos/${REPO}/releases/tags/${TAG}")"
|
|
||||||
RELEASE_ID="$(printf '%s' "${RELEASE_JSON}" | grep -oP '"id":\s*\K[0-9]+' | head -1)"
|
|
||||||
if [ -z "${RELEASE_ID}" ]; then
|
|
||||||
echo "::error::release for ${TAG} not found"; exit 1
|
|
||||||
fi
|
|
||||||
echo "release_id=${RELEASE_ID}"
|
|
||||||
|
|
||||||
UPLOAD_HTTP=$(curl -sS -L -o /tmp/upload.out -w '%{http_code}' \
|
|
||||||
-H "Authorization: token ${CI_TOKEN}" \
|
|
||||||
-F "attachment=@${APK_PATH}" \
|
|
||||||
"https://git.fabledsword.com/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets?name=minstrel-${TAG}.apk")
|
|
||||||
echo "upload_http=${UPLOAD_HTTP}"
|
|
||||||
cat /tmp/upload.out || true
|
|
||||||
echo
|
|
||||||
if [ "${UPLOAD_HTTP}" -lt 200 ] || [ "${UPLOAD_HTTP}" -ge 300 ]; then
|
|
||||||
echo "::error::APK upload returned HTTP ${UPLOAD_HTTP}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Same treatment for the sidecar. Named `.apk.version` so the
|
|
||||||
# downloader's `\.apk$` match cannot pick it up by mistake.
|
|
||||||
SIDECAR_HTTP=$(curl -sS -L -o /tmp/upload-sidecar.out -w '%{http_code}' \
|
|
||||||
-H "Authorization: token ${CI_TOKEN}" \
|
|
||||||
-F "attachment=@${SIDECAR_PATH}" \
|
|
||||||
"https://git.fabledsword.com/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets?name=minstrel-${TAG}.apk.version")
|
|
||||||
echo "sidecar_upload_http=${SIDECAR_HTTP}"
|
|
||||||
cat /tmp/upload-sidecar.out || true
|
|
||||||
echo
|
|
||||||
if [ "${SIDECAR_HTTP}" -lt 200 ] || [ "${SIDECAR_HTTP}" -ge 300 ]; then
|
|
||||||
echo "::error::version sidecar upload returned HTTP ${SIDECAR_HTTP}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
image-release:
|
image-release:
|
||||||
name: Build + push container image
|
name: Build + push container image
|
||||||
# Every lane must have SUCCEEDED, each named here, and so must the APK
|
# Every lane must have SUCCEEDED, each named here, and so must the APK
|
||||||
@@ -735,42 +612,29 @@ jobs:
|
|||||||
&& needs.web.result == 'success'
|
&& needs.web.result == 'success'
|
||||||
&& needs.android.result == 'success'
|
&& needs.android.result == 'success'
|
||||||
&& needs.govulncheck.result == 'success'
|
&& needs.govulncheck.result == 'success'
|
||||||
&& needs.android-release.result == 'success'
|
&& needs.android-release.result == 'success' }}
|
||||||
&& github.event.inputs.ghcr_release != 'true' }}
|
|
||||||
runs-on: go-ci
|
runs-on: go-ci
|
||||||
container:
|
container:
|
||||||
image: git.fabledsword.com/bvandeusen/ci-go:1.26
|
image: git.fabledsword.com/bvandeusen/ci-go:1.26
|
||||||
|
|
||||||
env:
|
env:
|
||||||
IMAGE: git.fabledsword.com/bvandeusen/minstrel
|
IMAGE: git.fabledsword.com/bvandeusen/minstrel
|
||||||
|
PUBLIC_REPO: Fabled-Sword/minstrel
|
||||||
|
PUBLIC_IMAGE: ghcr.io/fabled-sword/minstrel
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
# Full history: any job that DERIVES the version name needs it,
|
# Full history and its tags: any job that DERIVES the version name
|
||||||
# because a shallow clone changes what git-derived values resolve to
|
# needs it, because a shallow clone changes what git-derived values
|
||||||
# WITHOUT failing — a too-low value, silently, with every lane green.
|
# resolve to WITHOUT failing — a too-low value, silently, with every
|
||||||
#
|
# lane green. The changelog lists the commits since the previous
|
||||||
# This job runs ci/version.sh itself: with no :<version> image tags,
|
# release's tag, so it needs them too.
|
||||||
# the server's self-reported version is the only thing that says which
|
|
||||||
# build an image is.
|
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Detect buildable project
|
|
||||||
id: guard
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
if [ -f Dockerfile ] && [ -f go.mod ]; then
|
|
||||||
echo "ready=true" >> "$GITHUB_OUTPUT"
|
|
||||||
else
|
|
||||||
echo "ready=false" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "::notice::No Dockerfile + go.mod yet — release build skipped"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Compute image tags
|
- name: Compute image tags
|
||||||
id: tags
|
id: tags
|
||||||
if: steps.guard.outputs.ready == 'true'
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
@@ -778,10 +642,10 @@ jobs:
|
|||||||
# THE VERSION, and it is derived the same way on every ref — the
|
# THE VERSION, and it is derived the same way on every ref — the
|
||||||
# branch decides the CHANNEL, never the version.
|
# branch decides the CHANNEL, never the version.
|
||||||
#
|
#
|
||||||
# A per-ref string ("main", "dev", the tag name) would not order, and
|
# A per-ref string ("main", "dev") would not order, and "dev" would be
|
||||||
# "dev" would be the same string forever — two dev images eight weeks
|
# the same string forever — two dev images eight weeks apart
|
||||||
# apart indistinguishable in the UI. With no version image tags, this
|
# indistinguishable in the UI. The server's self-reported version is
|
||||||
# is how an admin tells which build a container is running.
|
# how an admin tells which build a private image is.
|
||||||
#
|
#
|
||||||
# `sed -n s///p` rather than `grep`: it exits 0 when nothing matches,
|
# `sed -n s///p` rather than `grep`: it exits 0 when nothing matches,
|
||||||
# so the empty check below is actually reachable. A grep here would
|
# so the empty check below is actually reachable. A grep here would
|
||||||
@@ -792,24 +656,7 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
|
if [[ "${GITHUB_REF}" == "refs/heads/dev" ]]; then
|
||||||
# A release refreshes the CHANNEL and mints nothing else.
|
|
||||||
#
|
|
||||||
# The tag build exists to produce the signed APK and attach it to
|
|
||||||
# the release; the image it rebuilds is the SAME SOURCE as the main
|
|
||||||
# build minutes earlier, differing only in which APK is baked in.
|
|
||||||
# When the same source is rebuilt with different contents,
|
|
||||||
# publish the moving channel tag and never a commit-addressable
|
|
||||||
# one.
|
|
||||||
#
|
|
||||||
# :latest moves here so the server hands out the same APK build
|
|
||||||
# that is attached to the Release: a phone that installed from the
|
|
||||||
# Release page and one that updated in-app hold one build, with one
|
|
||||||
# ordering key. Cut a release on main's tip, as :latest follows it.
|
|
||||||
CHANNEL=stable
|
|
||||||
echo "args=-t ${IMAGE}:latest" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "::notice::Release build ${VERSION}: refreshing :latest around the new APK"
|
|
||||||
elif [[ "${GITHUB_REF}" == "refs/heads/dev" ]]; then
|
|
||||||
# The rolling test channel, and :dev ALONE — deliberately no
|
# The rolling test channel, and :dev ALONE — deliberately no
|
||||||
# per-commit tag. A rolling channel is rolling by definition, so a
|
# per-commit tag. A rolling channel is rolling by definition, so a
|
||||||
# commit-addressable image here would be a rollback target nobody
|
# commit-addressable image here would be a rollback target nobody
|
||||||
@@ -830,8 +677,72 @@ jobs:
|
|||||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||||
echo "channel=${CHANNEL}" >> "$GITHUB_OUTPUT"
|
echo "channel=${CHANNEL}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
# The public release's name, and whether this run makes the release.
|
||||||
|
# Only a PUSH to main does: a dispatch on main rebuilds the private
|
||||||
|
# channel and publishes nothing outside this forge.
|
||||||
|
{
|
||||||
|
echo "EXPORT=${RUNNER_TEMP}/export"
|
||||||
|
echo "NAME=$(date -u -d "@$(git log -1 --format=%ct HEAD)" +%Y.%m.%d.%H%M)"
|
||||||
|
if [ "${GITHUB_EVENT_NAME}" = "push" ] && [ "${GITHUB_REF}" = "refs/heads/main" ]; then
|
||||||
|
echo "PUBLIC=true"
|
||||||
|
else
|
||||||
|
echo "PUBLIC=false"
|
||||||
|
fi
|
||||||
|
} >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
# What a release would publish: the export, and its changelog. Neither
|
||||||
|
# may carry a banned word or a private record id (ci/leakgate.sh), and the
|
||||||
|
# export carries no CI file.
|
||||||
|
- name: Export, changelog and leak gate
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
rm -rf "${EXPORT}"
|
||||||
|
mkdir -p "${EXPORT}"
|
||||||
|
git archive HEAD | tar -x -C "${EXPORT}"
|
||||||
|
for private in .gitea .forgejo .github ci ci-requirements.md .gitattributes renovate.json; do
|
||||||
|
if [ -e "${EXPORT}/${private}" ]; then
|
||||||
|
echo "::error::the export carries ${private}; .gitattributes export-ignore no longer covers it"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
bash ci/changelog.sh "${RUNNER_TEMP}/changelog"
|
||||||
|
echo "--- the public changelog of v${NAME} ---"
|
||||||
|
cat "${RUNNER_TEMP}/changelog/public.md"
|
||||||
|
echo "---"
|
||||||
|
bash ci/leakgate.sh "${EXPORT}" "${RUNNER_TEMP}/changelog/public.md"
|
||||||
|
|
||||||
|
# The secrets the public half needs, checked before anything is pushed
|
||||||
|
# anywhere. A dev push warns about one that is missing or refused; a main
|
||||||
|
# push stops. Nothing here writes: the push token reads the public
|
||||||
|
# repository, and the forge token updates a release that does not exist.
|
||||||
|
- name: Public release secrets
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
PUBLIC_PUSH_TOKEN: ${{ secrets.PUBLIC_PUSH_TOKEN }}
|
||||||
|
GHCR_USER: ${{ vars.GHCR_USER || secrets.GHCR_USER }}
|
||||||
|
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
|
||||||
|
FORGE_TOKEN: ${{ secrets.CI_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -u
|
||||||
|
bad=""
|
||||||
|
say() { bad="yes"; if [ "${PUBLIC}" = "true" ]; then echo "::error::$1"; else echo "::warning::$1"; fi; }
|
||||||
|
[ -n "${GHCR_USER}" ] || say "GHCR_USER is empty or unset (an Actions variable or secret)"
|
||||||
|
[ -n "${GHCR_TOKEN}" ] || say "the GHCR_TOKEN secret is empty or unset"
|
||||||
|
if [ -z "${PUBLIC_PUSH_TOKEN}" ]; then
|
||||||
|
say "the PUBLIC_PUSH_TOKEN secret is empty or unset"
|
||||||
|
else
|
||||||
|
auth="$(printf 'x-access-token:%s' "${PUBLIC_PUSH_TOKEN}" | base64 -w0)"
|
||||||
|
echo "::add-mask::${auth}"
|
||||||
|
git -c http.https://github.com/.extraheader="AUTHORIZATION: basic ${auth}" \
|
||||||
|
ls-remote "https://github.com/${PUBLIC_REPO}.git" >/dev/null \
|
||||||
|
|| say "PUBLIC_PUSH_TOKEN cannot read github.com/${PUBLIC_REPO}"
|
||||||
|
fi
|
||||||
|
node ci/releases.mjs forge-probe || say "CI_TOKEN may not write this repository's releases"
|
||||||
|
if [ -n "${bad}" ] && [ "${PUBLIC}" = "true" ]; then exit 1; fi
|
||||||
|
exit 0
|
||||||
|
|
||||||
- name: Registry login
|
- name: Registry login
|
||||||
if: steps.guard.outputs.ready == 'true'
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.CI_TOKEN }}" \
|
echo "${{ secrets.CI_TOKEN }}" \
|
||||||
@@ -839,7 +750,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Download signed APK artifact
|
- name: Download signed APK artifact
|
||||||
# android-release just produced this, on every ref.
|
# android-release just produced this, on every ref.
|
||||||
if: steps.guard.outputs.ready == 'true'
|
|
||||||
# Consuming half of the pair: stock download-artifact, which works here for
|
# Consuming half of the pair: stock download-artifact, which works here for
|
||||||
# the same reason as the upload (gitea/runner 3.x edits the GHES refusal
|
# the same reason as the upload (gitea/runner 3.x edits the GHES refusal
|
||||||
# out of the bundle). v8 runs on node24, which every CI-runner image
|
# out of the bundle). v8 runs on node24, which every CI-runner image
|
||||||
@@ -849,8 +759,8 @@ jobs:
|
|||||||
name: minstrel-apk
|
name: minstrel-apk
|
||||||
path: client/
|
path: client/
|
||||||
|
|
||||||
|
# Into the export, which is what the image is built from.
|
||||||
- name: Stage bundled APK + version sidecar
|
- name: Stage bundled APK + version sidecar
|
||||||
if: steps.guard.outputs.ready == 'true'
|
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
# All three pulled from android-release's outputs so the sidecar the
|
# All three pulled from android-release's outputs so the sidecar the
|
||||||
@@ -864,15 +774,15 @@ jobs:
|
|||||||
# The artifact lands as `app-release.apk` (the original Gradle
|
# The artifact lands as `app-release.apk` (the original Gradle
|
||||||
# output name). The Dockerfile COPYs client/* into /app/client/
|
# output name). The Dockerfile COPYs client/* into /app/client/
|
||||||
# and the server reads minstrel.apk + minstrel.apk.version.
|
# and the server reads minstrel.apk + minstrel.apk.version.
|
||||||
mv client/app-release.apk client/minstrel.apk
|
mv client/app-release.apk "${EXPORT}/client/minstrel.apk"
|
||||||
printf '{"name":"%s","code":%s,"channel":"%s"}\n' \
|
printf '{"name":"%s","code":%s,"channel":"%s"}\n' \
|
||||||
"${APK_VERSION_NAME}" "${APK_VERSION_CODE}" "${APK_CHANNEL}" \
|
"${APK_VERSION_NAME}" "${APK_VERSION_CODE}" "${APK_CHANNEL}" \
|
||||||
> client/minstrel.apk.version
|
> "${EXPORT}/client/minstrel.apk.version"
|
||||||
cat client/minstrel.apk.version
|
cat "${EXPORT}/client/minstrel.apk.version"
|
||||||
ls -lh client/
|
ls -lh "${EXPORT}/client/"
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
if: steps.guard.outputs.ready == 'true'
|
shell: bash
|
||||||
# --pull: the Dockerfile's base images are floating tags (golang:1.26,
|
# --pull: the Dockerfile's base images are floating tags (golang:1.26,
|
||||||
# debian:bookworm-slim). Without it the runner's daemon reuses
|
# debian:bookworm-slim). Without it the runner's daemon reuses
|
||||||
# whatever it cached, and the shipped binary can sit on a Go patch
|
# whatever it cached, and the shipped binary can sit on a Go patch
|
||||||
@@ -882,262 +792,127 @@ jobs:
|
|||||||
docker buildx build --pull \
|
docker buildx build --pull \
|
||||||
--build-arg MINSTREL_VERSION="${{ steps.tags.outputs.version }}" \
|
--build-arg MINSTREL_VERSION="${{ steps.tags.outputs.version }}" \
|
||||||
--build-arg MINSTREL_CHANNEL="${{ steps.tags.outputs.channel }}" \
|
--build-arg MINSTREL_CHANNEL="${{ steps.tags.outputs.channel }}" \
|
||||||
--push ${{ steps.tags.outputs.args }} .
|
--push ${{ steps.tags.outputs.args }} "${EXPORT}"
|
||||||
|
|
||||||
# The public release image, process #7881's release step 4.
|
# THE PUBLIC RELEASE, a push to main only. The export becomes one commit
|
||||||
#
|
# on the public repository's main, replacing its whole tree so removed
|
||||||
# Runs only on a dispatch with ghcr_release ticked, never on a push. It
|
# files go too, tagged v<name>. Author, committer and tagger are the
|
||||||
# builds from `git archive HEAD`, the same tree the public repo's release
|
# project's public identity, dated at this commit's time in UTC.
|
||||||
# commit holds, so nothing export-ignored (.gitea/, ci/) reaches the
|
#
|
||||||
# image's build context, and the image's labels name the public repo and
|
# A re-run finds v<name> already there: on the same tree it goes on to the
|
||||||
# the public commit rather than this workbench.
|
# image and the releases, on a different tree it stops. A published tag
|
||||||
#
|
# is never moved.
|
||||||
# Tags: :<version> (rule 149's name, v<name> is the public git tag) and
|
- name: Public commit and tag
|
||||||
# :latest. :<version> is pushed once and never re-pushed; a re-run only
|
if: env.PUBLIC == 'true'
|
||||||
# moves :latest. The private registry gets nothing from this job.
|
|
||||||
#
|
|
||||||
# ghcr_dry_run (the default) builds and checks everything and pushes
|
|
||||||
# nothing, so the job can be proved on dev before a release exists. A real
|
|
||||||
# run must be on main and needs the public tag to exist already: the
|
|
||||||
# exported tree is compared with the tag's tree and refused on a mismatch.
|
|
||||||
ghcr-release:
|
|
||||||
name: Publish the release image to GHCR (dispatch only)
|
|
||||||
needs: [go, integration, web, android, govulncheck, android-release]
|
|
||||||
if: >-
|
|
||||||
${{
|
|
||||||
!cancelled()
|
|
||||||
&& github.event_name == 'workflow_dispatch'
|
|
||||||
&& github.event.inputs.ghcr_release == 'true'
|
|
||||||
&& needs.go.result == 'success'
|
|
||||||
&& needs.integration.result == 'success'
|
|
||||||
&& needs.web.result == 'success'
|
|
||||||
&& needs.android.result == 'success'
|
|
||||||
&& needs.govulncheck.result == 'success'
|
|
||||||
&& needs.android-release.result == 'success' }}
|
|
||||||
runs-on: go-ci
|
|
||||||
container:
|
|
||||||
image: git.fabledsword.com/bvandeusen/ci-go:1.26
|
|
||||||
|
|
||||||
env:
|
|
||||||
PUBLIC_IMAGE: ghcr.io/fabled-sword/minstrel
|
|
||||||
PUBLIC_REPO: https://github.com/Fabled-Sword/minstrel
|
|
||||||
# Anything but an explicit false is a dry run.
|
|
||||||
DRY_RUN: ${{ github.event.inputs.ghcr_dry_run != 'false' }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
# Full history: ci/version.sh derives the name from commit times.
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Name the release
|
|
||||||
id: name
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
VERSION="$(ci/version.sh HEAD | sed -n 's/^name=//p')"
|
|
||||||
if [ -z "${VERSION}" ]; then
|
|
||||||
echo "::error::could not derive a release name from ci/version.sh"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ "${DRY_RUN}" != "true" ] && [ "${GITHUB_REF}" != "refs/heads/main" ]; then
|
|
||||||
echo "::error::a real GHCR release runs on main; this is ${GITHUB_REF}. Dispatch on main, or leave ghcr_dry_run ticked."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "tag=v${VERSION}" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "::notice::Release ${VERSION} (public tag v${VERSION}), dry run: ${DRY_RUN}"
|
|
||||||
|
|
||||||
- name: Export the public tree and match it to the public tag
|
|
||||||
id: export
|
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
TAG: ${{ steps.name.outputs.tag }}
|
PUBLIC_PUSH_TOKEN: ${{ secrets.PUBLIC_PUSH_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
EXPORT="${RUNNER_TEMP}/export"
|
auth="$(printf 'x-access-token:%s' "${PUBLIC_PUSH_TOKEN}" | base64 -w0)"
|
||||||
rm -rf "${EXPORT}"
|
echo "::add-mask::${auth}"
|
||||||
mkdir -p "${EXPORT}"
|
pub="${RUNNER_TEMP}/public"
|
||||||
git archive HEAD | tar -x -C "${EXPORT}"
|
rm -rf "${pub}"
|
||||||
for private in .gitea ci ci-requirements.md; do
|
git init -q -b main "${pub}"
|
||||||
if [ -e "${EXPORT}/${private}" ]; then
|
cd "${pub}"
|
||||||
echo "::error::the export carries ${private}; .gitattributes export-ignore no longer covers it"
|
git config http.https://github.com/.extraheader "AUTHORIZATION: basic ${auth}"
|
||||||
exit 1
|
git remote add origin "https://github.com/${PUBLIC_REPO}.git"
|
||||||
fi
|
# An empty repository has no main yet, and its first release starts it.
|
||||||
done
|
if [ -n "$(git ls-remote --heads origin main)" ]; then
|
||||||
|
git fetch -q --depth 1 origin main
|
||||||
# The tree hash of exactly what was exported. -f because some
|
git checkout -q -B main FETCH_HEAD
|
||||||
# tracked files are also ignored (android/.idea, the generated token
|
fi
|
||||||
# CSS): the public commit has to be staged with -f too, or it drops
|
find . -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
|
||||||
# them and this match refuses the release.
|
# A fresh archive, not the build context, which also holds the app.
|
||||||
cd "${EXPORT}"
|
git -C "${GITHUB_WORKSPACE}" archive HEAD | tar -xf -
|
||||||
git init -q
|
# -f: the export exactly, a tracked file a .gitignore matches
|
||||||
|
# (the generated token CSS) included.
|
||||||
git add -A -f
|
git add -A -f
|
||||||
TREE="$(git write-tree)"
|
tree="$(git write-tree)"
|
||||||
echo "::notice::export tree ${TREE}"
|
when="@$(git -C "${GITHUB_WORKSPACE}" log -1 --format=%ct HEAD) +0000"
|
||||||
|
if [ -n "$(git ls-remote --tags origin "refs/tags/v${NAME}")" ]; then
|
||||||
if git fetch -q --depth 1 "${PUBLIC_REPO}" "refs/tags/${TAG}:refs/tags/${TAG}" 2>/dev/null; then
|
git fetch -q --depth 1 origin "refs/tags/v${NAME}:refs/tags/v${NAME}"
|
||||||
PUBLIC_TREE="$(git rev-parse "${TAG}^{tree}")"
|
if [ "$(git rev-parse "v${NAME}^{tree}")" != "${tree}" ]; then
|
||||||
REVISION="$(git rev-parse "${TAG}^{commit}")"
|
echo "::error::the public tag v${NAME} holds another tree; a published tag is never moved"
|
||||||
if [ "${PUBLIC_TREE}" != "${TREE}" ]; then
|
|
||||||
echo "::error::${PUBLIC_REPO} tag ${TAG} holds tree ${PUBLIC_TREE}, but this commit exports ${TREE}. The public release commit is not this export."
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "::notice::public ${TAG} is commit ${REVISION}, and its tree matches the export"
|
echo "::notice::v${NAME} is already published with this tree"
|
||||||
elif [ "${DRY_RUN}" = "true" ]; then
|
|
||||||
REVISION=unreleased
|
|
||||||
echo "::notice::${TAG} is not on ${PUBLIC_REPO} yet; a dry run labels the image revision=unreleased"
|
|
||||||
else
|
else
|
||||||
echo "::error::${TAG} is not on ${PUBLIC_REPO}. Push the public release commit and its tag first (#8209), then run this."
|
export GIT_AUTHOR_NAME=AmateurDungeoneer GIT_AUTHOR_EMAIL=amateurdungeoneer@fabledsword.com
|
||||||
exit 1
|
export GIT_COMMITTER_NAME=AmateurDungeoneer GIT_COMMITTER_EMAIL=amateurdungeoneer@fabledsword.com
|
||||||
|
export GIT_AUTHOR_DATE="${when}" GIT_COMMITTER_DATE="${when}"
|
||||||
|
git commit -q -m "Release ${NAME}"
|
||||||
|
git tag -a "v${NAME}" -m "Release ${NAME}"
|
||||||
|
git push -q origin main "refs/tags/v${NAME}"
|
||||||
fi
|
fi
|
||||||
rm -rf .git
|
echo "REVISION=$(git rev-parse "v${NAME}^{commit}")" >> "$GITHUB_ENV"
|
||||||
echo "dir=${EXPORT}" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "revision=${REVISION}" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Download signed APK artifact
|
# The same export, built again with the release's name and labels that
|
||||||
uses: actions/download-artifact@v8
|
# point at the public repository and commit, so nothing in the image
|
||||||
with:
|
# points back here. Every layer but the stamped binary comes from the
|
||||||
name: minstrel-apk
|
# build above. --provenance=false and no SBOM: an attestation would carry
|
||||||
path: client/
|
# this workbench's build details into a public registry.
|
||||||
|
- name: Public image
|
||||||
- name: Stage the APK and its version sidecar into the export
|
if: env.PUBLIC == 'true'
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
APK_VERSION_NAME: ${{ needs.android-release.outputs.version_name }}
|
|
||||||
APK_VERSION_CODE: ${{ needs.android-release.outputs.version_code }}
|
|
||||||
APK_CHANNEL: ${{ needs.android-release.outputs.channel }}
|
|
||||||
EXPORT: ${{ steps.export.outputs.dir }}
|
|
||||||
run: |
|
|
||||||
set -euxo pipefail
|
|
||||||
mv client/app-release.apk "${EXPORT}/client/minstrel.apk"
|
|
||||||
printf '{"name":"%s","code":%s,"channel":"%s"}\n' \
|
|
||||||
"${APK_VERSION_NAME}" "${APK_VERSION_CODE}" "${APK_CHANNEL}" \
|
|
||||||
> "${EXPORT}/client/minstrel.apk.version"
|
|
||||||
cat "${EXPORT}/client/minstrel.apk.version"
|
|
||||||
|
|
||||||
- name: Build the release image from the export
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
VERSION: ${{ steps.name.outputs.version }}
|
|
||||||
REVISION: ${{ steps.export.outputs.revision }}
|
|
||||||
CHANNEL: ${{ needs.android-release.outputs.channel }}
|
|
||||||
EXPORT: ${{ steps.export.outputs.dir }}
|
|
||||||
# --provenance=false and no SBOM: an attestation would carry the
|
|
||||||
# workbench's build details into a public registry.
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
docker build --pull --provenance=false \
|
|
||||||
--build-arg MINSTREL_VERSION="${VERSION}" \
|
|
||||||
--build-arg MINSTREL_CHANNEL="${CHANNEL}" \
|
|
||||||
--label org.opencontainers.image.source="${PUBLIC_REPO}" \
|
|
||||||
--label org.opencontainers.image.revision="${REVISION}" \
|
|
||||||
--label org.opencontainers.image.version="${VERSION}" \
|
|
||||||
-t "${PUBLIC_IMAGE}:${VERSION}" -t "${PUBLIC_IMAGE}:latest" \
|
|
||||||
"${EXPORT}"
|
|
||||||
docker image inspect --format '{{json .Config.Labels}}' "${PUBLIC_IMAGE}:${VERSION}"
|
|
||||||
|
|
||||||
- name: Push to GHCR
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
VERSION: ${{ steps.name.outputs.version }}
|
|
||||||
# GHCR_USER is read from an Actions variable, or from a secret of
|
|
||||||
# that name where no variable reaches the job.
|
|
||||||
GHCR_USER: ${{ vars.GHCR_USER || secrets.GHCR_USER }}
|
GHCR_USER: ${{ vars.GHCR_USER || secrets.GHCR_USER }}
|
||||||
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
|
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
if [ "${DRY_RUN}" = "true" ]; then
|
docker build --provenance=false \
|
||||||
echo "::notice::dry run: ${PUBLIC_IMAGE}:${VERSION} and :latest built, nothing pushed"
|
--build-arg MINSTREL_VERSION="${NAME}" \
|
||||||
exit 0
|
--build-arg MINSTREL_CHANNEL=stable \
|
||||||
fi
|
--label "org.opencontainers.image.source=https://github.com/${PUBLIC_REPO}" \
|
||||||
if [ -z "${GHCR_USER}" ]; then echo "::error::GHCR_USER is empty: set it as an Actions variable or secret"; exit 1; fi
|
--label "org.opencontainers.image.revision=${REVISION}" \
|
||||||
if [ -z "${GHCR_TOKEN}" ]; then echo "::error::the Actions secret GHCR_TOKEN is empty"; exit 1; fi
|
--label "org.opencontainers.image.version=${NAME}" \
|
||||||
|
-t "${PUBLIC_IMAGE}:${NAME}" "${EXPORT}"
|
||||||
|
labelled="$(docker inspect --format '{{ index .Config.Labels "org.opencontainers.image.revision" }}' "${PUBLIC_IMAGE}:${NAME}")"
|
||||||
|
test "${labelled}" = "${REVISION}" || { echo "::error::the image names commit ${labelled}, not ${REVISION}"; exit 1; }
|
||||||
printf '%s' "${GHCR_TOKEN}" | docker login ghcr.io -u "${GHCR_USER}" --password-stdin
|
printf '%s' "${GHCR_TOKEN}" | docker login ghcr.io -u "${GHCR_USER}" --password-stdin
|
||||||
if docker manifest inspect "${PUBLIC_IMAGE}:${VERSION}" > /dev/null 2>&1; then
|
# :<name> is never re-pushed, so a re-run only moves :latest.
|
||||||
echo "::notice::${PUBLIC_IMAGE}:${VERSION} is already published and is never re-pushed; moving :latest only"
|
if docker manifest inspect "${PUBLIC_IMAGE}:${NAME}" >/dev/null 2>&1; then
|
||||||
|
echo "::notice::${PUBLIC_IMAGE}:${NAME} is already published; only :latest moves"
|
||||||
else
|
else
|
||||||
docker push "${PUBLIC_IMAGE}:${VERSION}"
|
docker push "${PUBLIC_IMAGE}:${NAME}"
|
||||||
fi
|
fi
|
||||||
|
docker tag "${PUBLIC_IMAGE}:${NAME}" "${PUBLIC_IMAGE}:latest"
|
||||||
docker push "${PUBLIC_IMAGE}:latest"
|
docker push "${PUBLIC_IMAGE}:latest"
|
||||||
docker image inspect --format '{{json .RepoDigests}}' "${PUBLIC_IMAGE}:${VERSION}"
|
echo "DIGEST=$(docker inspect --format '{{ index .RepoDigests 0 }}' "${PUBLIC_IMAGE}:${NAME}")" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
# Verifies a tag release actually ended up complete, and names the specific
|
# The release pages, each created or updated in place: GitHub's with the
|
||||||
# thing that's missing if not.
|
# public changelog, this forge's with the private one, tagging this
|
||||||
#
|
# commit. Both name the image. No files are attached: the app ships
|
||||||
# A release can be incomplete while looking fine. If android-release never
|
# inside the image.
|
||||||
# starts (a runner failing to launch), its steps all report `failure` with
|
- name: Public and private releases
|
||||||
# none executed and image-release shows `skipped`. The run is red, but the
|
if: env.PUBLIC == 'true'
|
||||||
# release page renders and main's own push build has already moved
|
|
||||||
# `:latest`, so a release missing its APK and its image is easy to skim
|
|
||||||
# past.
|
|
||||||
#
|
|
||||||
# This job cannot prevent that; it turns an incomplete release into an
|
|
||||||
# explicit, named error instead of a row of mystery step failures.
|
|
||||||
#
|
|
||||||
# `if: always()` is the whole point: it has to report precisely when the jobs
|
|
||||||
# above did NOT succeed.
|
|
||||||
verify-release:
|
|
||||||
name: Verify release artifacts (tag releases only)
|
|
||||||
needs: [android-release, release-assets, image-release]
|
|
||||||
if: ${{ always() && startsWith(github.ref, 'refs/tags/v') }}
|
|
||||||
runs-on: go-ci
|
|
||||||
container:
|
|
||||||
image: git.fabledsword.com/bvandeusen/ci-go:1.26
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Release must have an APK attached
|
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
CI_TOKEN: ${{ secrets.CI_TOKEN }}
|
PUBLIC_PUSH_TOKEN: ${{ secrets.PUBLIC_PUSH_TOKEN }}
|
||||||
|
FORGE_TOKEN: ${{ secrets.CI_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
TAG="${GITHUB_REF#refs/tags/}"
|
cl="${RUNNER_TEMP}/changelog"
|
||||||
REPO="${GITHUB_REPOSITORY}"
|
for side in public private; do
|
||||||
|
{
|
||||||
|
cat "${cl}/${side}.md"
|
||||||
|
printf '\nImage: `%s:%s`\n' "${PUBLIC_IMAGE}" "${NAME}"
|
||||||
|
} > "${cl}/${side}-body.md"
|
||||||
|
done
|
||||||
|
echo "GITHUB_RELEASE=$(node ci/releases.mjs github "v${NAME}" "${cl}/public-body.md")" >> "$GITHUB_ENV"
|
||||||
|
echo "FORGE_RELEASE=$(node ci/releases.mjs forge "v${NAME}" "${cl}/private-body.md" "${GITHUB_SHA}")" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
REL_JSON="$(curl -fsSL \
|
# The record the release task keeps.
|
||||||
-H "Authorization: token ${CI_TOKEN}" \
|
- name: Published
|
||||||
"https://git.fabledsword.com/api/v1/repos/${REPO}/releases/tags/${TAG}" || true)"
|
|
||||||
if [ -z "${REL_JSON}" ]; then
|
|
||||||
echo "::error::no release found for ${TAG} — the tag exists but nothing was published"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
APK="$(printf '%s' "${REL_JSON}" \
|
|
||||||
| grep -oP '"browser_download_url":\s*"\K[^"]+' \
|
|
||||||
| grep -E '\.apk$' | head -1 || true)"
|
|
||||||
if [ -z "${APK}" ]; then
|
|
||||||
echo "::error::release ${TAG} has NO APK attached — in-app update will offer nothing, and the bundled-APK path on future :latest builds has no source."
|
|
||||||
echo "::error::Fix by RE-RUNNING this workflow run. Do NOT delete and re-create the tag; if it fails again the runner never started the container, and the evidence is in act_runner on the host (Gitea will hold no job log)."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "::notice::APK attached: ${APK}"
|
|
||||||
|
|
||||||
# The other half. Checking only the APK would report success on a release
|
|
||||||
# whose image push failed. `always()` on this job means it runs even when
|
|
||||||
# image-release failed, so without this the guard would cheerfully verify
|
|
||||||
# an incomplete release.
|
|
||||||
#
|
|
||||||
# The image checked is the :<sha> rollback target, which main's own build
|
|
||||||
# published for this same commit before the tag was cut (there are no
|
|
||||||
# version image tags). It catches an image push that silently did not
|
|
||||||
# happen, and it proves the ORDERING — a tag cut on a commit whose main
|
|
||||||
# build never completed has no rollback target, and that is worth failing
|
|
||||||
# on rather than discovering during an incident.
|
|
||||||
- name: Rollback image must exist for the tagged commit
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
echo "pushed ${{ steps.tags.outputs.args }}"
|
||||||
IMAGE="git.fabledsword.com/bvandeusen/minstrel"
|
if [ "${PUBLIC}" = "true" ]; then
|
||||||
|
echo "release v${NAME} of workbench ${GITHUB_SHA}"
|
||||||
echo "${{ secrets.CI_TOKEN }}" \
|
echo "public commit ${REVISION}"
|
||||||
| docker login git.fabledsword.com -u "${{ github.actor }}" --password-stdin
|
echo "image ${DIGEST}"
|
||||||
|
echo "GitHub release ${GITHUB_RELEASE}"
|
||||||
if ! docker manifest inspect "${IMAGE}:${GITHUB_SHA}" > /dev/null 2>&1; then
|
echo "forge release ${FORGE_RELEASE}"
|
||||||
echo "::error::image ${IMAGE}:${GITHUB_SHA} does not exist — this commit has no rollback target."
|
else
|
||||||
echo "::error::That image is published by the MAIN build of this commit, not by the tag build. If main's build never ran or failed, fix that first; a release whose commit cannot be rolled back to is the thing this check exists to refuse."
|
echo "dry run of release v${NAME}: export, changelog and leak gate passed, image built from the export"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
echo "::notice::rollback target verified: ${IMAGE}:${GITHUB_SHA}"
|
|
||||||
|
|||||||
@@ -87,11 +87,10 @@ docker compose pull && docker compose up -d
|
|||||||
|
|
||||||
Database migrations run at startup. Image tags:
|
Database migrations run at startup. Image tags:
|
||||||
|
|
||||||
- `:latest`: the stable release. Most people should run this.
|
- `:latest`: the newest release. Most people should run this.
|
||||||
- `:<commit-sha>`: one fixed build. Pin one to stop updates, or to roll back.
|
- `:<version>`, such as `:2026.12.04.1530`: one release, which never changes. Pin one to stop updates, or to roll back. The [releases page](https://github.com/Fabled-Sword/minstrel/releases) lists each one with what changed.
|
||||||
- `:dev`: the test channel, rebuilt on every change. It may break, and the fix is the next build.
|
|
||||||
|
|
||||||
Every image carries a signed Android app, all with the same key, so a phone can move between channels without reinstalling. Rolling back a SHA tag rolls back the app it carries too.
|
Every image carries a signed Android app, all with the same key, so a phone can move between versions without reinstalling. Rolling back to an older version rolls back the app it carries too.
|
||||||
|
|
||||||
**Back up the Postgres volume** with `pg_dump`. It holds accounts, likes, play history, playlists and settings, and a migration can only be undone by restoring a dump. The `minstrel-data` volume holds artwork and caches that Minstrel rebuilds if lost.
|
**Back up the Postgres volume** with `pg_dump`. It holds accounts, likes, play history, playlists and settings, and a migration can only be undone by restoring a dump. The `minstrel-data` volume holds artwork and caches that Minstrel rebuilds if lost.
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -12,7 +12,7 @@ git.fabledsword.com/bvandeusen/ci-go:1.26
|
|||||||
git.fabledsword.com/bvandeusen/ci-android:36
|
git.fabledsword.com/bvandeusen/ci-android:36
|
||||||
```
|
```
|
||||||
|
|
||||||
- `ci-go:1.26` — the `go`, `integration` and `web` lanes, `release-assets`, and the container build (`image-release`). All CI lives in that one workflow so every publishing job can depend on every lane.
|
- `ci-go:1.26` — the `go`, `integration` and `web` lanes, and the container build and public release (`image-release`). All CI lives in that one workflow so every publishing job can depend on every lane.
|
||||||
- `golang:1.26-bookworm` (Docker Hub) — the `govulncheck` lane. Deliberately the same image as the Dockerfile's builder stage rather than `ci-go`, so the standard library it checks is the one in the shipped binary. Keep the two in step.
|
- `golang:1.26-bookworm` (Docker Hub) — the `govulncheck` lane. Deliberately the same image as the Dockerfile's builder stage rather than `ci-go`, so the standard library it checks is the one in the shipped binary. Keep the two in step.
|
||||||
- `ci-android:36` — native Kotlin/Compose client: ktlint + detekt + unit tests (the `android` lane), and the signed release APK (`android-release`).
|
- `ci-android:36` — native Kotlin/Compose client: ktlint + detekt + unit tests (the `android` lane), and the signed release APK (`android-release`).
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ while pulling `ci-android:36`, per the label/image split below.
|
|||||||
- **golangci-lint** — lint pass in the `go` lane.
|
- **golangci-lint** — lint pass in the `go` lane.
|
||||||
- **docker CLI** — bridge-IP discovery of the per-job Postgres service container in the `integration` lane (via the runner's shared `/var/run/docker.sock`).
|
- **docker CLI** — bridge-IP discovery of the per-job Postgres service container in the `integration` lane (via the runner's shared `/var/run/docker.sock`).
|
||||||
- **docker buildx** — release container build + push in `release.yml`.
|
- **docker buildx** — release container build + push in `release.yml`.
|
||||||
- **curl** — release-asset polling / upload in `release.yml`.
|
- **git, perl, node** — the public release in `image-release`: `git archive` for the export, `ci/leakgate.sh` (perl joins comment lines), `ci/releases.mjs` (node's fetch) for the release pages on GitHub and this forge.
|
||||||
|
|
||||||
### From `ci-android:36`
|
### From `ci-android:36`
|
||||||
- **JDK 25** — Gradle launcher + Android build. Requires Gradle 9.1.0+ in
|
- **JDK 25** — Gradle launcher + Android build. Requires Gradle 9.1.0+ in
|
||||||
@@ -41,8 +41,7 @@ while pulling `ci-android:36`, per the label/image split below.
|
|||||||
the `android` lane. Image pins track `android/gradle/libs.versions.toml` so local
|
the `android` lane. Image pins track `android/gradle/libs.versions.toml` so local
|
||||||
and CI checks agree.
|
and CI checks agree.
|
||||||
- **git** — `actions/checkout@v4` baseline (and any shell git operations).
|
- **git** — `actions/checkout@v4` baseline (and any shell git operations).
|
||||||
- **base64 + curl** — keystore decode + release-asset upload in `release.yml`'s
|
- **base64** — keystore decode in `release.yml`'s `android-release` job.
|
||||||
`android-release` job.
|
|
||||||
|
|
||||||
## Per-job tool installs
|
## Per-job tool installs
|
||||||
|
|
||||||
@@ -53,7 +52,8 @@ None.
|
|||||||
- **Label/image split.** Workflows keep `runs-on: go-ci` / `runs-on: flutter-ci` as the scheduling label per the [`ci-runners.md`](https://…/FabledRulebook/ci-runners.md) "label = scheduling handle, image = `container.image`" pattern. The labels are intentional handles, not toolchain assertions — which is why the Android jobs still schedule on `flutter-ci` while pulling `ci-android:36`. Switch them to `android-ci` if that runner label is ever registered; nothing breaks either way.
|
- **Label/image split.** Workflows keep `runs-on: go-ci` / `runs-on: flutter-ci` as the scheduling label per the [`ci-runners.md`](https://…/FabledRulebook/ci-runners.md) "label = scheduling handle, image = `container.image`" pattern. The labels are intentional handles, not toolchain assertions — which is why the Android jobs still schedule on `flutter-ci` while pulling `ci-android:36`. Switch them to `android-ci` if that runner label is ever registered; nothing breaks either way.
|
||||||
- **Integration-job docker-socket dependency.** The `integration` lane uses the runner's shared docker socket (`/var/run/docker.sock`) to bridge-IP-discover the per-job Postgres service container by name + network intersection — the dev compose's `minstrel-postgres-*` containers are explicitly skipped as belt-and-suspenders. Depends on `act_runner.valid_volumes` whitelisting the socket; if that ever stops auto-mounting, integration tests fail at the `docker inspect` step.
|
- **Integration-job docker-socket dependency.** The `integration` lane uses the runner's shared docker socket (`/var/run/docker.sock`) to bridge-IP-discover the per-job Postgres service container by name + network intersection — the dev compose's `minstrel-postgres-*` containers are explicitly skipped as belt-and-suspenders. Depends on `act_runner.valid_volumes` whitelisting the socket; if that ever stops auto-mounting, integration tests fail at the `docker inspect` step.
|
||||||
- **Go toolchain pin.** `go.mod` is on `go 1.25.0` because `golang.org/x/crypto v0.51.0` declares 1.25 as its minimum. `ci-go:1.26` satisfies this with headroom. Future `x/crypto` bumps that move the Go floor should be paired with an image-tag bump in this file + the workflows.
|
- **Go toolchain pin.** `go.mod` is on `go 1.25.0` because `golang.org/x/crypto v0.51.0` declares 1.25 as its minimum. `ci-go:1.26` satisfies this with headroom. Future `x/crypto` bumps that move the Go floor should be paired with an image-tag bump in this file + the workflows.
|
||||||
- **In-app update channel — `needs:`, not polling.** `release.yml`'s `image-release` job declares `needs: [android-release]`, so on dev and tag pushes the signed APK is guaranteed present before the image build starts — no polling window, no race. On `main` pushes `android-release` is skipped and `image-release` instead pulls the most recent release's APK and the version sidecar recorded beside it, so `:latest` never ships without an update channel. It degrades to an empty `client/` — never a wrong version — if no release or APK asset can be resolved.
|
- **In-app update channel — `needs:`, not polling.** `release.yml`'s `image-release` job declares `needs: [android-release]`, so on dev and main pushes the signed APK built from the same commit is guaranteed present before the image build starts — no polling window, no race. No APK is attached to any release page; phones get the app from the server image.
|
||||||
|
- **Public release secrets.** `PUBLIC_PUSH_TOKEN` (push to github.com/Fabled-Sword/minstrel and create its releases), `GHCR_USER` and `GHCR_TOKEN` (push to ghcr.io/fabled-sword/minstrel), and `CI_TOKEN` (this forge's release page). A dev push warns when one is missing; a main push stops before anything is pushed.
|
||||||
- **Cache server reachability.** The `web` lane does NOT use `cache: 'npm'` on `actions/setup-node` — the Gitea Actions cache server isn't reachable from this runner's container network, so `setup-node` would spend minutes on ETIMEDOUT before failing open. `setup-node` is not used at all (Node is in the image). The cache concern reappears if a change introduces a network-dependent action.
|
- **Cache server reachability.** The `web` lane does NOT use `cache: 'npm'` on `actions/setup-node` — the Gitea Actions cache server isn't reachable from this runner's container network, so `setup-node` would spend minutes on ETIMEDOUT before failing open. `setup-node` is not used at all (Node is in the image). The cache concern reappears if a change introduces a network-dependent action.
|
||||||
- **Artifacts — stock `actions/upload-artifact@v7` and `actions/download-artifact@v8`; never `@v3`.**
|
- **Artifacts — stock `actions/upload-artifact@v7` and `actions/download-artifact@v8`; never `@v3`.**
|
||||||
```yaml
|
```yaml
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Commits ci/changelog.sh leaves out of the public changelog, one full hash per
|
||||||
|
# line, each with a comment saying why. For a subject that names something that
|
||||||
|
# must not be published; the private changelog still lists it.
|
||||||
Executable
+86
@@ -0,0 +1,86 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# A release's changelog, in the two versions a release publishes:
|
||||||
|
#
|
||||||
|
# private.md every commit subject since the previous release, as written
|
||||||
|
# public.md the same list with record ids cut out ("(#1234)", "rule 12"),
|
||||||
|
# and the commits that only touch CI or tests left out, since
|
||||||
|
# neither ships
|
||||||
|
#
|
||||||
|
# The previous release is the newest public-release tag (v<name>, from
|
||||||
|
# PUBLIC_SINCE on) that is not on the commit being released. With none, this is
|
||||||
|
# the first public release, and both versions are a fixed note rather than the
|
||||||
|
# whole history before it.
|
||||||
|
#
|
||||||
|
# PUBLIC_SINCE exists because this repository also holds older v* tags, from
|
||||||
|
# releases made on this forge alone before the public ones began. Those are not
|
||||||
|
# public releases, so a changelog never counts from them.
|
||||||
|
#
|
||||||
|
# A commit whose subject must not reach the public list (it names something
|
||||||
|
# private) is left out by listing its full hash in changelog-skip.txt. The
|
||||||
|
# subject itself is never rewritten: the history is not.
|
||||||
|
#
|
||||||
|
# Usage: ci/changelog.sh <out-dir> [<commit-ish>] (default HEAD; needs the
|
||||||
|
# full history and tags, fetch-depth: 0)
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
readonly PUBLIC_SINCE='v2026.12.04'
|
||||||
|
|
||||||
|
out="${1:?usage: $0 <out-dir> [<commit-ish>]}"
|
||||||
|
ref="${2:-HEAD}"
|
||||||
|
here="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
mkdir -p "$out"
|
||||||
|
|
||||||
|
head="$(git rev-parse "$ref^{commit}")"
|
||||||
|
previous=""
|
||||||
|
for tag in $(git tag -l 'v*' --sort=-v:refname); do
|
||||||
|
# sort -V puts the older of the two first.
|
||||||
|
if [ "$(printf '%s\n%s\n' "$PUBLIC_SINCE" "$tag" | sort -V | head -1)" != "$PUBLIC_SINCE" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if [ "$(git rev-parse "$tag^{commit}")" != "$head" ]; then
|
||||||
|
previous="$tag"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$previous" ]; then
|
||||||
|
note='The first public release of Fabled Minstrel, a self-hosted music server with its own Android app. The README says what it does and how to run it.'
|
||||||
|
printf '%s\n' "$note" >"$out/private.md"
|
||||||
|
printf '%s\n' "$note" >"$out/public.md"
|
||||||
|
echo "changelog: first release, the fixed note"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
subjects="$(git log --no-merges --reverse --format='%H %s' "$previous..$head")"
|
||||||
|
|
||||||
|
{
|
||||||
|
printf 'Changes since %s:\n\n' "$previous"
|
||||||
|
printf '%s\n' "$subjects" | sed -E '/^$/d; s/^[0-9a-f]+ /- /'
|
||||||
|
} >"$out/private.md"
|
||||||
|
|
||||||
|
skip="$(grep -oE '^[0-9a-f]{40}' "$here/changelog-skip.txt" || true)"
|
||||||
|
{
|
||||||
|
printf 'Changes since %s:\n\n' "$previous"
|
||||||
|
printf '%s\n' "$subjects" | while IFS=' ' read -r hash subject; do
|
||||||
|
[ -n "$hash" ] || continue
|
||||||
|
if printf '%s\n' "$skip" | grep -qx "$hash"; then continue; fi
|
||||||
|
# The area before the colon, as a list: "server, web, ci". A type with a
|
||||||
|
# scope, "test(web)", counts by its type.
|
||||||
|
area="${subject%%:*}"
|
||||||
|
if [ "$area" != "$subject" ] &&
|
||||||
|
! printf '%s\n' "$area" | sed -E 's/\(.*\)//' | tr ',' '\n' | sed -E 's/^ +| +$//g' |
|
||||||
|
grep -qvxE 'ci|tests?|[a-z]+ tests?'; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
printf -- '- %s\n' "$subject"
|
||||||
|
done | sed -E '
|
||||||
|
s/ *\(((rule|preference|lesson|snippet|process|milestone|task|issue) )?#?[0-9]+(, *#?[0-9]+)*\)//gI
|
||||||
|
s/ *\b(rule|preference|lesson|snippet|process|milestone|task|issue) #?[0-9]+//gI
|
||||||
|
s/ *#[0-9]{3,5}\b//g
|
||||||
|
s/ *\( *\)//g
|
||||||
|
s/ +([,;.])/\1/g
|
||||||
|
s/[,;] *$//'
|
||||||
|
} >"$out/public.md"
|
||||||
|
|
||||||
|
echo "changelog: $(grep -c '^- ' "$out/private.md" || true) commits since $previous, $(grep -c '^- ' "$out/public.md" || true) public"
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Known false positives of ci/leakgate.sh, one extended regex per line, matched
|
||||||
|
# without regard to case. Each is cut out of a hit line before the line is
|
||||||
|
# tested again, so keep a pattern as narrow as the thing it allows.
|
||||||
|
|
||||||
|
# Words that contain a banned one.
|
||||||
|
jsonarray
|
||||||
|
readarray
|
||||||
|
|
||||||
|
# Drawing paths: SVG d attributes, Android pathData, and the path strings the
|
||||||
|
# web and Android icon sets keep, all of which start with a moveto, "M12".
|
||||||
|
d="[^"]*"?
|
||||||
|
pathdata="[^"]*"?
|
||||||
|
'M[0-9][^']*'
|
||||||
|
# The continuation lines of a long drawing path: numbers and path commands only.
|
||||||
|
^[-0-9 .,cmlzhvsqta]+$
|
||||||
|
|
||||||
|
# Material 3, the Android design system, in comments about its defaults.
|
||||||
|
\bM3('s)?\b
|
||||||
|
# CSS colours in hex, written as design tokens.
|
||||||
|
--[a-z-]+: [#][0-9a-f]{3,6};
|
||||||
Executable
+74
@@ -0,0 +1,74 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# The automatic half of the leak standard, run on what a public release would
|
||||||
|
# publish: the exported tree and the public changelog. Two kinds of hit fail it:
|
||||||
|
#
|
||||||
|
# words that must never ship the names of tools and services this project
|
||||||
|
# has nothing to do with in public
|
||||||
|
# private record ids "#1234", "rule 12", "milestone 7": pointers into
|
||||||
|
# a tracker no reader of the release can open
|
||||||
|
#
|
||||||
|
# The ids are also searched with comment continuation lines joined, because a
|
||||||
|
# citation split at a line break ("see rule\n// 12") passes a per-line search.
|
||||||
|
#
|
||||||
|
# The by-eye half (people, titles, quotes, images) is not here: a search cannot
|
||||||
|
# decide it.
|
||||||
|
#
|
||||||
|
# Known false positives are listed in leak-allow.txt, one pattern per line. A
|
||||||
|
# pattern is cut out of a hit line before the line is tested again, so an
|
||||||
|
# allowed word never hides a real hit beside it.
|
||||||
|
#
|
||||||
|
# Usage: ci/leakgate.sh <path>... (directories are searched recursively)
|
||||||
|
# Prints each hit and exits 1 if there is one.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
readonly HARD='sluice|storehouse|prospector|bookbag|musicbox|fabledexchange|lidarr|readarr|chaptarr|prowlarr|jackett|sonarr|radarr|qbittorrent|deluge|sabnzbd|nzbget|slskd|soulseek|deemix|torrent|usenet|\bnzb\b|magnet:|grimoire|\bscribe\b|traefik\.internal|vdnt'
|
||||||
|
readonly IDS='(\(|\s)#[0-9]{3,5}\b|\bM[0-9]{1,3}\b|\b(rule|preference|lesson|snippet|process|milestone) #?[0-9]{1,5}\b'
|
||||||
|
# Joined across comment lines, only the worded citations: the bare forms above
|
||||||
|
# are already whole on one line.
|
||||||
|
readonly JOINED='\b(?:rule|preference|lesson|snippet|process|milestone|task|issue)\s+#?\d{1,5}\b|\b(?:reference|measured)\s+library\b'
|
||||||
|
|
||||||
|
[ "$#" -gt 0 ] || { echo "usage: $0 <path>..." >&2; exit 2; }
|
||||||
|
|
||||||
|
here="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
strip="$(mktemp)"
|
||||||
|
trap 'rm -f "$strip"' EXIT
|
||||||
|
# One sed substitution per allowed pattern, case-insensitive like the search.
|
||||||
|
# \x01 delimits, so a pattern may hold any other character.
|
||||||
|
while IFS= read -r pattern; do
|
||||||
|
case "$pattern" in '' | '#'*) continue ;; esac
|
||||||
|
printf 's\x01%s\x01\x01gI\n' "$pattern" >>"$strip"
|
||||||
|
done <"$here/leak-allow.txt"
|
||||||
|
|
||||||
|
# Reads grep's path:line:text and prints the hits that still match once the
|
||||||
|
# allowed patterns are cut out of the text.
|
||||||
|
still() {
|
||||||
|
local hit text
|
||||||
|
while IFS= read -r hit; do
|
||||||
|
text="${hit#*:*:}"
|
||||||
|
if printf '%s\n' "$text" | sed -E -f "$strip" | grep -qiE -- "$1"; then
|
||||||
|
printf '%s\n' "$hit"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
found="$(
|
||||||
|
{
|
||||||
|
grep -rnHIiE -- "$HARD" "$@" || true
|
||||||
|
grep -rnHIiE -- "$IDS" "$@" || true
|
||||||
|
} | still "$HARD|$IDS"
|
||||||
|
# -I skips binary files, as grep does above. Each joined hit is printed as
|
||||||
|
# path:joined:text, so the same filter applies.
|
||||||
|
find "$@" -type f -exec grep -lIZ '' {} + 2>/dev/null \
|
||||||
|
| xargs -0 -r perl -0777 -ne '
|
||||||
|
s/\n[ \t]*(?:\/\/+|--|\*|#+)[ \t]*/ /g;
|
||||||
|
while (/('"$JOINED"')/gi) { (my $m = $1) =~ s/\s+/ /g; print "$ARGV:joined:$m\n" }' \
|
||||||
|
| still "$(printf '%s' "$JOINED" | sed -E 's/\(\?:/(/g; s/\\s/[[:space:]]/g; s/\\d/[0-9]/g')"
|
||||||
|
)"
|
||||||
|
|
||||||
|
if [ -n "$found" ]; then
|
||||||
|
printf '%s\n' "$found" | sort -u
|
||||||
|
echo "leakgate: the hits above would be published; reword them, or list a false positive in ci/leak-allow.txt" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "leakgate: clean"
|
||||||
@@ -0,0 +1,175 @@
|
|||||||
|
package ci
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// leakgate runs leakgate.sh over one file holding text, and says whether it
|
||||||
|
// passed.
|
||||||
|
func leakgate(t *testing.T, text string) (bool, string) {
|
||||||
|
t.Helper()
|
||||||
|
dir := t.TempDir()
|
||||||
|
if err := os.WriteFile(filepath.Join(dir, "f.go"), []byte(text), 0o644); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
out, err := exec.Command("bash", "leakgate.sh", dir).CombinedOutput()
|
||||||
|
return err == nil, string(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The gate fails on a banned word or a private record id, wherever it sits on
|
||||||
|
// the line, and passes the known false positives.
|
||||||
|
func TestTheLeakGateRefusesWhatMustNotBePublished(t *testing.T) {
|
||||||
|
for _, c := range []struct{ name, text string }{
|
||||||
|
{"a banned word", "// a folder some downloader called Lidarr made\n"},
|
||||||
|
{"a banned word in a fixture path", `{".sluice-held/Artist/01.flac", true},` + "\n"},
|
||||||
|
{"a banned word beside an allowed one", "var list JsonArray // the torrent's files\n"},
|
||||||
|
{"a ticket", "// fixed in (#4321)\n"},
|
||||||
|
{"a worded citation", "// as milestone 635 decided\n"},
|
||||||
|
{"a short milestone id", "// added in m7-scan-progress\n"},
|
||||||
|
{"a citation split across comment lines", "// as the rule\n// 12 says\n"},
|
||||||
|
{"a library measured, split across lines", "// counted on the reference\n// library\n"},
|
||||||
|
{"an id beside a drawing path", "<path d=\"M3 4\"/> see rule 9\n"},
|
||||||
|
{"an id beside Material 3", "// M3's default, as M12 chose\n"},
|
||||||
|
} {
|
||||||
|
if passed, out := leakgate(t, c.text); passed {
|
||||||
|
t.Errorf("%s: passed %q\n%s", c.name, c.text, out)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTheLeakGatePassesItsKnownFalsePositives(t *testing.T) {
|
||||||
|
text := strings.Join([]string{
|
||||||
|
"import kotlinx.serialization.json.JsonArray",
|
||||||
|
`<path d="M8 1.5 15 14H1z" />`,
|
||||||
|
`android:pathData="M17,3H7c-1.1,0 -1.99,0.9 -1.99,2L5,21z" />`,
|
||||||
|
`back: 'M15 5l-7 7 7 7',`,
|
||||||
|
"97 -322 147 -488 125z m928 -812 c53 -27 39 -34",
|
||||||
|
"// M3 inactive default is secondaryContainer; drops M3's stop",
|
||||||
|
`expect(css).toMatch(/--fs-obsidian: #000;[\s\S]*--fs-parchment: #FFF;/);`,
|
||||||
|
"// a song called the rule of three is fine",
|
||||||
|
}, "\n") + "\n"
|
||||||
|
if passed, out := leakgate(t, text); !passed {
|
||||||
|
t.Errorf("refused a known false positive:\n%s", out)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// repo makes a git repository whose commits carry the given subjects, and
|
||||||
|
// returns its path.
|
||||||
|
func repo(t *testing.T, subjects ...string) string {
|
||||||
|
t.Helper()
|
||||||
|
dir := t.TempDir()
|
||||||
|
git(t, dir, "init", "-q", "-b", "main")
|
||||||
|
for _, s := range subjects {
|
||||||
|
commit(t, dir, s)
|
||||||
|
}
|
||||||
|
return dir
|
||||||
|
}
|
||||||
|
|
||||||
|
// commit makes one commit with the given subject, changing a file so that it
|
||||||
|
// is never empty.
|
||||||
|
func commit(t *testing.T, dir, subject string) {
|
||||||
|
t.Helper()
|
||||||
|
if err := os.WriteFile(filepath.Join(dir, "f"), []byte(subject), 0o644); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
git(t, dir, "add", "f")
|
||||||
|
git(t, dir, "commit", "-q", "-m", subject)
|
||||||
|
}
|
||||||
|
|
||||||
|
func git(t *testing.T, dir string, args ...string) string {
|
||||||
|
t.Helper()
|
||||||
|
cmd := exec.Command("git", append([]string{"-c", "user.name=t", "-c", "user.email=t@example.com"}, args...)...)
|
||||||
|
cmd.Dir = dir
|
||||||
|
cmd.Env = append(os.Environ(), "GIT_CONFIG_GLOBAL=/dev/null", "GIT_CONFIG_SYSTEM=/dev/null")
|
||||||
|
out, err := cmd.CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("git %v: %v\n%s", args, err, out)
|
||||||
|
}
|
||||||
|
return strings.TrimSpace(string(out))
|
||||||
|
}
|
||||||
|
|
||||||
|
// changelog runs changelog.sh in dir and returns the private and public lists.
|
||||||
|
func changelog(t *testing.T, dir string) (string, string) {
|
||||||
|
t.Helper()
|
||||||
|
script, err := filepath.Abs("changelog.sh")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
out := t.TempDir()
|
||||||
|
cmd := exec.Command("bash", script, out)
|
||||||
|
cmd.Dir = dir
|
||||||
|
if msg, err := cmd.CombinedOutput(); err != nil {
|
||||||
|
t.Fatalf("changelog.sh: %v\n%s", err, msg)
|
||||||
|
}
|
||||||
|
read := func(name string) string {
|
||||||
|
b, err := os.ReadFile(filepath.Join(out, name))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
return string(b)
|
||||||
|
}
|
||||||
|
return read("private.md"), read("public.md")
|
||||||
|
}
|
||||||
|
|
||||||
|
// The first public release has no public release before it, and its changelog
|
||||||
|
// is the fixed note rather than every commit the project ever made. A v* tag
|
||||||
|
// from before the public releases began is not a public release, so it does
|
||||||
|
// not count as one.
|
||||||
|
func TestTheFirstReleaseIsAFixedNote(t *testing.T) {
|
||||||
|
dir := repo(t, "library: the first commit")
|
||||||
|
git(t, dir, "tag", "v2026.10.26.1520")
|
||||||
|
commit(t, dir, "web: after the forge-only release")
|
||||||
|
private, public := changelog(t, dir)
|
||||||
|
if private != public || strings.Contains(public, "web:") || !strings.Contains(public, "first public release") {
|
||||||
|
t.Errorf("private %q, public %q: want the same fixed note", private, public)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A later release lists what changed since the previous one. The public list
|
||||||
|
// loses its record ids and the commits that only touch CI or tests.
|
||||||
|
func TestALaterReleaseListsWhatChangedSinceThePrevious(t *testing.T) {
|
||||||
|
dir := repo(t, "library: before the release")
|
||||||
|
git(t, dir, "tag", "v2026.12.05.0000")
|
||||||
|
for _, s := range []string{
|
||||||
|
"fix(library): a song keeps its title (#4321)",
|
||||||
|
"web, ci: a page and its lane (rule 12, #77)",
|
||||||
|
"ci: a faster lane",
|
||||||
|
"test(web): one test fewer",
|
||||||
|
"web tests: one more",
|
||||||
|
"server, tests: a route, as milestone 635 asks",
|
||||||
|
} {
|
||||||
|
commit(t, dir, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
private, public := changelog(t, dir)
|
||||||
|
if strings.Contains(private, "before the release") {
|
||||||
|
t.Errorf("the private list reaches past the previous release:\n%s", private)
|
||||||
|
}
|
||||||
|
if !strings.Contains(private, "(#4321)") || !strings.Contains(private, "- ci: a faster lane") {
|
||||||
|
t.Errorf("the private list is not as written:\n%s", private)
|
||||||
|
}
|
||||||
|
want := "Changes since v2026.12.05.0000:\n\n" +
|
||||||
|
"- fix(library): a song keeps its title\n" +
|
||||||
|
"- web, ci: a page and its lane\n" +
|
||||||
|
"- server, tests: a route, as asks\n"
|
||||||
|
if public != want {
|
||||||
|
t.Errorf("public list:\n%s\nwant:\n%s", public, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A re-run of a release finds its own tag on the commit, and lists from the
|
||||||
|
// release before it.
|
||||||
|
func TestARerunListsFromTheReleaseBefore(t *testing.T) {
|
||||||
|
dir := repo(t, "library: before")
|
||||||
|
git(t, dir, "tag", "v2026.12.05.0000")
|
||||||
|
commit(t, dir, "web: after")
|
||||||
|
git(t, dir, "tag", "v2026.12.06.0000")
|
||||||
|
_, public := changelog(t, dir)
|
||||||
|
if !strings.Contains(public, "since v2026.12.05.0000") || !strings.Contains(public, "- web: after") {
|
||||||
|
t.Errorf("re-run list:\n%s", public)
|
||||||
|
}
|
||||||
|
}
|
||||||
+106
@@ -0,0 +1,106 @@
|
|||||||
|
// Creates a release's page on a forge, or updates it in place when the run is
|
||||||
|
// repeated, so a re-run never fails on the release it made the first time.
|
||||||
|
//
|
||||||
|
// node ci/releases.mjs github <tag> <body-file>
|
||||||
|
// the public repository's GitHub Release, with PUBLIC_PUSH_TOKEN. The tag
|
||||||
|
// must already be pushed there.
|
||||||
|
// node ci/releases.mjs forge <tag> <body-file> <commit>
|
||||||
|
// this repository's release on its own forge, with FORGE_TOKEN, tagging
|
||||||
|
// <commit> when the tag does not exist yet.
|
||||||
|
// node ci/releases.mjs forge-probe
|
||||||
|
// whether FORGE_TOKEN may write releases, without writing one: an update
|
||||||
|
// of a release that does not exist answers 404 to a token that may, and
|
||||||
|
// 403 to one that may not.
|
||||||
|
//
|
||||||
|
// Prints the release's page.
|
||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
|
||||||
|
const PUBLIC_REPO = 'Fabled-Sword/minstrel';
|
||||||
|
|
||||||
|
const [kind, tag, bodyFile, commit] = process.argv.slice(2);
|
||||||
|
|
||||||
|
function need(name) {
|
||||||
|
const value = process.env[name];
|
||||||
|
if (!value) throw new Error(`${name} is empty or unset`);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function call(method, url, headers, body) {
|
||||||
|
const res = await fetch(url, {
|
||||||
|
method,
|
||||||
|
headers: { 'Content-Type': 'application/json', ...headers },
|
||||||
|
body: body === undefined ? undefined : JSON.stringify(body)
|
||||||
|
});
|
||||||
|
const text = await res.text();
|
||||||
|
return { status: res.status, json: text ? safeJSON(text) : null, text };
|
||||||
|
}
|
||||||
|
|
||||||
|
function safeJSON(text) {
|
||||||
|
try {
|
||||||
|
return JSON.parse(text);
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function ok(res, what) {
|
||||||
|
if (res.status < 200 || res.status >= 300) {
|
||||||
|
throw new Error(`${what}: HTTP ${res.status} ${res.text.slice(0, 300)}`);
|
||||||
|
}
|
||||||
|
return res.json;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The same steps on either forge: find the release by its tag, then update it
|
||||||
|
// or create it.
|
||||||
|
async function upsert(api, headers, fields) {
|
||||||
|
const found = await call('GET', `${api}/releases/tags/${encodeURIComponent(tag)}`, headers);
|
||||||
|
if (found.status === 200) {
|
||||||
|
return ok(await call('PATCH', `${api}/releases/${found.json.id}`, headers, fields), 'update');
|
||||||
|
}
|
||||||
|
if (found.status !== 404) ok(found, 'look up');
|
||||||
|
return ok(await call('POST', `${api}/releases`, headers, { tag_name: tag, ...fields }), 'create');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
if (kind === 'forge-probe') {
|
||||||
|
const res = await call(
|
||||||
|
'PATCH',
|
||||||
|
`${need('GITHUB_SERVER_URL')}/api/v1/repos/${need('GITHUB_REPOSITORY')}/releases/0`,
|
||||||
|
{ Authorization: `token ${need('FORGE_TOKEN')}` },
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
if (res.status !== 404) throw new Error(`the token may not write releases: HTTP ${res.status} ${res.text.slice(0, 200)}`);
|
||||||
|
console.log('the forge token may write releases');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!tag || !bodyFile) throw new Error('usage: node ci/releases.mjs github|forge <tag> <body-file> [<commit>]');
|
||||||
|
const body = readFileSync(bodyFile, 'utf8');
|
||||||
|
const name = `Fabled Minstrel ${tag}`;
|
||||||
|
let release;
|
||||||
|
if (kind === 'github') {
|
||||||
|
release = await upsert(
|
||||||
|
`https://api.github.com/repos/${PUBLIC_REPO}`,
|
||||||
|
{
|
||||||
|
Authorization: `Bearer ${need('PUBLIC_PUSH_TOKEN')}`,
|
||||||
|
Accept: 'application/vnd.github+json',
|
||||||
|
'X-GitHub-Api-Version': '2022-11-28'
|
||||||
|
},
|
||||||
|
{ name, body }
|
||||||
|
);
|
||||||
|
} else if (kind === 'forge') {
|
||||||
|
if (!commit) throw new Error('forge needs the commit to tag');
|
||||||
|
release = await upsert(
|
||||||
|
`${need('GITHUB_SERVER_URL')}/api/v1/repos/${need('GITHUB_REPOSITORY')}`,
|
||||||
|
{ Authorization: `token ${need('FORGE_TOKEN')}` },
|
||||||
|
{ name, body, target_commitish: commit }
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw new Error(`unknown forge ${kind}`);
|
||||||
|
}
|
||||||
|
console.log(release.html_url);
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch((err) => {
|
||||||
|
console.error(`releases: ${err.message}`);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
@@ -3,6 +3,7 @@ package server
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -24,15 +25,14 @@ import (
|
|||||||
// require its success by name.
|
// require its success by name.
|
||||||
var gateLanes = []string{"go", "integration", "web", "android", "govulncheck"}
|
var gateLanes = []string{"go", "integration", "web", "android", "govulncheck"}
|
||||||
|
|
||||||
// gatePublishers push something other people can pull: image tags (the
|
// gatePublishers push something other people can pull: image-release pushes
|
||||||
// private channels, and the public release image on GHCR), and the APK +
|
// the private channels and, on main, the whole public release.
|
||||||
// sidecar attached to a Release.
|
var gatePublishers = []string{"image-release"}
|
||||||
var gatePublishers = []string{"image-release", "release-assets", "ghcr-release"}
|
|
||||||
|
|
||||||
// gateOthers are the remaining jobs and why they sit outside the gate:
|
// gateOthers are the remaining jobs and why they sit outside the gate:
|
||||||
// android-release only builds a workflow artifact (nothing outside the run can
|
// android-release only builds a workflow artifact (nothing outside the run can
|
||||||
// pull it), and verify-release reports on a finished release.
|
// pull it).
|
||||||
var gateOthers = []string{"android-release", "verify-release"}
|
var gateOthers = []string{"android-release"}
|
||||||
|
|
||||||
type workflowJob struct {
|
type workflowJob struct {
|
||||||
Needs any `yaml:"needs"`
|
Needs any `yaml:"needs"`
|
||||||
@@ -120,47 +120,66 @@ func TestReleaseGate_PublishersNeedEveryLaneToSucceed(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The public release image has four properties a later edit could quietly
|
// The public release has properties a later edit could quietly lose, each of
|
||||||
// lose, each of which still builds and pushes a valid image:
|
// which still builds and pushes a valid release:
|
||||||
// - it runs only on a dispatch that asks for it, never on a push to dev;
|
// - only a push to main makes it, never a dev push or a dispatch;
|
||||||
// - a GHCR dispatch moves no private channel;
|
// - every image is built from the `git archive` export, so export-ignored
|
||||||
// - it builds from the `git archive` export, so export-ignored files never
|
// files never reach a build context, and the export and the public
|
||||||
// reach its build context;
|
// changelog pass the leak gate before anything is built or pushed;
|
||||||
// - it carries no provenance attestation, and its source label names the
|
// - the public image carries no provenance attestation, and its labels name
|
||||||
// public repo rather than this workbench.
|
// the public repository and commit rather than this workbench;
|
||||||
func TestGHCRRelease_OnlyOnRequestFromTheExportAndNamingThePublicRepo(t *testing.T) {
|
// - the public commit is the family's public identity, dated in UTC.
|
||||||
jobs := releaseJobs(t)
|
func TestPublicRelease_OnlyFromAMainPushBuiltFromTheGatedExport(t *testing.T) {
|
||||||
ghcr := strings.Join(strings.Fields(jobs["ghcr-release"].If), " ")
|
|
||||||
for _, want := range []string{"github.event_name == 'workflow_dispatch'", "github.event.inputs.ghcr_release == 'true'"} {
|
|
||||||
if !strings.Contains(ghcr, want) {
|
|
||||||
t.Errorf("ghcr-release's if lacks %s, so it could run on a push\n if: %s", want, ghcr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private := strings.Join(strings.Fields(jobs["image-release"].If), " ")
|
|
||||||
if !strings.Contains(private, "github.event.inputs.ghcr_release != 'true'") {
|
|
||||||
t.Errorf("image-release does not stand aside on a GHCR dispatch, so a release would also move a private channel\n if: %s", private)
|
|
||||||
}
|
|
||||||
|
|
||||||
yaml := releaseYAML(t)
|
yaml := releaseYAML(t)
|
||||||
i := strings.Index(yaml, "\n ghcr-release:")
|
i := strings.Index(yaml, "\n image-release:")
|
||||||
if i < 0 {
|
if i < 0 {
|
||||||
t.Fatal("no ghcr-release job")
|
t.Fatal("no image-release job")
|
||||||
}
|
}
|
||||||
job := yaml[i:]
|
job := yaml[i:]
|
||||||
if j := jobBoundary.FindStringIndex(job[1:]); j != nil {
|
|
||||||
job = job[:j[0]+1]
|
tags := stepBody(t, job, "Compute image tags")
|
||||||
|
public := regexp.MustCompile(`if \[ "\$\{GITHUB_EVENT_NAME\}" = "push" \] && \[ "\$\{GITHUB_REF\}" = "refs/heads/main" \]; then\s+echo "PUBLIC=true"\s+else\s+echo "PUBLIC=false"`)
|
||||||
|
if !public.MatchString(tags) {
|
||||||
|
t.Errorf("PUBLIC is not true for a push to main alone, so another run could publish the release\n%s", tags)
|
||||||
}
|
}
|
||||||
export := stepBody(t, job, "Export the public tree and match it to the public tag")
|
for _, step := range []string{"Public commit and tag", "Public image", "Public and private releases"} {
|
||||||
if !strings.Contains(export, "git archive HEAD") {
|
if !strings.Contains(stepBody(t, job, step), "if: env.PUBLIC == 'true'") {
|
||||||
t.Errorf("the export step does not use git archive, so export-ignored files could reach the image\n%s", export)
|
t.Errorf("%q does not wait for PUBLIC, so a dev push would publish it", step)
|
||||||
}
|
|
||||||
build := stepBody(t, job, "Build the release image from the export")
|
|
||||||
for _, want := range []string{"--provenance=false", `"${EXPORT}"`, "org.opencontainers.image.source=\"${PUBLIC_REPO}\""} {
|
|
||||||
if !strings.Contains(build, want) {
|
|
||||||
t.Errorf("the release image build lacks %s\n%s", want, build)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !strings.Contains(job, "PUBLIC_REPO: https://github.com/Fabled-Sword/minstrel") {
|
|
||||||
t.Error("ghcr-release's PUBLIC_REPO is not the public GitHub repo, so the image's source label points elsewhere")
|
export := stepBody(t, job, "Export, changelog and leak gate")
|
||||||
|
for _, want := range []string{"git archive HEAD", "ci/changelog.sh", `ci/leakgate.sh "${EXPORT}" "${RUNNER_TEMP}/changelog/public.md"`} {
|
||||||
|
if !strings.Contains(export, want) {
|
||||||
|
t.Errorf("the export step lacks %s\n%s", want, export)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gate := strings.Index(job, "- name: Export, changelog and leak gate")
|
||||||
|
for _, step := range []string{"Build and push", "Public commit and tag"} {
|
||||||
|
if at := strings.Index(job, "- name: "+step); at < gate {
|
||||||
|
t.Errorf("%q runs before the leak gate, so a leak could be pushed before it is caught", step)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, step := range []string{"Build and push", "Public image"} {
|
||||||
|
if !strings.Contains(stepBody(t, job, step), `"${EXPORT}"`) {
|
||||||
|
t.Errorf("%q does not build from the export, so export-ignored files reach its image", step)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
image := stepBody(t, job, "Public image")
|
||||||
|
for _, want := range []string{"--provenance=false", "org.opencontainers.image.source=https://github.com/${PUBLIC_REPO}", "org.opencontainers.image.revision=${REVISION}"} {
|
||||||
|
if !strings.Contains(image, want) {
|
||||||
|
t.Errorf("the public image build lacks %s\n%s", want, image)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !strings.Contains(job, "PUBLIC_REPO: Fabled-Sword/minstrel") {
|
||||||
|
t.Error("PUBLIC_REPO is not the public GitHub repository, so the release and its labels point elsewhere")
|
||||||
|
}
|
||||||
|
|
||||||
|
commit := stepBody(t, job, "Public commit and tag")
|
||||||
|
for _, want := range []string{"GIT_AUTHOR_EMAIL=amateurdungeoneer@fabledsword.com", "GIT_COMMITTER_EMAIL=amateurdungeoneer@fabledsword.com", "+0000", "git add -A -f"} {
|
||||||
|
if !strings.Contains(commit, want) {
|
||||||
|
t.Errorf("the public commit lacks %s\n%s", want, commit)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,20 +220,18 @@ func releaseYAML(t *testing.T) string {
|
|||||||
return string(body)
|
return string(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
// imageTagArms splits "Compute image tags" into its three ref branches. The
|
// imageTagArms splits "Compute image tags" into its two ref branches. The
|
||||||
// whole tag policy lives in that if/elif/else, so the arms are the unit worth
|
// whole private tag policy lives in that if/else, so the arms are the unit
|
||||||
// asserting on — a tag published from the wrong arm reaches the wrong
|
// worth asserting on — a tag published from the wrong arm reaches the wrong
|
||||||
// audience, and every such mistake still builds and still pushes a valid
|
// audience, and every such mistake still builds and still pushes a valid
|
||||||
// image.
|
// image.
|
||||||
func imageTagArms(t *testing.T, yaml string) (tagArm, devArm, mainArm string) {
|
func imageTagArms(t *testing.T, yaml string) (devArm, mainArm string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
const (
|
const (
|
||||||
tagMarker = `if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then`
|
devMarker = `if [[ "${GITHUB_REF}" == "refs/heads/dev" ]]; then`
|
||||||
devMarker = `elif [[ "${GITHUB_REF}" == "refs/heads/dev" ]]; then`
|
|
||||||
mainMarker = "\n else"
|
mainMarker = "\n else"
|
||||||
endMarker = "\n fi"
|
endMarker = "\n fi"
|
||||||
)
|
)
|
||||||
iTag := strings.Index(yaml, tagMarker)
|
|
||||||
iDev := strings.Index(yaml, devMarker)
|
iDev := strings.Index(yaml, devMarker)
|
||||||
iMain := -1
|
iMain := -1
|
||||||
if iDev >= 0 {
|
if iDev >= 0 {
|
||||||
@@ -241,8 +239,8 @@ func imageTagArms(t *testing.T, yaml string) (tagArm, devArm, mainArm string) {
|
|||||||
iMain = iDev + k
|
iMain = iDev + k
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if iTag < 0 || iDev < 0 || iMain < 0 {
|
if iDev < 0 || iMain < 0 {
|
||||||
t.Fatal("Compute image tags no longer has a tag/dev/main arm — the tag policy has been restructured, so these guards are pinning nothing")
|
t.Fatal("Compute image tags no longer has a dev/main arm — the tag policy has been restructured, so these guards are pinning nothing")
|
||||||
}
|
}
|
||||||
iEnd := iMain
|
iEnd := iMain
|
||||||
if k := strings.Index(yaml[iMain:], endMarker); k >= 0 {
|
if k := strings.Index(yaml[iMain:], endMarker); k >= 0 {
|
||||||
@@ -250,7 +248,7 @@ func imageTagArms(t *testing.T, yaml string) (tagArm, devArm, mainArm string) {
|
|||||||
} else {
|
} else {
|
||||||
t.Fatal("no closing fi after the main arm")
|
t.Fatal("no closing fi after the main arm")
|
||||||
}
|
}
|
||||||
return yaml[iTag:iDev], yaml[iDev:iMain], yaml[iMain:iEnd]
|
return yaml[iDev:iMain], yaml[iMain:iEnd]
|
||||||
}
|
}
|
||||||
|
|
||||||
// The worst regression this wiring can produce: a dev push that also moves
|
// The worst regression this wiring can produce: a dev push that also moves
|
||||||
@@ -258,7 +256,7 @@ func imageTagArms(t *testing.T, yaml string) (tagArm, devArm, mainArm string) {
|
|||||||
// next pull. Nothing else in the suite would notice — the build stays green
|
// next pull. Nothing else in the suite would notice — the build stays green
|
||||||
// and the image is valid, it is simply the wrong audience.
|
// and the image is valid, it is simply the wrong audience.
|
||||||
func TestDevChannel_PublishesDevAloneAndNeverLatest(t *testing.T) {
|
func TestDevChannel_PublishesDevAloneAndNeverLatest(t *testing.T) {
|
||||||
_, arm, _ := imageTagArms(t, releaseYAML(t))
|
arm, _ := imageTagArms(t, releaseYAML(t))
|
||||||
|
|
||||||
if !strings.Contains(arm, "${IMAGE}:dev") {
|
if !strings.Contains(arm, "${IMAGE}:dev") {
|
||||||
t.Errorf("dev arm does not publish :dev\n%s", arm)
|
t.Errorf("dev arm does not publish :dev\n%s", arm)
|
||||||
@@ -274,14 +272,14 @@ func TestDevChannel_PublishesDevAloneAndNeverLatest(t *testing.T) {
|
|||||||
|
|
||||||
// A merge to main is enough to put a new app in front of stable phones: main
|
// A merge to main is enough to put a new app in front of stable phones: main
|
||||||
// builds the signed APK from its own commit and bakes it into :latest, as dev
|
// builds the signed APK from its own commit and bakes it into :latest, as dev
|
||||||
// does for :dev. The regression to guard is main falling back to a tag-only
|
// does for :dev. The regression to guard is main falling back to an APK built
|
||||||
// APK build, which leaves every merged app change waiting on a release while
|
// somewhere else, which leaves every merged app change waiting while each build
|
||||||
// each build stays green.
|
// stays green.
|
||||||
func TestEveryBranchShipsTheAppBuiltFromItsOwnCommit(t *testing.T) {
|
func TestEveryBranchShipsTheAppBuiltFromItsOwnCommit(t *testing.T) {
|
||||||
jobs := releaseJobs(t)
|
jobs := releaseJobs(t)
|
||||||
|
|
||||||
build := strings.Join(strings.Fields(jobs["android-release"].If), " ")
|
build := strings.Join(strings.Fields(jobs["android-release"].If), " ")
|
||||||
for _, ref := range []string{"refs/heads/main", "refs/heads/dev", "refs/tags/v"} {
|
for _, ref := range []string{"refs/heads/main", "refs/heads/dev"} {
|
||||||
if !strings.Contains(build, ref) {
|
if !strings.Contains(build, ref) {
|
||||||
t.Errorf("android-release does not build on %s, so that ref's image carries no app of its own\n if: %s", ref, build)
|
t.Errorf("android-release does not build on %s, so that ref's image carries no app of its own\n if: %s", ref, build)
|
||||||
}
|
}
|
||||||
@@ -297,8 +295,7 @@ func TestEveryBranchShipsTheAppBuiltFromItsOwnCommit(t *testing.T) {
|
|||||||
t.Error("release.yml fetches the latest release; an image bundling a release's APK ships an app older than its own commit")
|
t.Error("release.yml fetches the latest release; an image bundling a release's APK ships an app older than its own commit")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Both bundling steps run on every ref. Sliced from image-release on,
|
// Both bundling steps run on every ref.
|
||||||
// because release-assets has a step of the same name.
|
|
||||||
i := strings.Index(yaml, "\n image-release:")
|
i := strings.Index(yaml, "\n image-release:")
|
||||||
if i < 0 {
|
if i < 0 {
|
||||||
t.Fatal("no image-release job")
|
t.Fatal("no image-release job")
|
||||||
@@ -319,7 +316,7 @@ func TestEveryBranchShipsTheAppBuiltFromItsOwnCommit(t *testing.T) {
|
|||||||
//
|
//
|
||||||
// Rules 145 and 147: main push → :latest + :<sha>.
|
// Rules 145 and 147: main push → :latest + :<sha>.
|
||||||
func TestMainChannel_PublishesLatestAndTheRollbackUnit(t *testing.T) {
|
func TestMainChannel_PublishesLatestAndTheRollbackUnit(t *testing.T) {
|
||||||
_, _, arm := imageTagArms(t, releaseYAML(t))
|
_, arm := imageTagArms(t, releaseYAML(t))
|
||||||
|
|
||||||
if !strings.Contains(arm, "${IMAGE}:latest") {
|
if !strings.Contains(arm, "${IMAGE}:latest") {
|
||||||
t.Errorf("main arm does not move :latest — production would stop tracking main's tip\n%s", arm)
|
t.Errorf("main arm does not move :latest — production would stop tracking main's tip\n%s", arm)
|
||||||
@@ -334,38 +331,21 @@ func TestMainChannel_PublishesLatestAndTheRollbackUnit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A release refreshes the CHANNEL and mints nothing else.
|
// No version-numbered PRIVATE image tags, on either arm: the build's version
|
||||||
|
// is self-reported, and the private tag map is :latest, :<sha> and :dev. (The
|
||||||
|
// public image on GHCR is the one that carries the release's name.)
|
||||||
//
|
//
|
||||||
// The regression to guard: a :<sha> tag here. The tag build rebuilds the SAME
|
// Asserted on both arms because the mistake this catches is re-adding one
|
||||||
// SOURCE as main's build minutes earlier, differing only in which APK is baked
|
// anywhere. `${VERSION}` still legitimately appears in the step as the build's
|
||||||
// in — so a :<sha> minted here would overwrite main's immutable rollback
|
|
||||||
// target with different contents, under the same name.
|
|
||||||
func TestReleaseBuild_RefreshesTheChannelAndMintsNothingElse(t *testing.T) {
|
|
||||||
arm, _, _ := imageTagArms(t, releaseYAML(t))
|
|
||||||
|
|
||||||
if !strings.Contains(arm, "${IMAGE}:latest") {
|
|
||||||
t.Errorf("tag arm does not refresh :latest — the server would hand out a different APK build from the one attached to the Release\n%s", arm)
|
|
||||||
}
|
|
||||||
if strings.Contains(arm, "GITHUB_SHA") {
|
|
||||||
t.Errorf("tag arm mints a :<sha> image; that would re-push main's immutable rollback target with different bundled contents\n%s", arm)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// No version-numbered image tags anywhere, on any arm: the build's version is
|
|
||||||
// self-reported, and the tag map is :latest, :<sha> and :dev.
|
|
||||||
//
|
|
||||||
// Asserted across the whole step rather than per-arm because the mistake this
|
|
||||||
// catches is re-adding one ANYWHERE, and the tag arm is only the likeliest
|
|
||||||
// spot. `${VERSION}` still legitimately appears in the step as the build's
|
|
||||||
// self-reported version, so the assertion has to name the image-tag form
|
// self-reported version, so the assertion has to name the image-tag form
|
||||||
// specifically rather than the variable — otherwise it would fire on correct
|
// specifically rather than the variable — otherwise it would fire on correct
|
||||||
// code and get "fixed" by deleting the guard.
|
// code and get "fixed" by deleting the guard.
|
||||||
func TestNoVersionNumberedImageTags(t *testing.T) {
|
func TestNoVersionNumberedImageTags(t *testing.T) {
|
||||||
yaml := releaseYAML(t)
|
yaml := releaseYAML(t)
|
||||||
tagArm, devArm, mainArm := imageTagArms(t, yaml)
|
devArm, mainArm := imageTagArms(t, yaml)
|
||||||
|
|
||||||
for _, tc := range []struct{ name, arm string }{
|
for _, tc := range []struct{ name, arm string }{
|
||||||
{"tag", tagArm}, {"dev", devArm}, {"main", mainArm},
|
{"dev", devArm}, {"main", mainArm},
|
||||||
} {
|
} {
|
||||||
for _, forbidden := range []string{
|
for _, forbidden := range []string{
|
||||||
"${IMAGE}:${VERSION}",
|
"${IMAGE}:${VERSION}",
|
||||||
@@ -380,25 +360,6 @@ func TestNoVersionNumberedImageTags(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The verify job asserted the :<version> image existed. With version tags
|
|
||||||
// gone that assertion would fail every release for a tag nothing mints — so
|
|
||||||
// this pins that it was re-pointed rather than deleted, since deleting it is
|
|
||||||
// the tempting way to make a failing guard go green.
|
|
||||||
func TestVerifyJob_ChecksTheRollbackImageNotAVersionTag(t *testing.T) {
|
|
||||||
yaml := releaseYAML(t)
|
|
||||||
|
|
||||||
if !strings.Contains(yaml, "- name: Rollback image must exist for the tagged commit") {
|
|
||||||
t.Fatal("the release-verification step that checks an image exists is gone; an image push that silently did not happen would now pass verification")
|
|
||||||
}
|
|
||||||
step := stepBody(t, yaml, "Rollback image must exist for the tagged commit")
|
|
||||||
if !strings.Contains(step, "${IMAGE}:${GITHUB_SHA}") {
|
|
||||||
t.Errorf("the verify step does not inspect the commit's rollback image\n%s", step)
|
|
||||||
}
|
|
||||||
if strings.Contains(step, "${IMAGE}:${TAG}") {
|
|
||||||
t.Errorf("the verify step still inspects a version-numbered image, which is no longer published — this would fail every release\n%s", step)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The server's self-reported version is the ONLY thing that identifies a
|
// The server's self-reported version is the ONLY thing that identifies a
|
||||||
// build, so a lane that stamps a channel word instead of a version silently
|
// build, so a lane that stamps a channel word instead of a version silently
|
||||||
// removes that ability.
|
// removes that ability.
|
||||||
@@ -418,7 +379,7 @@ func TestImageBuild_StampsADerivedVersionAndAChannel(t *testing.T) {
|
|||||||
// The version must come from the shared derivation, not from the ref.
|
// The version must come from the shared derivation, not from the ref.
|
||||||
// Reading it off GITHUB_REF is what produced "main" and "dev" as version
|
// Reading it off GITHUB_REF is what produced "main" and "dev" as version
|
||||||
// strings, which is the regression this pins.
|
// strings, which is the regression this pins.
|
||||||
_, _, mainArm := imageTagArms(t, yaml)
|
_, mainArm := imageTagArms(t, yaml)
|
||||||
if strings.Contains(mainArm, `version=main`) {
|
if strings.Contains(mainArm, `version=main`) {
|
||||||
t.Errorf("the main arm stamps the literal string \"main\" as a version; two images months apart would be indistinguishable\n%s", mainArm)
|
t.Errorf("the main arm stamps the literal string \"main\" as a version; two images months apart would be indistinguishable\n%s", mainArm)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user