ci(release): skip publishing an already published version
CI / check (push) Failing after 5s

This commit is contained in:
BlackAngelTV committed 2026-11-25 21:16:19 +01:00
1 parent a3d0fd38b7
commit 70befe3802
3 files changed
+33 -21

No files matched your search

+26 -17
View File
@@ -129,6 +129,29 @@ jobs:
tag="v$VERSION"
auth="Authorization: token $RELEASE_TOKEN"
# A pacman version is immutable: the repository index, the CDN in
# front of it and every client cache the package by its name, so a
# second build published under the same name leaves them disagreeing
# and pacman reports the download as corrupted. Once repo.laxacube.ch
# serves the name there is nothing left to publish: a re-run is a
# no-op, and a changed build needs a pkgrel bump so it gets its own
# package name.
local_sha256="$(cut -d' ' -f1 "$PACKAGE_FILE.sha256")"
repo_sha256=""
if curl -fsSL "https://repo.laxacube.ch/x86_64/$PACKAGE_NAME" -o "$RUNNER_TEMP/repo.pkg" 2>/dev/null; then
repo_sha256="$(sha256sum "$RUNNER_TEMP/repo.pkg" | cut -d' ' -f1)"
fi
if [ -n "$repo_sha256" ]; then
if [ "$repo_sha256" = "$local_sha256" ]; then
echo "$PACKAGE_NAME is already published to repo.laxacube.ch, nothing to do"
else
echo "::warning::$PACKAGE_NAME is already published to repo.laxacube.ch with sha256 $repo_sha256, this build is $local_sha256 and is not published"
echo "::warning::bump pkgrel in packaging/PKGBUILD to publish this build under its own package name"
fi
echo "SKIP_PUBLISH=1" >> "$GITHUB_ENV"
exit 0
fi
release_id="$(curl -sS -H "$auth" "$api/releases/tags/$tag" | python3 -c '
import json, sys
try:
@@ -154,23 +177,6 @@ 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() {
@@ -195,6 +201,9 @@ jobs:
attach "$PACKAGE_FILE.sha256" "$PACKAGE_NAME.sha256"
- name: Push the package to repo.laxacube.ch
# Skipped when the release step found the version already published, so
# a re-run can never replace the bytes pacman clients are served.
if: env.SKIP_PUBLISH != '1'
env:
REPO_TOKEN: ${{ secrets.REPO_TOKEN }}
PACKAGE_NAME: ${{ steps.package.outputs.name }}