From 9de046c60317cef87bec0851e8591d5488e346f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Bene=C5=A1?= Date: Tue, 1 Dec 2026 22:56:46 +0000 Subject: [PATCH] A GitHub Release for a tag, made from the signed Gitea release of the same tag ide/install.sh reads GitHub's releases by default, and a mirror carries none: the workflow waits for the Gitea release, checks it as the installer would, and publishes the same files. Co-Authored-By: Claude Fable 5.2 --- .github/workflows/release.yml | 65 +++++++++++++++++++++++++++++++++++ scripts/hygiene.sh | 9 ++++- 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f1246f0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,65 @@ +# The GitHub Release for a tag, made from the Gitea release of the same tag. LLeMbas IDE is developed +# on Gitea (git.houmeres.sk/LLeMbas/LLeMbas-IDE), which mirrors its commits and tags here; a mirror carries no Releases, +# and GitHub's are what ide/install.sh reads by default. So when a tag arrives this waits for Gitea's +# release to have its files, checks them exactly as the installer would — SHA256SUMS signed by the +# release key, every file matching — and publishes the same files and notes. Nothing is built here. +name: release +on: + push: + tags: ["v*"] + # By hand, for a tag that arrived without starting this. + workflow_dispatch: + inputs: + tag: + description: "The tag, e.g. v1.0.0" + required: true + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + timeout-minutes: 60 + env: + GITEA: https://git.houmeres.sk + # The repository on Gitea (the same name as on GitHub). + REPO: LLeMbas/LLeMbas-IDE + TAG: ${{ inputs.tag || github.ref_name }} + PUBKEY: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDSZO3Byow7R3ZpOH3MCvpPIga2pZBzhfX5wXfNP1cLa" + steps: + - name: Wait for the Gitea release and its files + run: | + # The tag is mirrored as soon as it is pushed; the release and its files come minutes later. + for i in $(seq 1 50); do + if curl -fsSL "$GITEA/api/v1/repos/$REPO/releases/tags/$TAG" -o release.json && + jq -e '[.assets[].name] | index("SHA256SUMS.sig") and index("SHA256SUMS") and index("install.sh")' release.json >/dev/null; then + exit 0 + fi + sleep 60 + done + echo "no Gitea release for $TAG with its files after 50 minutes" >&2 + exit 1 + - name: Download and check the files + run: | + mkdir files + jq -r '.assets[].name' release.json > names + while IFS= read -r name; do + case "$name" in */* | .* | "") echo "a file name that is not one: $name" >&2; exit 1 ;; esac + curl -fsSL -o "files/$name" "$GITEA/$REPO/releases/download/$TAG/$name" + done < names + cd files + # Signed in the namespace lembas-release. + printf 'lembas-release %s\n' "$PUBKEY" > ../allowed + ssh-keygen -Y verify -f ../allowed -I lembas-release -n lembas-release -s SHA256SUMS.sig < SHA256SUMS || { echo "SHA256SUMS is not signed by the release key" >&2; exit 1; } + sha256sum -c --strict SHA256SUMS + [ -f "llembas-ide-${TAG#v}.tar.gz" ] || { echo "no llembas-ide-${TAG#v}.tar.gz in the release" >&2; exit 1; } + for f in *; do case "$f" in SHA256SUMS | SHA256SUMS.sig) continue ;; esac; grep -q " $f\$" SHA256SUMS || { echo "$f is not in SHA256SUMS" >&2; exit 1; }; done + - name: Publish the GitHub Release + env: + GH_TOKEN: ${{ github.token }} + run: | + jq -r .body release.json > notes.md + pre="" + case "$TAG" in *-beta.*) pre="--prerelease" ;; esac + gh release create "$TAG" --repo "$GITHUB_REPOSITORY" --verify-tag --title "$(jq -r .name release.json)" --notes-file notes.md $pre files/* diff --git a/scripts/hygiene.sh b/scripts/hygiene.sh index 8de8d9f..47845e1 100755 --- a/scripts/hygiene.sh +++ b/scripts/hygiene.sh @@ -18,11 +18,18 @@ patterns=( '\bgamebox\b' '\bthor\b' ) +# What is allowed to match, each for a reason — a line of `file:line:text` as grep prints it: +allowed=( + # The public forge the releases are made on: the workflow that republishes them must name it. + '^\.github/workflows/release\.yml:[0-9]+:.*git\.houmeres\.sk' +) +allow="$(IFS='|'; echo "${allowed[*]}")" + found=0 for pattern in "${patterns[@]}"; do # The output decides, not the exit status: xargs answers 123 when any one batch of files has no # match, and grep 2 on an error -- either would have read as "clean" around real matches. - hits=$(git ls-files -z | grep -zv '^scripts/hygiene.sh$' | xargs -0 grep -nIEi -- "$pattern" 2>/dev/null || true) + hits=$(git ls-files -z | grep -zv '^scripts/hygiene.sh$' | xargs -0 grep -nIEi -- "$pattern" 2>/dev/null | grep -vE -- "$allow" || true) if [ -n "$hits" ]; then printf '%s\n' "$hits" echo "hygiene: the lines above match /$pattern/" >&2