diff --git a/.github/scripts/check-yaml.rb b/.github/scripts/check-yaml.rb new file mode 100644 index 00000000..8e82d3c1 --- /dev/null +++ b/.github/scripts/check-yaml.rb @@ -0,0 +1,42 @@ +# Parses YAML files and checks the shape of GitHub issue forms, so a broken workflow, compose file or issue form fails +# CI instead of being skipped by GitHub (an issue form that does not parse is simply not offered). +# Usage: ruby .github/scripts/check-yaml.rb FILE... +require "yaml" + +def issue_form_problem(doc) + return "the form is not a mapping" unless doc.is_a?(Hash) + return "the form needs a name and a description" unless doc["name"].is_a?(String) && doc["description"].is_a?(String) + return "the form needs a body list" unless doc["body"].is_a?(Array) && !doc["body"].empty? + + ids = [] + doc["body"].each_with_index do |item, i| + return "body item #{i + 1} has no type" unless item.is_a?(Hash) && item["type"].is_a?(String) + + attributes = item["attributes"] + return "body item #{i + 1} has no attributes" unless attributes.is_a?(Hash) + + if item["type"] == "markdown" + return "markdown item #{i + 1} has no value" unless attributes["value"].is_a?(String) + else + return "body item #{i + 1} has no label" unless attributes["label"].is_a?(String) + ids << item["id"] if item["id"] + end + end + return "duplicate ids #{ids.tally.select { |_, n| n > 1 }.keys.join(', ')}" if ids.uniq.size != ids.size + + nil +end + +failures = 0 +ARGV.each do |path| + doc = YAML.safe_load(File.read(path), aliases: true, filename: path) + if File.basename(File.dirname(path)) == "ISSUE_TEMPLATE" && File.basename(path) != "config.yml" + problem = issue_form_problem(doc) + raise problem if problem + end + puts "ok #{path}" +rescue StandardError => e + puts "::error file=#{path},title=YAML::#{e.message.lines.first.to_s.strip}" + failures += 1 +end +exit(failures.zero? ? 0 : 1) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5a00411..8df564be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,6 +64,11 @@ jobs: if: runner.os == 'Windows' run: dotnet format whitespace Titano.slnx --verify-no-changes + # GitHub silently skips a workflow or issue form that does not parse; the public issue forms ship with releases. + - name: YAML check (workflows, compose, public issue forms) + if: runner.os == 'Linux' + run: ruby .github/scripts/check-yaml.rb .github/workflows/*.yml deploy/docker/docker-compose.yml deploy/releases-repo/.github/ISSUE_TEMPLATE/*.yml + # Missing samples become "RAW fixture missing" warning annotations; the tests that need them skip. - name: Fetch CC0 fixtures run: dotnet "$TOOLS" fixtures --allow-missing @@ -87,6 +92,7 @@ jobs: - name: Screenshots if: runner.os == 'Windows' + timeout-minutes: 10 run: | set +e 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 diff --git a/.github/workflows/perf.yml b/.github/workflows/perf.yml index 5e43f70b..0a8f0e75 100644 --- a/.github/workflows/perf.yml +++ b/.github/workflows/perf.yml @@ -58,7 +58,11 @@ jobs: { echo "## Performance gates" echo '```' - grep -h "perf:" out-perf.log 2>/dev/null | sed 's/^ *//' || echo "no timings recorded" + if grep -q "perf:" out-perf.log 2>/dev/null; then + grep -h "perf:" out-perf.log | sed 's/^ *//' + else + echo "no timings recorded" + fi echo '```' } >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 24222a51..08d0e962 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,8 @@ 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. + # 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: @@ -71,13 +72,14 @@ jobs: - name: Build and test run: | - dotnet build Titano.slnx -c Release -p:TitanoVersion="$VERSION" + 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 & @@ -87,7 +89,7 @@ jobs: - name: Publish self-contained programs run: | - common="-c Release -r win-x64 --self-contained -p:TitanoVersion=$VERSION -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:DebugType=none" + 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 @@ -232,20 +234,41 @@ jobs: - 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 - echo "repo=$RELEASES_REPO" >> "$GITHUB_OUTPUT" + repo="$RELEASES_REPO" else - echo "repo=$GITHUB_REPOSITORY" >> "$GITHUB_OUTPUT" + 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. + 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 is left as it is." + 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: Update the public releases repository - if: env.HAS_RELEASES_TOKEN == 'true' + if: env.HAS_RELEASES_TOKEN == 'true' && steps.target.outputs.newest == 'true' env: GH_TOKEN: ${{ secrets.RELEASES_TOKEN }} run: | - owner="${RELEASES_REPO%%/*}" 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" @@ -261,9 +284,9 @@ jobs: 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 image owner. + # 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/#ghcr.io/${owner,,}/#g" + xargs -0 -r sed -i -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" @@ -279,12 +302,16 @@ jobs: 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" + 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" + gh release create "$TAG" out/release/* --repo "$TARGET" --title "Titano $VERSION" --notes-file out/release-notes.md --prerelease="$PRERELEASE" "${latest[@]}" fi - name: Summary diff --git a/README.md b/README.md index 963b8d80..f5e94288 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ The server reads `/data/server.json` (`TITANO_DATA_PATH`) and `TITANO_*` environ | Workflow | When | What | |---|---|---| -| `.github/workflows/ci.yml` | push to `main`, pull requests | Windows + Linux build (warnings are errors), all tests, package guard, i18n check, XAML lint, format check, CC0 fixtures (a warning per missing sample), screenshots (`--capture`, also pushed to the `ci-screenshots` branch for same-repository PRs), Windows program artifacts, PostgreSQL 16/17 integration, Docker image smoke test | +| `.github/workflows/ci.yml` | push to `main`, pull requests | Windows + Linux build (warnings are errors), all tests, package guard, i18n check, XAML lint, format check, YAML check of workflows and public issue forms, CC0 fixtures (a warning per missing sample), screenshots (`--capture`, also pushed to the `ci-screenshots` branch for same-repository PRs), Windows program artifacts, PostgreSQL 16/17 integration, Docker image smoke test | | `.github/workflows/docker.yml` | nightly | `ghcr.io//titano-server:nightly` (multi-arch) | | `.github/workflows/perf.yml` | weekly, manual | Performance gates on SQLite and PostgreSQL 17; timings in the job summary | | `.github/workflows/release.yml` | tag `v*`, manual re-publish | The release (below) | @@ -75,7 +75,10 @@ The server reads `/data/server.json` (`TITANO_DATA_PATH`) and `TITANO_*` environ zips `Titano-Server-win-x64-.zip` and `Titano-win-x64-portable-.zip`; - writes release notes from the Conventional Commits since the previous tag (`Titano.Tools changelog`); - builds and pushes `ghcr.io//titano-server:` (and `:latest` for stable tags) for amd64 and arm64; - - computes `SHA256SUMS`, updates the public releases repository and creates (or updates) the GitHub release there. + - computes `SHA256SUMS`, checks the public issue forms, updates the public releases repository and creates (or + updates) the GitHub release there. The repository content (README, EULA, `i18n/`, `SHA256SUMS`) follows the + newest stable release: a pre-release, or an older tag published again, only gets its release and never becomes + *Latest*. Until the first stable release exists, every tag updates the content. 4. To publish an existing tag again (for example after adding a secret), run *Release* manually with the tag. ### Secrets and variables @@ -83,7 +86,7 @@ The server reads `/data/server.json` (`TITANO_DATA_PATH`) and `TITANO_*` environ | Name | Kind | Purpose | |---|---|---| | `RELEASES_TOKEN` | secret | Fine-grained PAT with *Contents: read and write* on the public releases repository. Without it the release is created in this (private) repository, which clients cannot see. | -| `RELEASES_REPO` | variable (optional) | `owner/name` of the public repository; default `/titano-releases`. Builds embed it through the `TitanoReleasesRepo` MSBuild property (default `alby96/titano-releases`), so keep the two in line. | +| `RELEASES_REPO` | variable (optional) | `owner/name` of the public repository; default `/titano-releases`. `release.yml` passes it to every build as the `TitanoReleasesRepo` MSBuild property, so the update check, licence and issue links of the binaries read the repository the release goes to (local builds default to `alby96/titano-releases`). | | `SIGN_PFX_BASE64` | secret (optional) | Base64 of the Authenticode code-signing certificate (`.pfx`). Without it builds are unsigned. | | `SIGN_PASSWORD` | secret (optional) | Password of that `.pfx`. | diff --git a/deploy/releases-repo/.github/ISSUE_TEMPLATE/bug_report.yml b/deploy/releases-repo/.github/ISSUE_TEMPLATE/bug_report.yml index 724a373f..7744468d 100644 --- a/deploy/releases-repo/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/deploy/releases-repo/.github/ISSUE_TEMPLATE/bug_report.yml @@ -23,7 +23,7 @@ body: id: version attributes: label: Version - description: About shows it (server: admin panel › About, or /api/v1/server/info). + description: "About shows it (server: admin panel › About, or /api/v1/server/info)." placeholder: "0.2.0" validations: required: true diff --git a/deploy/releases-repo/README.md b/deploy/releases-repo/README.md index d56c0f72..0d0414ea 100644 --- a/deploy/releases-repo/README.md +++ b/deploy/releases-repo/README.md @@ -100,7 +100,7 @@ Run `Titano.Server.exe` in a console, or install it as a Windows service from an Titano is written in English and Italian; every other language is machine-translated and marked as such in About. The source strings are in [`i18n/`](i18n): `en/.resx` is the source, `/..resx` the translation. To suggest a correction, open a **Translation review** issue with the key, the current text and -your proposal — or the in-app *Review* link in About, which leads here. +your proposal — or the in-app *Suggest a fix* link in About, which leads here. ## Verifying downloads