ci(release): keep a published version immutable
CI / check (push) Successful in 3m26s

The 0.1.7-1 release was built twice: the second run attached a package with a
different sha256 under the same name, so the CDN kept serving bytes from the
first build while the index announced the second, and pacman rejected the
download as an invalid or corrupted package. The release now refuses to replace
a published package whose checksum changed and asks for a pkgrel bump instead,
and it verifies the sha256 of the served file after the upload rather than only
its presence.
This commit is contained in:
BlackAngelTV committed 2026-11-25 20:58:40 +01:00
1 parent af032e3d87
commit 25840c6ce1
3 files changed
+39 -6

No files matched your search

+25 -4
View File
@@ -154,6 +154,23 @@ jobs:
fi
echo "release_id=$release_id"
# A pacman version is immutable: clients cache the package by name and
# repo.laxacube.ch serves it through a CDN, so a rebuild published
# under the same version leaves those caches holding bytes the index
# no longer matches, and pacman reports the file as corrupted. A
# re-run that rebuilds identical bytes stays allowed.
local_sha256="$(cut -d' ' -f1 "$PACKAGE_FILE.sha256")"
published_sha256=""
sha_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/$tag/$PACKAGE_NAME.sha256"
if curl -fsSL "$sha_url" -o "$RUNNER_TEMP/published.sha256"; then
published_sha256="$(cut -d' ' -f1 "$RUNNER_TEMP/published.sha256")"
fi
if [ -n "$published_sha256" ] && [ "$published_sha256" != "$local_sha256" ]; then
echo "::error::$PACKAGE_NAME is already published with sha256 $published_sha256 but this build is $local_sha256"
echo "::error::bump pkgrel in packaging/PKGBUILD so the rebuild is published as its own version"
exit 1
fi
# A re-run must replace its own artefacts instead of failing on them.
assets="$(curl -sS -H "$auth" "$api/releases/$release_id/assets")"
attach() {
@@ -194,15 +211,19 @@ jobs:
-H 'Content-Type: application/octet-stream' \
--data-binary "@$PACKAGE_FILE"
echo
# The index is rebuilt server-side, so wait for the package before
# reporting success.
# The index is rebuilt server-side and the file is served through a
# CDN, so a HEAD is not enough: the index and the file can disagree
# for as long as the CDN caches the previous build under this name,
# and the checksum is exactly what pacman verifies before installing.
url="https://repo.laxacube.ch/x86_64/$PACKAGE_NAME"
expected="$(cut -d' ' -f1 "$PACKAGE_FILE.sha256")"
for _ in 1 2 3 4 5 6; do
if curl -fsSI "$url" > /dev/null; then
if [ "$(curl -fsSL "$url" | sha256sum | cut -d' ' -f1)" = "$expected" ]; then
echo "published $url"
exit 0
fi
sleep 5
done
echo "::error::the upload was accepted but $url is not served yet"
echo "::error::$url does not serve this build (expected sha256 $expected)"
echo "::error::the CDN is probably still caching an older file under this name: purge it before re-running"
exit 1