Files
Febe/.gitea/workflows/rilascio.yml
Alby96andClaude Opus 5.5 a3126bbde9
verifica / controlli (push) Successful in 22s
verifica / prove (push) Canceled after 8s
verifica / installatore (push) Canceled after 0s
verifica / immagine (push) Canceled after 0s
Rilascio: le note senza immagine non parlano di una versione precedente (#43)
Quando l'immagine non si pubblica, le note della release dicevano che
«:latest resta sulla versione precedente», ma alla prima pubblicazione sul
registro un'immagine precedente non c'è. Ora dicono che questo rilascio non
aggiorna :latest e che Unraid e Docker Compose tengono l'immagine che avevano,
se ce n'era una: vero in ogni caso.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 12:03:34 +01:00

399 lines
21 KiB
YAML

# Release at every vX.Y.Z tag (also vX.Y.Z-something for a preview):
# 1. prove: the tag matches <Version> in Directory.Build.props, the solution builds with warnings as errors and all
# the tests pass, in the same Debian 13 container as the verification (real Chromium and Xvfb) and without any
# skipped test. Without green tests nothing is built or released;
# 2. windows: Febe.exe in a single file, our own installer (src/Febe.Installer) and the portable zip
# (installer/costruisci.sh, runs on Linux with the .NET SDK only): the gate before the image;
# 3. immagine: after the installer, the Docker image (the tests also run inside the build), tested without network
# and scanned with Trivy as in the verification (a CRITICAL with a fix stops everything), then published on the
# Gitea container registry as <registro>/<proprietario>/febe:X.Y.Z and :latest (only for versions without a
# dash). The job says whether it published it, and at the end it always removes the run's images, containers,
# cache and builder, then the unnamed images and the dangling build cache unused for 24 hours of all the
# daemon's projects;
# 4. release: only after the tests, the installer and the image. It rebuilds installer and zip from the same commit
# with the same script (without actions there is no way to pass artifacts between jobs that does not depend on
# REGISTRY_TOKEN, and the release must come out without it too), then creates the release (or completes it, if
# it already exists) with installer, portable zip, Unraid template and the Docker Compose archive (compose.yml
# with the seccomp profile next to it); the notes say where the image is, or that it was not published.
#
# No actions, as in the verification (decision of 18 November 2026): sources with git and the job token, SDK with
# .gitea/scripts/dotnet.sh, buildx builder with costruisci-immagine.sh builder, test results and Trivy report in the
# generic package febe-ci (version <versione>-rilascio.<numero>, with REGISTRY_TOKEN; artefatti.sh).
#
# Repository secret (Impostazioni ▸ Actions ▸ Segreti): REGISTRY_TOKEN, a user token with the permissions
# «package: read and write». Without it, the image is built and tested but not published: the release comes out
# anyway, with the Windows installer, and its notes say the image of this version is missing. Once the secret is
# added, the tag's workflow is run again: the image is published and the release notes are corrected.
# Optional variable (Impostazioni ▸ Actions ▸ Variabili): REGISTRY, the registry name as the runner reaches it (for
# example 192.168.30.23:3000); if missing, the host of the Gitea server address (its ROOT_URL) is used.
# The registry answers in HTTP: publishing goes through buildx with a builder of its own (docker-container) whose
# buildkit configuration says that registry is HTTP and insecure, so the runner's Docker does not need it among its
# insecure-registries. The credentials go into the Docker client configuration, without «docker login» (which would
# go through the daemon, and the daemon would try HTTPS).
name: rilascio
on:
push:
tags: ["v*"]
# Like the verification and the cleanup: every step with «bash -e -o pipefail», whatever the default shell of the
# runner or of the container (the Sorgenti step uses bash arrays; in a Debian container the default would be dash).
defaults:
run:
shell: bash
env:
DOTNET_NOLOGO: "1"
DOTNET_CLI_TELEMETRY_OPTOUT: "1"
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "1"
jobs:
prove:
runs-on: ubuntu-latest
timeout-minutes: 60
# The same environment as the verification tests: Debian 13 with real Chromium and Xvfb and the summary that
# allows no skipped tests. On ubuntu-latest the browser tests (among them the return after sign-in,
# return-path.js) would be inconclusive and a release would come out without having run them.
container:
image: debian:trixie
options: --shm-size=1g
env:
FEBE_CHROMIUM: /usr/bin/chromium
NUMERO: ${{ gitea.run_number }}
steps:
- name: Git e curl per i sorgenti
run: |
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get install -y -qq --no-install-recommends git curl ca-certificates > /dev/null
git --version
- name: Sorgenti
env:
TOKEN: ${{ gitea.token }}
SERVER: ${{ gitea.server_url }}
REPOSITORY: ${{ gitea.repository }}
PROFONDITA: "1"
run: |
git config --global --add safe.directory "$PWD"
git init -q .
git remote add origin "$SERVER/$REPOSITORY.git" 2> /dev/null || git remote set-url origin "$SERVER/$REPOSITORY.git"
GIT_CONFIG_VALUE_0="Authorization: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)"
export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=http.extraHeader GIT_CONFIG_VALUE_0
profondita=()
[ "$PROFONDITA" = 0 ] || profondita=(--depth "$PROFONDITA")
if ! git fetch -q --no-tags "${profondita[@]}" origin "$GITHUB_SHA"; then
echo "Il server non dà il commit per identificativo: prendo $GITHUB_REF con tutta la storia."
git fetch -q --no-tags origin "+$GITHUB_REF:refs/remotes/origin/lavoro"
fi
git checkout -q --force --detach "$GITHUB_SHA"
git log -1 --format='Commit %h: %s'
- name: Versione coerente con il tag
run: |
V=$(sed -n 's:.*<Version>\(.*\)</Version>.*:\1:p' Directory.Build.props | head -n 1)
[ "v$V" = "${GITHUB_REF_NAME}" ] || { echo "Il tag ${GITHUB_REF_NAME} non coincide con <Version> $V"; exit 1; }
- name: Chromium, Xvfb e lingua italiana
run: bash .gitea/scripts/ambiente-prove.sh
- name: SDK .NET 10
run: bash .gitea/scripts/dotnet.sh 10.0
- name: Compilazione (avvisi = errori)
run: dotnet build Febe.slnx -c Release -nologo -warnaserror
- name: Prove
run: >-
dotnet test tests/Febe.Tests -c Release --no-build --nologo
--logger "trx;LogFileName=prove.trx" --results-directory out/prove
# No skipped test: an inconclusive test (for example without Chromium) stops the release.
- name: Riepilogo delle prove
if: ${{ !cancelled() }}
run: bash .gitea/scripts/riepilogo-prove.sh out/prove 0
- name: Risultati (pacchetto febe-ci)
if: always()
env:
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
GITEA_URL: ${{ gitea.server_url }}
PROPRIETARIO: ${{ gitea.repository_owner }}
run: |
[ -f out/prove/prove.trx ] || { echo "Nessun risultato delle prove."; exit 0; }
bash .gitea/scripts/artefatti.sh rilascio out/prove/prove.trx
windows:
runs-on: ubuntu-latest
needs: prove
timeout-minutes: 30
env:
# Like the installer job of verifica.yml: the runner image does not guarantee ICU, and it is not needed here.
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: "true"
steps:
- name: Sorgenti
env:
TOKEN: ${{ gitea.token }}
SERVER: ${{ gitea.server_url }}
REPOSITORY: ${{ gitea.repository }}
PROFONDITA: "1"
run: |
git config --global --add safe.directory "$PWD"
git init -q .
git remote add origin "$SERVER/$REPOSITORY.git" 2> /dev/null || git remote set-url origin "$SERVER/$REPOSITORY.git"
GIT_CONFIG_VALUE_0="Authorization: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)"
export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=http.extraHeader GIT_CONFIG_VALUE_0
profondita=()
[ "$PROFONDITA" = 0 ] || profondita=(--depth "$PROFONDITA")
if ! git fetch -q --no-tags "${profondita[@]}" origin "$GITHUB_SHA"; then
echo "Il server non dà il commit per identificativo: prendo $GITHUB_REF con tutta la storia."
git fetch -q --no-tags origin "+$GITHUB_REF:refs/remotes/origin/lavoro"
fi
git checkout -q --force --detach "$GITHUB_SHA"
git log -1 --format='Commit %h: %s'
- name: Versione
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV"
- name: SDK .NET 10
run: bash .gitea/scripts/dotnet.sh 10.0
- name: Febe.exe, programma di installazione e zip portabile
run: bash installer/costruisci.sh "$VERSION"
immagine:
runs-on: ubuntu-latest
# After the installer: :X.Y.Z and :latest come out only if the release can come out too.
needs: [prove, windows]
timeout-minutes: 60
env:
FLUSSO: rilascio
ESECUZIONE: ${{ gitea.run_id }}
NUMERO: ${{ gitea.run_number }}
BUILDER: febe-ci-${{ gitea.run_id }}
PROVA: febe-ci:${{ gitea.run_id }}
outputs:
immagine: ${{ steps.nome.outputs.immagine }}
pubblicata: ${{ steps.pubblicazione.outputs.pubblicata }}
motivo: ${{ steps.segreto.outputs.motivo }}
steps:
- name: Sorgenti
env:
TOKEN: ${{ gitea.token }}
SERVER: ${{ gitea.server_url }}
REPOSITORY: ${{ gitea.repository }}
PROFONDITA: "1"
run: |
git config --global --add safe.directory "$PWD"
git init -q .
git remote add origin "$SERVER/$REPOSITORY.git" 2> /dev/null || git remote set-url origin "$SERVER/$REPOSITORY.git"
GIT_CONFIG_VALUE_0="Authorization: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)"
export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=http.extraHeader GIT_CONFIG_VALUE_0
profondita=()
[ "$PROFONDITA" = 0 ] || profondita=(--depth "$PROFONDITA")
if ! git fetch -q --no-tags "${profondita[@]}" origin "$GITHUB_SHA"; then
echo "Il server non dà il commit per identificativo: prendo $GITHUB_REF con tutta la storia."
git fetch -q --no-tags origin "+$GITHUB_REF:refs/remotes/origin/lavoro"
fi
git checkout -q --force --detach "$GITHUB_SHA"
git log -1 --format='Commit %h: %s'
# What an interrupted run could not remove, and an earlier attempt of this same run.
- name: Resti di esecuzioni interrotte
run: |
bash .gitea/scripts/pulizia-docker.sh residui 90
bash .gitea/scripts/pulizia-docker.sh esecuzione "$ESECUZIONE"
- name: Versione, registro e nome dell'immagine
id: nome
run: |
V="${GITHUB_REF_NAME#v}"
REGISTRY="${{ vars.REGISTRY }}"
[ -n "$REGISTRY" ] || REGISTRY=$(echo "${{ gitea.server_url }}" | sed -E 's#^https?://##; s#/.*$##')
OWNER=$(echo "${{ gitea.repository_owner }}" | tr '[:upper:]' '[:lower:]')
echo "VERSION=$V" >> "$GITHUB_ENV"
echo "VERSIONE=$V" >> "$GITHUB_ENV"
echo "GIT_COMMIT=${GITHUB_SHA::12}" >> "$GITHUB_ENV"
echo "ARCHIVIO=${RUNNER_TEMP:-/tmp}/febe-$ESECUZIONE.tar" >> "$GITHUB_ENV"
echo "REGISTRY=$REGISTRY" >> "$GITHUB_ENV"
echo "IMAGE=$REGISTRY/$OWNER/febe" >> "$GITHUB_ENV"
echo "immagine=$REGISTRY/$OWNER/febe" >> "$GITHUB_OUTPUT"
# A buildx builder of our own, which knows that the home registry answers in HTTP.
- name: Builder buildx dell'esecuzione
run: bash .gitea/scripts/costruisci-immagine.sh builder "$REGISTRY"
# The same arguments and labels as the publication (costruisci-immagine.sh): that one comes from this one's cache.
- name: Costruzione dell'immagine (le prove girano dentro la build)
run: |
bash .gitea/scripts/costruisci-immagine.sh archivio "$ARCHIVIO" "$PROVA"
docker load -i "$ARCHIVIO"
- name: Prova del contenitore, senza rete
run: bash .gitea/scripts/prova-immagine.sh "$PROVA" "$ESECUZIONE"
- name: Vulnerabilità dell'immagine (Trivy)
run: bash .gitea/scripts/scansione-immagine.sh "$ARCHIVIO" out/sicurezza
- name: Rapporto di Trivy (pacchetto febe-ci)
if: ${{ !cancelled() }}
env:
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
GITEA_URL: ${{ gitea.server_url }}
PROPRIETARIO: ${{ gitea.repository_owner }}
run: |
[ -f out/sicurezza/trivy.json ] || { echo "Nessun rapporto di Trivy."; exit 0; }
bash .gitea/scripts/artefatti.sh rilascio out/sicurezza/trivy.json
- name: Segreto per il registro
id: segreto
env:
TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: |
if [ -z "$TOKEN" ]; then
echo "::warning::Manca il segreto REGISTRY_TOKEN: l'immagine è stata costruita e provata ma non pubblicata. La release esce lo stesso e lo dice."
echo "Aggiungi il segreto (token con package: read and write) e rilancia il flusso di questo tag."
echo "presente=no" >> "$GITHUB_OUTPUT"
echo "motivo=manca il segreto REGISTRY_TOKEN del repository" >> "$GITHUB_OUTPUT"
else
echo "presente=si" >> "$GITHUB_OUTPUT"
fi
- name: Pubblicazione sul registro di Gitea
id: pubblicazione
if: steps.segreto.outputs.presente == 'si'
env:
REGISTRO_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
REGISTRO_UTENTE: ${{ gitea.actor }}
run: |
set -eu
# costruisci-immagine.sh pubblica puts the credentials in a client configuration of its own, removed at the
# end: buildx passes them to the builder, the daemon is not involved.
NOMI="$IMAGE:$VERSION"
case "$VERSION" in
*-*) echo "Versione di anteprima: :latest non si sposta." ;;
*) NOMI="$NOMI $IMAGE:latest" ;;
esac
# The same build as before (from the builder's cache), this time pushed to the registry by buildx.
bash .gitea/scripts/costruisci-immagine.sh pubblica $NOMI
echo "pubblicata=si" >> "$GITHUB_OUTPUT"
- name: Pulizia (sempre)
if: always()
run: |
# The client configuration with the credentials, if an interruption skipped the trap of whoever wrote it.
rm -rf "${RUNNER_TEMP:-/tmp}/febe-docker-$ESECUZIONE"
if [ -n "${ARCHIVIO:-}" ]; then rm -f "$ARCHIVIO"; fi
bash .gitea/scripts/pulizia-docker.sh esecuzione "$ESECUZIONE"
# Then, for all the daemon's projects, what nobody uses: unnamed images and dangling build cache unused for
# 24 hours. It never fails the job.
bash .gitea/scripts/pulizia-docker.sh penzolanti || echo "::warning::La pulizia di ciò che nessuno usa non è riuscita."
release:
runs-on: ubuntu-latest
# The tests are green, the installer is there and the image was built: published, or not published only because
# the secret is missing (the «immagine» job says so and the notes report it). If the build, the container test,
# the scan or the push to the registry fail, no release comes out.
needs: [prove, windows, immagine]
timeout-minutes: 40
env:
# Like «windows»: the runner image does not guarantee ICU, and building the installer does not need it.
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: "true"
steps:
- name: Sorgenti
env:
TOKEN: ${{ gitea.token }}
SERVER: ${{ gitea.server_url }}
REPOSITORY: ${{ gitea.repository }}
PROFONDITA: "1"
run: |
git config --global --add safe.directory "$PWD"
git init -q .
git remote add origin "$SERVER/$REPOSITORY.git" 2> /dev/null || git remote set-url origin "$SERVER/$REPOSITORY.git"
GIT_CONFIG_VALUE_0="Authorization: basic $(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)"
export GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=http.extraHeader GIT_CONFIG_VALUE_0
profondita=()
[ "$PROFONDITA" = 0 ] || profondita=(--depth "$PROFONDITA")
if ! git fetch -q --no-tags "${profondita[@]}" origin "$GITHUB_SHA"; then
echo "Il server non dà il commit per identificativo: prendo $GITHUB_REF con tutta la storia."
git fetch -q --no-tags origin "+$GITHUB_REF:refs/remotes/origin/lavoro"
fi
git checkout -q --force --detach "$GITHUB_SHA"
git log -1 --format='Commit %h: %s'
- name: SDK .NET 10
run: bash .gitea/scripts/dotnet.sh 10.0
# The same commit and the same script as the «windows» job, which already acted as the gate before the image.
- name: Febe.exe, programma di installazione e zip portabile per la release
run: bash installer/costruisci.sh "${GITHUB_REF_NAME#v}"
- name: Release con installatore, zip portabile, modello Unraid e archivio per Compose
env:
TOKEN: ${{ github.token }}
API: ${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}
IMMAGINE: ${{ needs.immagine.outputs.immagine }}
PUBBLICATA: ${{ needs.immagine.outputs.pubblicata }}
MOTIVO: ${{ needs.immagine.outputs.motivo }}
run: |
set -eu
TAG="${GITHUB_REF_NAME}"
VERSION="${TAG#v}"
case "$VERSION" in *-*|0.*) PRE=true ;; *) PRE=false ;; esac # 0.x versions are previews
NOTE=$(awk -v v="$VERSION" '/^## /{p=($2==v)} p' CHANGELOG.md || true)
[ -n "$NOTE" ] || NOTE="Febe $VERSION"
if [ "$PUBBLICATA" = "si" ]; then
case "$VERSION" in
*-*) DOVE="\`$IMMAGINE:$VERSION\` (anteprima: \`:latest\` resta sulla versione precedente)" ;;
*) DOVE="\`$IMMAGINE:$VERSION\` e \`$IMMAGINE:latest\`" ;;
esac
IMMAGINE_NOTA="Immagine Docker: $DOVE. Il registro risponde in HTTP: il Docker che la scarica deve averlo fra gli \`insecure-registries\`."
else
IMMAGINE_NOTA="**L'immagine Docker di questa versione non è stata pubblicata** (${MOTIVO:-motivo sconosciuto}): questo rilascio non aggiorna \`:latest\`, e Unraid e Docker Compose continuano a usare l'immagine che avevano già, se ce n'era una. Febe per Windows, qui allegato, è provato come sempre. Per pubblicare l'immagine, rilancia il flusso di rilascio di questo tag dopo aver risolto il problema: queste note si aggiornano."
fi
NOTE=$(printf '%s\n\n### Immagine Docker\n\n%s\n' "$NOTE" "$IMMAGINE_NOTA")
# JSON read and written with .gitea/scripts/json.sh (awk), no jq. Gitea's responses go to a file: the reader
# reads files, not a stream.
RISPOSTA="${RUNNER_TEMP:-/tmp}/febe-release-${GITHUB_RUN_ID:-0}.json"
ID=""
if curl -sf -H "Authorization: token $TOKEN" "$API/releases/tags/$TAG" -o "$RISPOSTA"; then
ID=$(bash .gitea/scripts/json.sh campi "" id "$RISPOSTA") || ID=""
fi
if [ -z "$ID" ]; then
printf '{"tag_name":%s,"name":%s,"body":%s,"draft":false,"prerelease":%s}' \
"$(bash .gitea/scripts/json.sh stringa "$TAG")" "$(bash .gitea/scripts/json.sh stringa "Febe $VERSION")" \
"$(bash .gitea/scripts/json.sh stringa "$NOTE")" "$PRE" \
| curl -sf -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
--data-binary @- "$API/releases" -o "$RISPOSTA"
ID=$(bash .gitea/scripts/json.sh campi "" id "$RISPOSTA")
[[ "$ID" =~ ^[0-9]+$ ]] || { echo "Gitea non ha dato l'identificativo della release creata." >&2; exit 1; }
echo "Release $TAG creata (id $ID)"
else
[[ "$ID" =~ ^[0-9]+$ ]] || { echo "Identificativo della release inatteso: «$ID»." >&2; exit 1; }
# The notes say how it went this time (for example: the image is now published).
printf '{"body":%s}' "$(bash .gitea/scripts/json.sh stringa "$NOTE")" \
| curl -sf -X PATCH -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
--data-binary @- "$API/releases/$ID" > /dev/null
echo "Release $TAG già presente (id $ID): note aggiornate, aggiungo gli allegati mancanti"
fi
cp docker/unraid/febe.xml "out/febe-unraid-$VERSION.xml"
# compose.yml points to the seccomp profile with a relative path: the archive carries them together.
COMPOSE="out/febe-compose-$VERSION"
rm -rf "$COMPOSE"
mkdir -p "$COMPOSE/chromium"
cp docker/compose.yml "$COMPOSE/compose.yml"
cp docker/chromium/seccomp.json "$COMPOSE/chromium/seccomp.json"
tar -czf "$COMPOSE.tar.gz" -C out "febe-compose-$VERSION"
curl -sf -H "Authorization: token $TOKEN" "$API/releases/$ID/assets" -o "$RISPOSTA"
ESISTENTI=$(bash .gitea/scripts/json.sh campi "*" name "$RISPOSTA")
rm -f "$RISPOSTA"
for f in out/Febe-Setup-*.exe out/Febe-*-portabile.zip "out/febe-unraid-$VERSION.xml" "$COMPOSE.tar.gz"; do
n=$(basename "$f")
if echo "$ESISTENTI" | grep -qx "$n"; then echo "$n già allegato"; continue; fi
curl -sf -X POST -H "Authorization: token $TOKEN" -F "attachment=@$f" "$API/releases/$ID/assets?name=$n" > /dev/null
echo "$n allegato"
done