Merge branch 'review2-p1-fix-release' into claude/owner-review-2-p1

This commit is contained in:
Alby96 committed 2026-10-26 23:40:39 +01:00
commit 5dfd5f93cf
8 files changed
+129 -40

No files matched your search

+27 -6
View File
@@ -54,7 +54,10 @@ jobs:
- name: Version
id: version
run: |
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
# SemVer 2.0 as release-channels reads it (no leading zeros, no empty identifiers), without +BUILD, which an
# image tag cannot hold: a tag it would refuse stops here, before anything is built or published.
semver='^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(\.(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*)?$'
if [[ ! "$TAG" =~ $semver ]]; then
echo "::error title=Release::Tag '$TAG' is not vMAJOR.MINOR.PATCH or vMAJOR.MINOR.PATCH-PRERELEASE"
exit 1
fi
@@ -197,11 +200,29 @@ jobs:
# most recently created one), so re-publishing an older tag never rolls a channel back. latest: the public
# content follows the highest stable release. image_latest: :latest follows it too, or the highest pre-release
# while no stable release exists, so compose and Unraid users find an image from the first pre-release on.
releases="$RUNNER_TEMP/releases.json"
curl -fsS -H "Authorization: token $token" -o "$releases" "${{ github.server_url }}/api/v1/repos/$TARGET/releases?draft=false&limit=50"
channels="$(dotnet "$TOOLS" release-channels --tag "$TAG" --releases "$releases")"
latest="$(printf '%s\n' "$channels" | sed -n 's/^latest=//p')"
image_latest="$(printf '%s\n' "$channels" | sed -n 's/^image_latest=//p')"
# Gitea lists 50 releases a page, newest first: every page up to the first empty one counts (at most 100).
channels() {
local page file pages=()
for ((page = 1; page <= 100; page++)); do
file="$RUNNER_TEMP/releases-$page.json"
curl -fsS -H "Authorization: token $token" -o "$file" "${{ github.server_url }}/api/v1/repos/$TARGET/releases?draft=false&limit=50&page=$page" || return
pages+=(--releases "$file")
if ! grep -q '"tag_name"' "$file"; then
dotnet "$TOOLS" release-channels --tag "$TAG" "${pages[@]}"
return
fi
done
echo "More than 100 pages of releases." >&2
return 1
}
# The release is already published: when its channels cannot be decided (the list unreadable, or a tag older
# than release-channels, such as v0.1.0-rc.2, whose Chronos.Tools lacks the command) it moves neither.
if ! decided="$(channels)"; then
echo "::warning title=Release::The channels of $TAG could not be decided (see the error above): it moves neither the releases repository nor :latest."
decided="$(printf 'latest=false\nimage_latest=false')"
fi
latest="$(printf '%s\n' "$decided" | sed -n 's/^latest=//p')"
image_latest="$(printf '%s\n' "$decided" | sed -n 's/^image_latest=//p')"
echo "Releases of $TARGET: $TAG moves the public content: $latest; :latest: $image_latest"
{ echo "latest=$latest"; echo "image_latest=$image_latest"; } >> "$GITHUB_OUTPUT"
{ echo "LATEST=$latest"; echo "IMAGE_LATEST=$image_latest"; } >> "$GITHUB_ENV"