fix(release): decide channels from every page and never fail after publishing
The release step decided :latest and the releases repository's content after the Gitea release was already public, and could then fail or decide wrongly (owner review 2, phase 1 review): - Re-publishing v0.1.0-rc.1 or rc.2 builds Chronos.Tools from the tag, which has no release-channels: the step failed after publishing and the image job never ran. Any failure to decide (a tag older than the command, an unreadable page, a body that is not a list) now warns and moves no channel, so the version's image is still pushed. - Only the first page (50, newest first) of releases was read, and pre-releases now share it with stable ones: 50 pre-releases after a stable release hid it and moved :latest to a pre-release. The workflow reads every page up to the first empty one (at most 100) and release-channels takes one --releases file per page (Args.GetAll). - The Version step accepted tags release-channels refuses (v01.2.0), which then failed only after publishing. It now uses release-channels' SemVer 2.0 pattern without +BUILD, and a test keeps the two in step. BRIEF §19.3, DECISIONS, CHANGELOG and README step 5 say so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a34b33d50b
commit
b2aeb2f587
8 files changed
+129
-40
No files matched your search
@@ -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"
|
||||
|
||||
Reference in new issue
Block a user