Publish each build as its own release

Gitea serves releases/download/latest/ from the newest published release, so
instead of replacing assets in a fixed "latest" release, each build uploads to
a draft and publishes it, then removes all but the newest 3 releases. The qcow2
is now published on every build, as latest only looks at the newest release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Job79andClaude Opus 5.5 committed 2026-11-14 16:22:07 +01:00
1 parent 5bb84ade05
commit 29ac7278a1
2 files changed
+21 -26

No files matched your search

+20 -25
View File
@@ -1,9 +1,9 @@
# git-runner OS image # git-runner OS image
# #
# Builds the OS image, with the job image inside, and publishes it as assets of this repository's # Builds the OS image, with the job image inside, and publishes it as a release of this repository.
# "latest" release, where runners fetch their updates (mkosi.extra/usr/lib/sysupdate.d). # Runners fetch their updates from releases/download/latest/ (mkosi.extra/usr/lib/sysupdate.d),
# Runs on every push, weekly for Fedora updates, and by hand. The weekly and manual runs also # which Gitea serves from the newest release. Runs on every push, weekly for Fedora updates, and
# publish the disk image for new installs (git-runner.qcow2). # by hand.
name: os name: os
on: on:
push: push:
@@ -16,7 +16,7 @@ jobs:
os: os:
runs-on: fedora runs-on: fedora
env: env:
API: ${{ github.api_url }}/repos/${{ github.repository }}/releases API: ${{ github.api_url }}/repos/${{ github.repository }}
AUTH: "Authorization: token ${{ github.token }}" AUTH: "Authorization: token ${{ github.token }}"
steps: steps:
- name: Install tools - name: Install tools
@@ -29,26 +29,21 @@ jobs:
working-directory: mkosi.output working-directory: mkosi.output
run: | run: |
zstd -q --rm -T0 -19 git-runner_*.root-*.raw zstd -q --rm -T0 -19 git-runner_*.root-*.raw
qemu-img convert -c -O qcow2 "$(basename git-runner_*.efi .efi).raw" git-runner.qcow2
sha256sum git-runner_*.efi git-runner_*.root-*.raw.zst > SHA256SUMS sha256sum git-runner_*.efi git-runner_*.root-*.raw.zst > SHA256SUMS
- name: Find the release # A draft until its files are uploaded, so "latest" never points at a release without them.
run: | # Then removes all but the newest 3 releases.
release=$(curl -fsS -H "$AUTH" "$API/tags/latest") || - name: Publish
release=$(curl -fsS -H "$AUTH" -H 'Content-Type: application/json' "$API" -d '{"tag_name": "latest", "name": "latest"}')
echo "RELEASE=$API/$(jq .id <<<"$release")" >> "$GITHUB_ENV"
# Uploads the update, then replaces SHA256SUMS, which tells runners it is there, then removes
# older versions.
- name: Publish the update
working-directory: mkosi.output working-directory: mkosi.output
run: | run: |
assets() { curl -fsS -H "$AUTH" "$RELEASE/assets" | jq -r '.[] | "\(.id) \(.name)"'; } version=$(basename git-runner_*.efi .efi)
upload() { curl -fsS -o /dev/null -H "$AUTH" -F "attachment=@$1" "$RELEASE/assets?name=$1"; } version=${version#git-runner_}
delete() { while read -r id _; do curl -fsS -H "$AUTH" -X DELETE "$RELEASE/assets/$id"; done; } id=$(curl -fsS -H "$AUTH" -H 'Content-Type: application/json' "$API/releases" \
for f in $(awk '{print $2}' SHA256SUMS); do upload "$f"; done -d "{\"tag_name\": \"$version\", \"target_commitish\": \"$GITHUB_SHA\", \"draft\": true}" | jq .id)
assets | awk '$2 == "SHA256SUMS"' | delete for f in $(awk '{print $2}' SHA256SUMS) git-runner.qcow2 SHA256SUMS; do
upload SHA256SUMS curl -fsS -o /dev/null -H "$AUTH" -F "attachment=@$f" "$API/releases/$id/assets?name=$f"
assets | awk 'NR == FNR { keep[$2]; next } $2 ~ /^git-runner_/ && !($2 in keep)' SHA256SUMS - | delete done
if [ "${{ github.event_name }}" != push ]; then curl -fsS -o /dev/null -H "$AUTH" -H 'Content-Type: application/json' -X PATCH "$API/releases/$id" -d '{"draft": false}'
qemu-img convert -c -O qcow2 "$(basename git-runner_*.efi .efi).raw" git-runner.qcow2 curl -fsS -H "$AUTH" "$API/releases" | jq -r '.[3:][].tag_name' | while read -r tag; do
assets | awk '$2 == "git-runner.qcow2"' | delete curl -fsS -H "$AUTH" -X DELETE "$API/releases/tags/$tag" && curl -fsS -H "$AUTH" -X DELETE "$API/tags/$tag"
upload git-runner.qcow2 done
fi
+1 -1
View File
@@ -11,7 +11,7 @@ A [Gitea Actions](https://docs.gitea.com/usage/actions/overview) runner packaged
## Install ## Install
Download [the disk image](https://git.plabble.org/Job79/git-runner-mkosi/releases/download/latest/git-runner.qcow2) (built weekly by the `os` workflow), resize it to the disk size you want (/var grows to fill it) and boot it with UEFI. The screen and the serial console ask for a root password, hostname, Gitea URL, registration token and number of parallel jobs; the runner then registers itself. Download [the disk image](https://git.plabble.org/Job79/git-runner-mkosi/releases/download/latest/git-runner.qcow2) (built by the `os` workflow), resize it to the disk size you want (/var grows to fill it) and boot it with UEFI. The screen and the serial console ask for a root password, hostname, Gitea URL, registration token and number of parallel jobs; the runner then registers itself.
## Images ## Images