Localization legge assets/i18n/strings.csv così com'è, ma Godot lo importava come traduzione e nel .pck finivano solo i file .translation: il gioco v0.5.1 partiva senza inglese («Traduzioni non trovate»). Il CSV ora usa l'importatore «keep» e il workflow di rilascio fallisce se le traduzioni importate tornano nel pacchetto. STATE.md registra il collaudo di v0.5.1 (pilota automatico completo sul gioco scaricato) e il secondo test instabile (#24). Closes #27. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
224 lines
11 KiB
YAML
224 lines
11 KiB
YAML
name: Release
|
|
|
|
# Un tag vMAJOR.MINOR.PATCH[-PRERELEASE] costruisce, prova e pubblica tutto (ADR 0014):
|
|
# - sulla release Gitea: il gioco desktop per Windows (client Godot + server locale in «server/»), il server per
|
|
# Windows e per Linux, SHA256SUMS e le note di rilascio;
|
|
# - nel registro container di Gitea: l'immagine del server con il tag della versione e, per le versioni stabili, :latest.
|
|
# La versione viene dal tag e sovrascrive quella di Directory.Build.props, che resta la versione di sviluppo.
|
|
on:
|
|
push:
|
|
tags: ["v*"]
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: "Tag esistente da (ri)pubblicare, per esempio v0.6.0"
|
|
required: true
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
env:
|
|
DOTNET_NOLOGO: "1"
|
|
DOTNET_CLI_TELEMETRY_OPTOUT: "1"
|
|
BUILD_CPUS: "4"
|
|
TAG: ${{ github.event.inputs.tag || github.ref_name }}
|
|
PUBLIC_URL: ${{ vars.PUBLIC_URL || 'https://gitea.encke-hake.ts.net' }}
|
|
# Versione di Godot .NET usata per esportare il client (deve coincidere con Godot.NET.Sdk nel csproj del client).
|
|
GODOT_VERSION: "4.7.2"
|
|
GODOT_MIRROR: ${{ vars.GODOT_MIRROR || 'https://github.com/godotengine/godot-builds/releases/download' }}
|
|
|
|
jobs:
|
|
release:
|
|
name: Build, test e pubblicazione
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: mcr.microsoft.com/dotnet/sdk:10.0
|
|
timeout-minutes: 150
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
outputs:
|
|
version: ${{ steps.version.outputs.version }}
|
|
prerelease: ${{ steps.version.outputs.prerelease }}
|
|
steps:
|
|
- name: Versione
|
|
id: version
|
|
run: |
|
|
semver='^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z.-]+)?$'
|
|
if [[ ! "$TAG" =~ $semver ]]; then
|
|
echo "::error title=Release::Il tag '$TAG' non è vMAJOR.MINOR.PATCH o vMAJOR.MINOR.PATCH-PRERELEASE"
|
|
exit 1
|
|
fi
|
|
version="${TAG#v}"
|
|
prerelease=false
|
|
if [[ "$version" == *-* ]]; then prerelease=true; fi
|
|
echo "version=$version" >> "$GITHUB_OUTPUT"
|
|
echo "prerelease=$prerelease" >> "$GITHUB_OUTPUT"
|
|
{ echo "VERSION=$version"; echo "PRERELEASE=$prerelease"; } >> "$GITHUB_ENV"
|
|
|
|
# Storia completa e tag: le note di rilascio elencano i commit dal tag precedente.
|
|
- name: Checkout
|
|
env:
|
|
TOKEN: ${{ github.token }}
|
|
run: |
|
|
git config --global --add safe.directory "$PWD"
|
|
git init -q .
|
|
git remote add origin "${{ github.server_url }}/${{ github.repository }}.git"
|
|
git -c http.extraheader="Authorization: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)" fetch -q --tags origin
|
|
git checkout -q "refs/tags/$TAG"
|
|
git log -1 --format='%h %s'
|
|
|
|
- name: Strumenti di sistema
|
|
run: |
|
|
apt-get update -qq
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends unzip zip curl jq libfontconfig1 > /dev/null
|
|
|
|
- name: Build e test
|
|
run: |
|
|
scripts/check-nuget.sh
|
|
dotnet build RailEnterprise.sln -c Release -m:"$BUILD_CPUS" -nologo -p:Version="$VERSION"
|
|
dotnet run --project src/RailEnterprise.Tools -c Release --no-build -- validate-data --data data
|
|
dotnet run --project tests/RailEnterprise.Tests -c Release --no-build
|
|
|
|
- name: Server autonomi (win-x64, linux-x64)
|
|
run: |
|
|
for rid in win-x64 linux-x64; do
|
|
dotnet publish src/RailEnterprise.Server -c Release -r "$rid" --self-contained -p:ReServerOnly=true \
|
|
-p:Version="$VERSION" -o "out/server-$rid" -nologo
|
|
done
|
|
|
|
# Godot .NET senza interfaccia esporta il client per Windows. Il server per Windows va in «server/» accanto al
|
|
# gioco: è lì che LocalServerLauncher lo cerca per la partita locale.
|
|
- name: Gioco desktop per Windows (esportazione Godot)
|
|
run: |
|
|
set -euo pipefail
|
|
tools="$RUNNER_TEMP/godot"
|
|
mkdir -p "$tools"
|
|
base="$GODOT_MIRROR/$GODOT_VERSION-stable"
|
|
curl -fsSL -o "$tools/godot.zip" "$base/Godot_v$GODOT_VERSION-stable_mono_linux_x86_64.zip"
|
|
curl -fsSL -o "$tools/templates.tpz" "$base/Godot_v$GODOT_VERSION-stable_mono_export_templates.tpz"
|
|
unzip -q "$tools/godot.zip" -d "$tools"
|
|
godot="$(find "$tools" -type f -name "Godot_v*_mono_linux.x86_64" | head -n1)"
|
|
chmod +x "$godot"
|
|
templates="$HOME/.local/share/godot/export_templates/$GODOT_VERSION.stable.mono"
|
|
mkdir -p "$templates"
|
|
unzip -q "$tools/templates.tpz" -d "$tools/tpl"
|
|
cp -r "$tools/tpl/templates/." "$templates/"
|
|
cd client/RailEnterprise.Client
|
|
mkdir -p export/windows
|
|
"$godot" --headless --import || true
|
|
"$godot" --headless --export-release "Windows Desktop" export/windows/RailEnterprise.exe
|
|
test -f export/windows/RailEnterprise.exe
|
|
# senza la soluzione del client Godot esporta il .pck senza il codice C#: il gioco partirebbe vuoto
|
|
if ! ls -d export/windows/data_RailEnterprise.Client_* > /dev/null 2>&1; then
|
|
echo "::error title=Esportazione::Mancano gli assembly .NET del client (data_RailEnterprise.Client_*)"
|
|
exit 1
|
|
fi
|
|
# Localization legge strings.csv così com'è: se Godot l'ha importato come traduzione, il CSV non è nel .pck
|
|
if grep -a -q "assets/i18n/strings\.[a-z]*\.translation" export/windows/RailEnterprise.pck; then
|
|
echo "::error title=Esportazione::strings.csv importato come traduzione: il gioco partirebbe senza inglese (serve importer=\"keep\")"
|
|
exit 1
|
|
fi
|
|
cp -r "../../out/server-win-x64" export/windows/server
|
|
|
|
- name: Pacchetti
|
|
run: |
|
|
set -euo pipefail
|
|
mkdir -p out/release
|
|
(cd client/RailEnterprise.Client/export/windows && zip -qr "$OLDPWD/out/release/RailEnterprise-$VERSION-windows-x64.zip" .)
|
|
(cd out/server-win-x64 && zip -qr "$OLDPWD/out/release/RailEnterprise-Server-$VERSION-windows-x64.zip" .)
|
|
tar -C out/server-linux-x64 -czf "out/release/RailEnterprise-Server-$VERSION-linux-x64.tar.gz" .
|
|
cp docker/docker-compose.yml "out/release/docker-compose.yml"
|
|
cp docker/unraid-template.xml "out/release/unraid-template.xml"
|
|
(cd out/release && sha256sum -- * > SHA256SUMS && cat SHA256SUMS)
|
|
|
|
- name: Note di rilascio
|
|
run: |
|
|
prev="$(git describe --tags --abbrev=0 "$TAG^" 2> /dev/null || true)"
|
|
owner="$(printf '%s' "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')"
|
|
host="$(printf '%s' "$PUBLIC_URL" | sed -E 's#^[a-z]+://##; s#/.*$##')"
|
|
{
|
|
echo "## Rail Enterprise $VERSION"
|
|
echo
|
|
echo "- **Gioco desktop (Windows x64):** scarica \`RailEnterprise-$VERSION-windows-x64.zip\`, estrai e avvia \`RailEnterprise.exe\`. «Partita locale» avvia da sola il server in \`server/\`."
|
|
echo "- **Server Docker:** \`docker pull $host/$owner/rail-enterprise-server:$VERSION\` (vedi \`docker-compose.yml\` e \`unraid-template.xml\`)."
|
|
echo "- **Server senza Docker:** \`RailEnterprise-Server-$VERSION-*.zip|tar.gz\`, poi \`RailEnterprise.Server --data ./dati\` con \`RE_TOKEN\` impostato."
|
|
echo
|
|
if [ -n "$prev" ]; then echo "### Modifiche da $prev"; else echo "### Modifiche"; fi
|
|
echo
|
|
git log --no-merges --format='- %s (%h)' ${prev:+$prev..}"$TAG"
|
|
} > out/release-notes.md
|
|
cat out/release-notes.md
|
|
|
|
# Creata come bozza, pubblicata quando tutti i file sono caricati.
|
|
- name: Release Gitea
|
|
env:
|
|
TOKEN: ${{ github.token }}
|
|
run: |
|
|
set -euo pipefail
|
|
api="${{ github.server_url }}/api/v1/repos/${{ github.repository }}"
|
|
auth="Authorization: token $TOKEN"
|
|
existing="$(curl -fsS -H "$auth" "$api/releases/tags/$TAG" 2> /dev/null | jq -r '.id // empty' || true)"
|
|
if [ -n "$existing" ]; then curl -fsS -X DELETE -H "$auth" "$api/releases/$existing"; fi
|
|
body="$(jq -n --arg tag "$TAG" --arg name "Rail Enterprise $VERSION" --rawfile body out/release-notes.md \
|
|
--argjson pre "$PRERELEASE" '{tag_name:$tag, name:$name, body:$body, draft:true, prerelease:$pre}')"
|
|
id="$(curl -fsS -X POST -H "$auth" -H 'Content-Type: application/json' -d "$body" "$api/releases" | jq -r .id)"
|
|
for f in out/release/*; do
|
|
name="$(basename "$f")"
|
|
curl -fsS -X POST -H "$auth" -F "attachment=@$f" "$api/releases/$id/assets?name=$name" > /dev/null
|
|
echo "caricato $name"
|
|
done
|
|
curl -fsS -X PATCH -H "$auth" -H 'Content-Type: application/json' -d '{"draft":false}' "$api/releases/$id" > /dev/null
|
|
echo "Release pubblicata: $PUBLIC_URL/${{ github.repository }}/releases/tag/$TAG"
|
|
|
|
image:
|
|
name: Immagine del server
|
|
needs: release
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 60
|
|
env:
|
|
VERSION: ${{ needs.release.outputs.version }}
|
|
PRERELEASE: ${{ needs.release.outputs.prerelease }}
|
|
steps:
|
|
- name: Checkout
|
|
env:
|
|
TOKEN: ${{ github.token }}
|
|
run: |
|
|
git config --global --add safe.directory "$PWD"
|
|
git init -q .
|
|
git remote add origin "${{ github.server_url }}/${{ github.repository }}.git"
|
|
git -c http.extraheader="Authorization: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)" fetch -q --depth=1 origin "refs/tags/$TAG:refs/tags/$TAG"
|
|
git checkout -q "refs/tags/$TAG"
|
|
|
|
- name: Accesso al registro
|
|
env:
|
|
REGISTRY: ${{ vars.REGISTRY }}
|
|
USER: ${{ vars.REGISTRY_USER || github.actor }}
|
|
TOKEN: ${{ secrets.REGISTRY_TOKEN || github.token }}
|
|
run: |
|
|
registry="${REGISTRY:-$(printf '%s' "$PUBLIC_URL" | sed -E 's#^[a-z]+://##; s#/.*$##')}"
|
|
owner="$(printf '%s' "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')"
|
|
{ echo "REGISTRY_HOST=$registry"; echo "IMAGE=$registry/$owner/rail-enterprise-server"; } >> "$GITHUB_ENV"
|
|
if ! printf '%s' "$TOKEN" | docker login "$registry" -u "$USER" --password-stdin; then
|
|
# il token del workflow (utente gitea-actions) non può scrivere i pacchetti di un'organizzazione
|
|
echo "::error title=Registro::Accesso a $registry rifiutato. Serve il segreto REGISTRY_TOKEN (organizzazione o repository): un token di un utente che può scrivere i pacchetti (scope package: read e write)."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Build e push
|
|
run: |
|
|
docker build -f docker/Dockerfile --build-arg RE_VERSION="$VERSION" -t "$IMAGE:$VERSION" .
|
|
docker push "$IMAGE:$VERSION"
|
|
# Compose e Unraid seguono :latest, che si muove solo con le versioni stabili.
|
|
if [ "$PRERELEASE" != "true" ]; then
|
|
docker tag "$IMAGE:$VERSION" "$IMAGE:latest"
|
|
docker push "$IMAGE:latest"
|
|
fi
|
|
|
|
- name: Pulizia
|
|
if: always()
|
|
run: |
|
|
docker image rm "$IMAGE:$VERSION" "$IMAGE:latest" 2> /dev/null || true
|
|
docker logout "$REGISTRY_HOST" || true
|