Infrastruttura: nome «Rail Enterprise», CI e rilasci su Gitea, documentazione
Il progetto adotta il nome «Rail Enterprise» ovunque (codice RailEnterprise.*, variabili RE_*, intestazioni RESV/RECL, immagine rail-enterprise-server) per allinearsi al repository Gitea. Aggiunge Gitea Actions sul modello di Chronos: CI su PR e main, rilascio da tag con gioco Windows (client Godot + server in server/), server Windows/Linux e immagine Docker nel registro Gitea, nightly. Aggiunge i riferimenti visivi 06–09, i modelli di PR e issue, l'ADR 0014 e aggiorna README (comandi locali), STATE e CLAUDE.md. 120 test verdi. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f6c2a17b4d
commit
c1a0049bcf
300 files changed
+1602
-1045
No files matched your search
@@ -0,0 +1,104 @@
|
||||
name: CI
|
||||
|
||||
# Gitea Actions (ADR 0014). Il runner è act_runner in modalità Docker sul server Linux che ospita Gitea: ogni job
|
||||
# gira in un container. I job .NET usano l'immagine dell'SDK e fanno il checkout con git, perché le azioni JavaScript
|
||||
# richiedono Node.js, assente in quell'immagine. Nessuna cache e nessun artefatto: il risultato è il verde o il rosso.
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
DOTNET_NOLOGO: "1"
|
||||
DOTNET_CLI_TELEMETRY_OPTOUT: "1"
|
||||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "1"
|
||||
BUILD_CPUS: "4"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build e test
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: mcr.microsoft.com/dotnet/sdk:10.0
|
||||
timeout-minutes: 90
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
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 "${{ github.sha }}"
|
||||
git checkout -q FETCH_HEAD
|
||||
git log -1 --format='%h %s'
|
||||
|
||||
# Core e Protocol compilano anche per net8.0 (client Godot): serve il targeting pack 8.0, che l'SDK 10 scarica
|
||||
# da solo come pacchetto di riferimento. Nessun PackageReference è ammesso (check-nuget).
|
||||
- name: Zero pacchetti NuGet
|
||||
run: scripts/check-nuget.sh
|
||||
|
||||
- name: Build Release (warning come errori)
|
||||
run: dotnet build RailEnterprise.sln -c Release -m:"$BUILD_CPUS" -nologo
|
||||
|
||||
- name: Validazione dei dati
|
||||
run: dotnet run --project src/RailEnterprise.Tools -c Release --no-build -- validate-data --data data
|
||||
|
||||
# Sulle PR i test lunghi (accettazioni pluriennali) si saltano; su main gira la suite completa.
|
||||
- name: Test
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
||||
dotnet run --project tests/RailEnterprise.Tests -c Release --no-build -- --skip-slow
|
||||
else
|
||||
dotnet run --project tests/RailEnterprise.Tests -c Release --no-build
|
||||
fi
|
||||
|
||||
# Il server per Windows (quello che il gioco desktop avvia da «server/») si compila anche qui.
|
||||
- name: Server Windows x64 (compilazione incrociata)
|
||||
run: dotnet publish src/RailEnterprise.Server -c Release -r win-x64 --self-contained -p:ReServerOnly=true -o out/server-win-x64 -nologo
|
||||
|
||||
# Il client Godot compila con il proprio SDK (Godot.NET.Sdk da NuGet, unica eccezione ammessa): basta dotnet.
|
||||
- name: Client Godot (compilazione C#)
|
||||
run: dotnet build client/RailEnterprise.Client/RailEnterprise.Client.csproj -c Release -nologo
|
||||
|
||||
docker:
|
||||
name: Immagine Docker
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
env:
|
||||
NAME: re-ci-${{ github.run_id }}
|
||||
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 "${{ github.sha }}"
|
||||
git checkout -q FETCH_HEAD
|
||||
|
||||
- name: Build dell'immagine
|
||||
run: docker build -f docker/Dockerfile -t "$NAME:ci" .
|
||||
|
||||
# Il container del job e quello del server non condividono la rete: la prova usa l'healthcheck interno.
|
||||
- name: Prova di avvio (/health)
|
||||
run: |
|
||||
docker run -d --name "$NAME" -e RE_TOKEN=ci "$NAME:ci"
|
||||
for i in $(seq 1 60); do
|
||||
if docker exec "$NAME" dotnet RailEnterprise.Server.dll --healthcheck; then echo "server sano"; exit 0; fi
|
||||
sleep 2
|
||||
done
|
||||
docker logs "$NAME" | tail -50
|
||||
exit 1
|
||||
|
||||
- name: Pulizia
|
||||
if: always()
|
||||
run: |
|
||||
docker rm -f "$NAME" 2> /dev/null || true
|
||||
docker image rm "$NAME:ci" 2> /dev/null || true
|
||||
@@ -0,0 +1,55 @@
|
||||
name: Immagine nightly
|
||||
|
||||
# L'immagine del server di main come :nightly nel registro container di Gitea (ADR 0014). Mai una release.
|
||||
on:
|
||||
schedule:
|
||||
- cron: "37 2 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
env:
|
||||
PUBLIC_URL: ${{ vars.PUBLIC_URL || 'https://gitea.encke-hake.ts.net' }}
|
||||
|
||||
jobs:
|
||||
nightly:
|
||||
if: github.ref == 'refs/heads/main'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
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 "${{ github.sha }}"
|
||||
git checkout -q FETCH_HEAD
|
||||
|
||||
- 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
|
||||
echo "::error title=Registro::Accesso a $registry rifiutato: serve il segreto REGISTRY_TOKEN."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Build e push
|
||||
run: |
|
||||
docker build -f docker/Dockerfile --build-arg RE_VERSION="0.0.0-nightly.${{ github.run_number }}" -t "$IMAGE:nightly" .
|
||||
docker push "$IMAGE:nightly"
|
||||
|
||||
- name: Pulizia
|
||||
if: always()
|
||||
run: |
|
||||
docker image rm "$IMAGE:nightly" 2> /dev/null || true
|
||||
docker logout "$REGISTRY_HOST" || true
|
||||
@@ -0,0 +1,213 @@
|
||||
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
|
||||
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
|
||||
Reference in new issue
Block a user