ci(release): push the image only after the tests, move :latest after the release
- The docker job waits for the Windows build and tests and pushes only :<v>; publish moves :latest with imagetools once the GitHub release exists and the tag is the newest stable one, so a failed or older re-published tag never moves it. - The GitHub release is created before the public repository content, so the public SHA256SUMS never describes a release that does not exist. - Stable release notes start from the previous stable tag. - Raw links to the public repository follow its default branch. - Public README and bug form name the Diagnostics row and its button. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
4 files changed
+64
-40
No files matched your search
@@ -157,7 +157,12 @@ jobs:
|
||||
env:
|
||||
TAG: ${{ needs.version.outputs.tag }}
|
||||
run: |
|
||||
previous="$(git describe --tags --abbrev=0 "$TAG^" 2>/dev/null || true)"
|
||||
# A stable release lists everything since the previous stable one, not only what followed its last pre-release.
|
||||
if [[ "$TAG" == *-* ]]; then
|
||||
previous="$(git describe --tags --abbrev=0 "$TAG^" 2>/dev/null || true)"
|
||||
else
|
||||
previous="$(git describe --tags --abbrev=0 --exclude '*-*' "$TAG^" 2>/dev/null || true)"
|
||||
fi
|
||||
range="${previous:+$previous..}$TAG"
|
||||
git log --no-merges --format='%h%x09%s' "$range" | dotnet "$TOOLS" changelog --title "Titano $VERSION" --out out/release-notes.md
|
||||
cat out/release-notes.md
|
||||
@@ -171,8 +176,10 @@ jobs:
|
||||
out/release-notes.md
|
||||
out/screenshots/
|
||||
|
||||
# Pushes only the version tag, and only after the Windows job's tests passed; publish moves :latest once the GitHub
|
||||
# release exists and the tag is the newest stable one.
|
||||
docker:
|
||||
needs: version
|
||||
needs: [version, windows]
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
image: ${{ steps.image.outputs.name }}
|
||||
@@ -197,9 +204,7 @@ jobs:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
build-args: TITANO_VERSION=${{ needs.version.outputs.version }}
|
||||
tags: |
|
||||
${{ steps.image.outputs.name }}:${{ needs.version.outputs.version }}
|
||||
${{ needs.version.outputs.prerelease == 'false' && format('{0}:latest', steps.image.outputs.name) || '' }}
|
||||
tags: ${{ steps.image.outputs.name }}:${{ needs.version.outputs.version }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
@@ -243,8 +248,9 @@ jobs:
|
||||
repo="$GITHUB_REPOSITORY"
|
||||
echo "::notice title=Release::RELEASES_TOKEN is not set: publishing to $GITHUB_REPOSITORY instead of $RELEASES_REPO (clients only see releases of $RELEASES_REPO)."
|
||||
fi
|
||||
# The public content (README, EULA, i18n/, SHA256SUMS) follows the newest stable release, so re-publishing an
|
||||
# older tag or publishing a pre-release never rolls it back; until a stable release exists, every tag updates it.
|
||||
# The public content (README, EULA, i18n/, SHA256SUMS), the GitHub "Latest" marker and the image's :latest tag
|
||||
# follow the newest stable release, so re-publishing an older tag or publishing a pre-release never rolls them
|
||||
# back; until a stable release exists, every tag updates the public content.
|
||||
latest="$(gh release view --repo "$repo" --json tagName --jq .tagName 2>/dev/null || true)"
|
||||
newest=true
|
||||
if [ -n "$latest" ] && [ "$latest" != "$TAG" ]; then
|
||||
@@ -254,7 +260,7 @@ jobs:
|
||||
fi
|
||||
echo "Latest release of $repo: ${latest:-none}; $TAG is the newest: $newest"
|
||||
if [ "$newest" = "false" ]; then
|
||||
echo "::notice title=Release::$TAG is older than $latest or a pre-release: the public repository content is left as it is."
|
||||
echo "::notice title=Release::$TAG is older than $latest or a pre-release: the public repository content and :latest are left as they are."
|
||||
fi
|
||||
{
|
||||
echo "repo=$repo"
|
||||
@@ -264,6 +270,35 @@ jobs:
|
||||
- name: Validate the public issue forms
|
||||
run: ruby .github/scripts/check-yaml.rb deploy/releases-repo/.github/ISSUE_TEMPLATE/*.yml
|
||||
|
||||
- name: GitHub release
|
||||
env:
|
||||
GH_TOKEN: ${{ env.HAS_RELEASES_TOKEN == 'true' && secrets.RELEASES_TOKEN || secrets.GITHUB_TOKEN }}
|
||||
TARGET: ${{ steps.target.outputs.repo }}
|
||||
NEWEST: ${{ steps.target.outputs.newest }}
|
||||
run: |
|
||||
# An older stable tag published again must not become "Latest" (the update check reads releases/latest).
|
||||
latest=()
|
||||
if [ "$PRERELEASE" = "false" ] && [ "$NEWEST" = "false" ]; then latest=(--latest=false); fi
|
||||
if gh release view "$TAG" --repo "$TARGET" > /dev/null 2>&1; then
|
||||
gh release upload "$TAG" out/release/* --repo "$TARGET" --clobber
|
||||
gh release edit "$TAG" --repo "$TARGET" --title "Titano $VERSION" --notes-file out/release-notes.md --prerelease="$PRERELEASE" "${latest[@]}"
|
||||
else
|
||||
gh release create "$TAG" out/release/* --repo "$TARGET" --title "Titano $VERSION" --notes-file out/release-notes.md --prerelease="$PRERELEASE" "${latest[@]}"
|
||||
fi
|
||||
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
if: env.PRERELEASE == 'false' && steps.target.outputs.newest == 'true'
|
||||
- uses: docker/login-action@v3
|
||||
if: env.PRERELEASE == 'false' && steps.target.outputs.newest == 'true'
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Move the image's latest tag
|
||||
if: env.PRERELEASE == 'false' && steps.target.outputs.newest == 'true'
|
||||
# Compose and Unraid users follow :latest; it moves only once the release exists, never back to an older server.
|
||||
run: docker buildx imagetools create --tag "$IMAGE:latest" "$IMAGE:$VERSION"
|
||||
|
||||
- name: Update the public releases repository
|
||||
if: env.HAS_RELEASES_TOKEN == 'true' && steps.target.outputs.newest == 'true'
|
||||
env:
|
||||
@@ -286,7 +321,8 @@ jobs:
|
||||
done
|
||||
# Links in the published files follow the configured repository and the image the docker job pushed.
|
||||
find public -path public/.git -prune -o -type f \( -name '*.md' -o -name '*.yml' -o -name '*.xml' \) -print0 |
|
||||
xargs -0 -r sed -i -e "s#alby96/titano-releases#${RELEASES_REPO}#g" -e "s#ghcr.io/alby96/titano-server#${IMAGE}#g"
|
||||
xargs -0 -r sed -i -e "s#alby96/titano-releases/main/#${RELEASES_REPO}/${branch}/#g" -e "s#alby96/titano-releases#${RELEASES_REPO}#g" \
|
||||
-e "s#ghcr.io/alby96/titano-server#${IMAGE}#g"
|
||||
cd public
|
||||
git config user.name "titano-release"
|
||||
git config user.email "titano-release@users.noreply.github.com"
|
||||
@@ -298,30 +334,15 @@ jobs:
|
||||
git push origin "HEAD:$branch"
|
||||
fi
|
||||
|
||||
- name: GitHub release
|
||||
env:
|
||||
GH_TOKEN: ${{ env.HAS_RELEASES_TOKEN == 'true' && secrets.RELEASES_TOKEN || secrets.GITHUB_TOKEN }}
|
||||
TARGET: ${{ steps.target.outputs.repo }}
|
||||
NEWEST: ${{ steps.target.outputs.newest }}
|
||||
run: |
|
||||
# An older stable tag published again must not become "Latest" (the update check reads releases/latest).
|
||||
latest=()
|
||||
if [ "$PRERELEASE" = "false" ] && [ "$NEWEST" = "false" ]; then latest=(--latest=false); fi
|
||||
if gh release view "$TAG" --repo "$TARGET" > /dev/null 2>&1; then
|
||||
gh release upload "$TAG" out/release/* --repo "$TARGET" --clobber
|
||||
gh release edit "$TAG" --repo "$TARGET" --title "Titano $VERSION" --notes-file out/release-notes.md --prerelease="$PRERELEASE" "${latest[@]}"
|
||||
else
|
||||
gh release create "$TAG" out/release/* --repo "$TARGET" --title "Titano $VERSION" --notes-file out/release-notes.md --prerelease="$PRERELEASE" "${latest[@]}"
|
||||
fi
|
||||
|
||||
- name: Summary
|
||||
env:
|
||||
TARGET: ${{ steps.target.outputs.repo }}
|
||||
NEWEST: ${{ steps.target.outputs.newest }}
|
||||
run: |
|
||||
{
|
||||
echo "## Titano $VERSION"
|
||||
echo "- Release: https://github.com/$TARGET/releases/tag/$TAG"
|
||||
echo "- Image: \`$IMAGE:$VERSION\`$([ "$PRERELEASE" = "false" ] && echo " and \`:latest\`")"
|
||||
echo "- Image: \`$IMAGE:$VERSION\`$([ "$PRERELEASE" = "false" ] && [ "$NEWEST" = "true" ] && echo " and \`:latest\`")"
|
||||
echo "- GHCR packages are private when first pushed and GitHub has no API to change that: once, open the"
|
||||
echo " package settings of \`titano-server\` and set its visibility to **Public** (BRIEF §19.4)."
|
||||
echo
|
||||
|
||||
Reference in new issue
Block a user