Files
Chronos/.github/workflows/release.yml
T
Claude 411425b83a 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
2026-10-03 10:07:18 +00:00

353 lines
16 KiB
YAML

name: Release
# A tag vMAJOR.MINOR.PATCH[-PRERELEASE] builds, tests, signs (when certificates are configured) and publishes
# everything (BRIEF §19.3): installers, portable and server zips, SHA256SUMS, release notes, the multi-arch server
# image on GHCR, and the public releases repository content (BRIEF §19.4).
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
tag:
description: "Existing tag to (re)publish, e.g. v0.2.0"
required: true
permissions:
contents: write
packages: write
concurrency:
group: release-${{ github.event.inputs.tag || github.ref_name }}
cancel-in-progress: false
env:
DOTNET_NOLOGO: "1"
DOTNET_CLI_TELEMETRY_OPTOUT: "1"
TOOLS: src/Titano.Tools/bin/Release/net10.0/Titano.Tools.dll
# Public repository that receives releases (BRIEF §19.4). Override with the RELEASES_REPO repository variable. Every
# build embeds it as TitanoReleasesRepo, so the update check, licence and issue links read the repository published to.
RELEASES_REPO: ${{ vars.RELEASES_REPO || format('{0}/titano-releases', github.repository_owner) }}
jobs:
version:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.v.outputs.tag }}
version: ${{ steps.v.outputs.version }}
prerelease: ${{ steps.v.outputs.prerelease }}
steps:
- id: v
env:
TAG: ${{ github.event.inputs.tag || github.ref_name }}
run: |
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "::error title=Release::Tag '$TAG' is not vMAJOR.MINOR.PATCH or vMAJOR.MINOR.PATCH-PRERELEASE"
exit 1
fi
version="${TAG#v}"
{
echo "tag=$TAG"
echo "version=$version"
if [[ "$version" == *-* ]]; then echo "prerelease=true"; else echo "prerelease=false"; fi
} >> "$GITHUB_OUTPUT"
windows:
needs: version
runs-on: windows-latest
defaults:
run:
shell: bash
env:
VERSION: ${{ needs.version.outputs.version }}
# Secrets cannot appear in step conditions: expose only whether signing is configured.
HAS_SIGNING: ${{ secrets.SIGN_PFX_BASE64 != '' }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.version.outputs.tag }}
fetch-depth: 0
- uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Build and test
run: |
dotnet build Titano.slnx -c Release -p:TitanoVersion="$VERSION" -p:TitanoReleasesRepo="$RELEASES_REPO"
for t in Core Data Server Core.Windows App; do
dotnet run --project "tests/Titano.$t.Tests" -c Release --no-build -- --junit "out/junit/$t.xml"
done
- name: Screenshots for the public README
continue-on-error: true
timeout-minutes: 10
run: |
for exe in src/Titano.App/bin/Release/net10.0-windows/Titano.exe src/Titano.Uploader/bin/Release/net10.0-windows/Titano.Uploader.exe; do
"$exe" --capture out/screenshots &
wait $! || echo "::warning title=Screenshots::$(basename "$exe") --capture exited with $?"
done
ls out/screenshots
- name: Publish self-contained programs
run: |
common="-c Release -r win-x64 --self-contained -p:TitanoVersion=$VERSION -p:TitanoReleasesRepo=$RELEASES_REPO -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=none"
dotnet publish src/Titano.App/Titano.App.csproj $common -p:PublishReadyToRun=true -o out/publish/app
dotnet publish src/Titano.Uploader/Titano.Uploader.csproj $common -p:PublishReadyToRun=true -o out/publish/uploader
dotnet publish src/Titano.Server/Titano.Server.csproj $common -o out/publish/server
dotnet publish src/Titano.Setup/Titano.Setup.csproj $common -p:PublishReadyToRun=true -o out/publish/setup
- name: Sign binaries
if: env.HAS_SIGNING == 'true'
env:
SIGN_PFX: ${{ secrets.SIGN_PFX_BASE64 }}
SIGN_PASSWORD: ${{ secrets.SIGN_PASSWORD }}
shell: pwsh
run: |
$pfx = Join-Path $env:RUNNER_TEMP "sign.pfx"
[IO.File]::WriteAllBytes($pfx, [Convert]::FromBase64String($env:SIGN_PFX))
try {
$signtool = Get-ChildItem "${env:ProgramFiles(x86)}\Windows Kits\10\bin\*\x64\signtool.exe" | Sort-Object FullName -Descending | Select-Object -First 1
if (-not $signtool) { throw "signtool.exe not found in the Windows SDK" }
Get-ChildItem out/publish -Recurse -Include *.exe | ForEach-Object {
& $signtool.FullName sign /fd SHA256 /f $pfx /p $env:SIGN_PASSWORD /tr http://timestamp.digicert.com /td SHA256 $_.FullName
if ($LASTEXITCODE -ne 0) { throw "signtool failed for $($_.FullName)" }
}
} finally {
Remove-Item $pfx -ErrorAction SilentlyContinue
}
- name: Package installers and archives
run: |
mkdir -p out/release
dotnet "$TOOLS" pack-installer --setup out/publish/setup/Titano.Setup.exe --product Titano \
--component "Titano=out/publish/app" --component "Uploader=out/publish/uploader" --component "Server=out/publish/server" \
--version "$VERSION" --out "out/release/Titano-Setup-$VERSION.exe"
dotnet "$TOOLS" pack-installer --setup out/publish/setup/Titano.Setup.exe --product "Titano Uploader" \
--component "Uploader=out/publish/uploader" --version "$VERSION" --out "out/release/Titano-Uploader-Setup-$VERSION.exe"
(cd out/publish/server && 7z a -tzip "../../release/Titano-Server-win-x64-$VERSION.zip" . > /dev/null)
# The portable build keeps its data next to Titano.exe because of portable.txt (never inside the installer).
cp -R out/publish/app out/portable
printf 'Titano portable mode: settings, index and logs are kept in the data folder next to Titano.exe.\r\n' > out/portable/portable.txt
(cd out/portable && 7z a -tzip "../release/Titano-win-x64-portable-$VERSION.zip" . > /dev/null)
ls -l out/release
- name: Sign installers
if: env.HAS_SIGNING == 'true'
env:
SIGN_PFX: ${{ secrets.SIGN_PFX_BASE64 }}
SIGN_PASSWORD: ${{ secrets.SIGN_PASSWORD }}
shell: pwsh
run: |
$pfx = Join-Path $env:RUNNER_TEMP "sign.pfx"
[IO.File]::WriteAllBytes($pfx, [Convert]::FromBase64String($env:SIGN_PFX))
try {
$signtool = Get-ChildItem "${env:ProgramFiles(x86)}\Windows Kits\10\bin\*\x64\signtool.exe" | Sort-Object FullName -Descending | Select-Object -First 1
Get-ChildItem out/release -Filter *.exe | ForEach-Object {
& $signtool.FullName sign /fd SHA256 /f $pfx /p $env:SIGN_PASSWORD /tr http://timestamp.digicert.com /td SHA256 $_.FullName
if ($LASTEXITCODE -ne 0) { throw "signtool failed for $($_.FullName)" }
}
} finally {
Remove-Item $pfx -ErrorAction SilentlyContinue
}
- name: Unsigned build notice
if: env.HAS_SIGNING != 'true'
run: echo "::notice title=Signing::SIGN_PFX_BASE64 is not set; the installers are unsigned."
- name: Release notes
env:
TAG: ${{ needs.version.outputs.tag }}
run: |
# 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
- uses: actions/upload-artifact@v4
with:
name: release-windows
if-no-files-found: error
path: |
out/release/
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, windows]
runs-on: ubuntu-latest
outputs:
image: ${{ steps.image.outputs.name }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.version.outputs.tag }}
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Image name
id: image
run: echo "name=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/titano-server" >> "$GITHUB_OUTPUT"
- uses: docker/build-push-action@v6
with:
context: .
file: deploy/docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
build-args: TITANO_VERSION=${{ needs.version.outputs.version }}
tags: ${{ steps.image.outputs.name }}:${{ needs.version.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
publish:
needs: [version, windows, docker]
runs-on: ubuntu-latest
env:
TAG: ${{ needs.version.outputs.tag }}
VERSION: ${{ needs.version.outputs.version }}
PRERELEASE: ${{ needs.version.outputs.prerelease }}
IMAGE: ${{ needs.docker.outputs.image }}
HAS_RELEASES_TOKEN: ${{ secrets.RELEASES_TOKEN != '' }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.version.outputs.tag }}
- uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- uses: actions/download-artifact@v4
with:
name: release-windows
path: out
- name: Checksums
working-directory: out/release
run: |
rm -f SHA256SUMS
sha256sum -- * > "$RUNNER_TEMP/SHA256SUMS"
mv "$RUNNER_TEMP/SHA256SUMS" SHA256SUMS
cat SHA256SUMS
- name: Release target
id: target
env:
GH_TOKEN: ${{ env.HAS_RELEASES_TOKEN == 'true' && secrets.RELEASES_TOKEN || secrets.GITHUB_TOKEN }}
run: |
if [ "$HAS_RELEASES_TOKEN" = "true" ]; then
repo="$RELEASES_REPO"
else
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), 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
if [ "$PRERELEASE" = "true" ] || [ "$(printf '%s\n%s\n' "${latest#v}" "$VERSION" | sort -V | tail -n 1)" != "$VERSION" ]; then
newest=false
fi
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 and :latest are left as they are."
fi
{
echo "repo=$repo"
echo "newest=$newest"
} >> "$GITHUB_OUTPUT"
- 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:
GH_TOKEN: ${{ secrets.RELEASES_TOKEN }}
run: |
branch="$(gh api "repos/$RELEASES_REPO" --jq .default_branch)"
git clone --depth 1 "https://x-access-token:${GH_TOKEN}@github.com/${RELEASES_REPO}.git" public
git -C public checkout -B "$branch"
cp -R deploy/releases-repo/. public/
mkdir -p public/unraid public/docker public/screenshots
cp deploy/unraid/titano.xml public/unraid/titano.xml
cp deploy/docker/docker-compose.yml deploy/docker/.env.example public/docker/
dotnet run --project src/Titano.Tools -c Release -- make-icon --out "$RUNNER_TEMP/icons"
cp "$RUNNER_TEMP/icons/titano-server-256.png" public/unraid/titano-server.png
rm -rf public/i18n
cp -R i18n public/i18n
cp out/release/SHA256SUMS public/SHA256SUMS
for shot in library jobs settings-rendering server uploader-queue; do
if [ -f "out/screenshots/$shot-dark.png" ]; then cp "out/screenshots/$shot-dark.png" public/screenshots/; fi
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/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"
git add -A
if git diff --cached --quiet; then
echo "Public repository already up to date."
else
git commit -q -m "chore: update for $TAG"
git push origin "HEAD:$branch"
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" ] && [ "$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
echo '```'
cat out/release/SHA256SUMS
echo '```'
} >> "$GITHUB_STEP_SUMMARY"