ci: a Release workflow publishes a prerelease from main on request, so a release no longer needs the maintainer's machine

Actions > Release > Run workflow on main with the tag: the job builds the 5.4 kernel (kernel/build-all.sh), the
mainline 6.18 and 7.2 kernels with their modules, keeps the kernel outputs in the Actions cache by the tree they were
built from, runs tools/make-release.sh --publish --prerelease and dispatches the Magisk zips (a release made with the
workflow's token does not start that workflow by itself). It refuses a ref other than main and a tag or release that
exists, so a side branch can never be tagged again and a published release's assets are never built over; its
permissions are the job's only. The config merge logs of a failed 5.4 build are uploaded as an artifact.

kernel/build-all.sh: on a Linux docker the container's outputs are root's, so they are handed to the user through the
build image before the copy, the cleanup of the scratch copy no longer fails a finished build, and MU300_KBUILD_LOGS
names a directory that keeps the merge logs and the rejected fragment options the cleanup would otherwise remove.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DqKKtBQZCfxYnHuBCuDqqn
This commit is contained in:
Abdurrahman Kaan DikeçandClaude Fable 5.1 committed 2026-10-09 09:21:32 +03:00
1 parent 94e71e2b39
commit 4168cb4f5e
2 files changed
+184 -1

No files matched your search

+174
View File
@@ -0,0 +1,174 @@
name: Release
# The whole release on a GitHub arm64 runner: the vendor 5.4 kernel (kernel/build-all.sh), the mainline 6.18 and 7.2
# kernels with their modules (upstream/build.sh, build-modules.sh), then tools/make-release.sh, which builds the root
# filesystems and the extras, audits every asset and publishes the release. Actions > Release > Run workflow on main,
# with the tag: a prerelease by default, which the installers and mu300-update do not offer until the maintainer has
# tried it on a device and promoted it on GitHub (gh release edit TAG --prerelease=false --latest). The release's commit
# is the main commit the workflow ran on, and nothing else: the job refuses another ref, and a tag or release that
# already exists. The Magisk zips follow by the Magisk installers workflow, started at the end (a release made with the
# workflow's own token does not start it by itself). A release published by hand with tools/make-release.sh does not
# start this workflow: it only ever runs when asked.
on:
workflow_dispatch:
inputs:
tag:
description: 'Release tag, e.g. v2026.10.12'
required: true
prerelease:
description: 'Publish as a prerelease'
type: boolean
default: true
kv618:
description: 'The 6.18 kernel to build (empty: the newest 6.18 longterm on kernel.org)'
required: false
kv72:
description: 'The 7.2 kernel to build (empty: the newest 7.2 on kernel.org)'
required: false
concurrency:
group: release-${{ github.ref_name }}
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-24.04-arm
timeout-minutes: 340
permissions:
contents: write # the release and its assets
actions: write # the Magisk installers dispatch at the end
env:
TAG: ${{ inputs.tag }}
GH_TOKEN: ${{ github.token }}
MU300_REPO: ${{ github.repository }}
steps:
- name: Tag and ref
run: |
[ "$GITHUB_REF_NAME" = main ] || { echo "releases come from main, not $GITHUB_REF_NAME"; exit 1; }
tag_ok=1
case "$TAG" in v[0-9]*) ;; *) tag_ok= ;; esac
case "$TAG" in *[!0-9A-Za-z._-]*|*..*) tag_ok= ;; esac
[ -n "$tag_ok" ] || { echo "not a release tag: $TAG"; exit 1; }
echo "release $TAG from $GITHUB_REF_NAME@$GITHUB_SHA"
- uses: actions/checkout@v5
# make-release.sh adds to a release that exists (its retry path for a hand run); the workflow must never build
# over one, nor tag a second commit with a name a tag has
- name: Not yet released
run: |
if gh release view "$TAG" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1; then echo "release $TAG exists"; exit 1; fi
[ -z "$(git ls-remote --tags origin "refs/tags/$TAG")" ] || { echo "tag $TAG exists"; exit 1; }
# Everything that uses docker runs as root: on a Linux docker the containers write their outputs as root, the
# scripts' own cleanups (rm -rf of a directory a container filled) fail for anyone else, and a docker client
# run as root once leaves its buildx lock behind for the user's next one. The maintainer's Docker Desktop
# hands the files to the user, which is why the scripts never needed to care.
- name: Tools
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq lz4 cpio zip unzip >/dev/null
sudo python3 -m pip install -q lz4 || sudo python3 -m pip install -q --break-system-packages lz4
sudo git config --system --add safe.directory "$GITHUB_WORKSPACE"
docker version --format 'docker {{.Server.Version}} {{.Server.Arch}}'
df -h / | tail -1
- name: Kernel versions
id: kv
env:
KV618: ${{ inputs.kv618 }}
KV72: ${{ inputs.kv72 }}
run: |
curl -fsSL https://www.kernel.org/releases.json | KV618="$KV618" KV72="$KV72" python3 -c '
import json, os, re, sys
vs = [x["version"] for x in json.load(sys.stdin)["releases"] if re.fullmatch(r"[0-9]+\.[0-9]+\.[0-9]+", x["version"])]
def newest(series):
got = sorted((v for v in vs if v.startswith(series + ".")), key=lambda v: [int(p) for p in v.split(".")])
return got[-1] if got else sys.exit("no %s kernel on kernel.org" % series)
for name, series in (("kv618", "6.18"), ("kv72", "7.2")):
v = os.environ[name.upper()] or newest(series)
if not re.fullmatch(series.replace(".", r"\.") + r"\.[0-9]+", v): sys.exit("not a %s kernel: %s" % (series, v))
print(name + "=" + v)
' | tee -a "$GITHUB_OUTPUT"
# what each kernel is built from: the git tree of its directory (the same inputs give the same outputs)
echo "tree54=$(git rev-parse HEAD:kernel)" >> "$GITHUB_OUTPUT"
echo "treeup=$(git rev-parse HEAD:upstream)" >> "$GITHUB_OUTPUT"
# The kernel outputs are kept in the Actions cache by the tree they were built from: a release whose kernel
# inputs did not change (most of them) skips the builds, and a run that fails later does not redo them.
- name: Vendor 5.4 kernel outputs from the cache
id: c54
uses: actions/cache/restore@v4
with:
path: out
key: kernel-5.4-${{ steps.kv.outputs.tree54 }}
- name: Vendor 5.4 kernel and modules
if: steps.c54.outputs.cache-hit != 'true'
env:
# the config merge logs and the rejected fragment options, which build-all.sh otherwise removes with its
# scratch copy of kernel/ (the compiler's errors are on stdout above)
MU300_KBUILD_LOGS: ${{ runner.temp }}/kernel-5.4-logs
run: sudo -E sh kernel/build-all.sh
- name: Vendor 5.4 kernel logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: kernel-5.4-logs
path: ${{ runner.temp }}/kernel-5.4-logs
if-no-files-found: ignore
- if: steps.c54.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: out
key: kernel-5.4-${{ steps.kv.outputs.tree54 }}
- name: Mainline 6.18 outputs from the cache
id: c618
uses: actions/cache/restore@v4
with:
path: upstream/out
key: kernel-${{ steps.kv.outputs.kv618 }}-${{ steps.kv.outputs.treeup }}
- name: Mainline 7.2 outputs from the cache
id: c72
uses: actions/cache/restore@v4
with:
path: upstream/out-7.2
key: kernel-${{ steps.kv.outputs.kv72 }}-${{ steps.kv.outputs.treeup }}
- name: Mainline build environment
if: steps.c618.outputs.cache-hit != 'true' || steps.c72.outputs.cache-hit != 'true'
run: |
sudo -E docker build -t mu300-mainline-build upstream/
sudo -E docker volume create mu300-mainline
- name: Mainline 6.18
if: steps.c618.outputs.cache-hit != 'true'
env:
KV: ${{ steps.kv.outputs.kv618 }}
run: |
sudo -E docker run --rm -e KV="$KV" -v mu300-mainline:/src -v "$PWD/upstream":/work mu300-mainline-build bash /work/build.sh
sudo -E docker run --rm -e KV="$KV" -v mu300-mainline:/src -v "$PWD/upstream":/work mu300-mainline-build bash /work/build-modules.sh > /dev/null
ls upstream/out/modules/*.ko | wc -l
- if: steps.c618.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: upstream/out
key: kernel-${{ steps.kv.outputs.kv618 }}-${{ steps.kv.outputs.treeup }}
- name: Mainline 7.2
if: steps.c72.outputs.cache-hit != 'true'
env:
KV: ${{ steps.kv.outputs.kv72 }}
run: |
sudo -E docker run --rm -e KV="$KV" -e OUTDIR=out-7.2 -v mu300-mainline:/src -v "$PWD/upstream":/work mu300-mainline-build bash /work/build.sh
sudo -E docker run --rm -e KV="$KV" -e OUTDIR=out-7.2 -v mu300-mainline:/src -v "$PWD/upstream":/work mu300-mainline-build bash /work/build-modules.sh > /dev/null
ls upstream/out-7.2/modules/*.ko | wc -l
- if: steps.c72.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: upstream/out-7.2
key: kernel-${{ steps.kv.outputs.kv72 }}-${{ steps.kv.outputs.treeup }}
- name: Build logs
if: failure()
run: tail -n 60 upstream/out/modules/*.log upstream/out-7.2/modules/*.log 2>/dev/null || true
- name: Root filesystems, extras, audit, publish
env:
INPUT_PRERELEASE: ${{ inputs.prerelease }}
run: |
pre=; [ "$INPUT_PRERELEASE" != true ] || pre=--prerelease
# the build outputs are ignored by git, so the tree is still the commit the release says it is
sudo -E git status --porcelain
sudo -E sh tools/make-release.sh "$TAG" --publish $pre
- name: Magisk installers
run: gh workflow run magisk.yml -R "$GITHUB_REPOSITORY" --ref main -f tag="$TAG"
+10 -1
View File
@@ -17,7 +17,15 @@ MODULES_REV=4381465ccaf87fcf3215b9cd42f4a685df40e5e0
docker build -q -t mu300-kbuild "$TOP/kernel" >/dev/null
docker volume create "$VOL" >/dev/null
W=$(mktemp -d)
trap 'rm -rf "$W"' EXIT
# on a Linux docker the container writes as root: the outputs are handed to the user below, and a cleanup that
# still cannot remove something does not fail the build that has already copied them out. The config merge logs and
# the rejected fragment options go with the scratch copy, unless MU300_KBUILD_LOGS names a directory to keep them in
# (the release workflow does, for a failed build).
cleanup() {
[ -z "${MU300_KBUILD_LOGS:-}" ] || { mkdir -p "$MU300_KBUILD_LOGS" && cp "$W"/*.log "$W"/fragment-rejected.txt "$MU300_KBUILD_LOGS/"; } 2>/dev/null || true
rm -rf "$W" 2>/dev/null || true
}
trap cleanup EXIT
# build-linux.sh writes its logs next to the config: give it a scratch copy of kernel/
cp -R "$TOP/kernel/." "$W/"
cp "$TOP/kernel/f50-stock-B09.config" "$W/device.config"
@@ -87,6 +95,7 @@ echo "$(ls /work/out/modules | wc -l) modules, $(strings /work/out/Image | grep
echo "==> ZTE U30 Air modules"
bash /work/build-u30air.sh
'
docker run --rm -v "$W":/work mu300-kbuild chown -R "$(id -u):$(id -g)" /work/out
mkdir -p "$OUT"
rm -rf "$OUT/modules" "$OUT/modules-u30air"
cp -R "$W/out/." "$OUT/"