Registro di casa 192.168.30.23:3000 (HTTP) nel modello Unraid, in compose e nel rilascio con buildx; profilo seccomp fuori da /dati. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
249 lines
12 KiB
YAML
249 lines
12 KiB
YAML
# Rilascio a ogni tag vX.Y.Z (anche vX.Y.Z-qualcosa per un'anteprima):
|
|
# 1. prove: il tag coincide con <Version> di Directory.Build.props, la soluzione si compila con gli avvisi come errori
|
|
# e tutte le prove passano. Senza prove verdi non si costruisce né si rilascia nulla;
|
|
# 2. windows: Febe.exe in un file solo, il programma di installazione NSIS e lo zip portabile (installer/costruisci.sh,
|
|
# gira su Linux);
|
|
# 3. immagine: l'immagine Docker (le prove girano anche dentro la build), pubblicata sul registro dei container di
|
|
# Gitea come <registro>/<proprietario>/febe:X.Y.Z e :latest (solo per le versioni senza trattino). Il lavoro dice
|
|
# se l'ha pubblicata;
|
|
# 4. release: solo dopo le prove, l'installatore e l'immagine. Crea la release (o la completa, se esiste già) con
|
|
# installatore, zip portabile, modello Unraid e l'archivio per Docker Compose (compose.yml con il profilo seccomp
|
|
# accanto); le note dicono dove sta l'immagine, o che non è stata pubblicata.
|
|
#
|
|
# Segreto del repository (Impostazioni ▸ Actions ▸ Segreti): REGISTRY_TOKEN, un token dell'utente con i permessi
|
|
# «package: read and write». Senza, l'immagine si costruisce e si prova ma non si pubblica: la release esce lo stesso,
|
|
# con l'installatore per Windows, e le sue note dicono che l'immagine di questa versione non c'è. Aggiunto il segreto,
|
|
# si rilancia il flusso del tag: l'immagine si pubblica e le note della release si correggono.
|
|
# Variabile facoltativa (Impostazioni ▸ Actions ▸ Variabili): REGISTRY, il nome del registro come lo raggiunge il
|
|
# runner (per esempio 192.168.30.23:3000); se manca si usa l'host dell'indirizzo del server Gitea (il suo ROOT_URL).
|
|
# Il registro risponde in HTTP: la pubblicazione passa da buildx con un builder proprio (docker-container) a cui la
|
|
# configurazione di buildkit dice che quel registro è in HTTP e insicuro, così non serve che il Docker del runner lo
|
|
# abbia fra gli insecure-registries. Le credenziali vanno nella configurazione del client Docker, senza «docker login»
|
|
# (che passerebbe dal demone, e il demone proverebbe HTTPS).
|
|
name: rilascio
|
|
|
|
on:
|
|
push:
|
|
tags: ["v*"]
|
|
|
|
jobs:
|
|
prove:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- 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; }
|
|
|
|
- uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: "10.0.x"
|
|
|
|
- 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
|
|
|
|
- name: Risultati
|
|
if: always()
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: risultati-prove
|
|
path: out/prove/*.trx
|
|
if-no-files-found: ignore
|
|
|
|
windows:
|
|
runs-on: ubuntu-latest
|
|
needs: prove
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Versione
|
|
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV"
|
|
|
|
- uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: "10.0.x"
|
|
|
|
- name: NSIS e zip
|
|
run: |
|
|
SUDO=""; [ "$(id -u)" = 0 ] || SUDO=sudo
|
|
$SUDO apt-get update -qq
|
|
$SUDO apt-get install -y -qq nsis zip > /dev/null
|
|
|
|
- name: Febe.exe, programma di installazione e zip portabile
|
|
run: bash installer/costruisci.sh "$VERSION"
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: windows
|
|
path: |
|
|
out/Febe-Setup-*.exe
|
|
out/Febe-*-portabile.zip
|
|
if-no-files-found: error
|
|
|
|
immagine:
|
|
runs-on: ubuntu-latest
|
|
needs: prove
|
|
outputs:
|
|
immagine: ${{ steps.nome.outputs.immagine }}
|
|
pubblicata: ${{ steps.pubblicazione.outputs.pubblicata }}
|
|
motivo: ${{ steps.segreto.outputs.motivo }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- 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 "REGISTRY=$REGISTRY" >> "$GITHUB_ENV"
|
|
echo "IMAGE=$REGISTRY/$OWNER/febe" >> "$GITHUB_ENV"
|
|
echo "registro=$REGISTRY" >> "$GITHUB_OUTPUT"
|
|
echo "immagine=$REGISTRY/$OWNER/febe" >> "$GITHUB_OUTPUT"
|
|
|
|
# Un builder buildx proprio, che sa che il registro di casa risponde in HTTP.
|
|
- uses: docker/setup-buildx-action@v3
|
|
with:
|
|
driver: docker-container
|
|
buildkitd-config-inline: |
|
|
[registry."${{ steps.nome.outputs.registro }}"]
|
|
http = true
|
|
insecure = true
|
|
|
|
- name: Costruzione dell'immagine (le prove girano dentro la build)
|
|
run: |
|
|
docker buildx build -f docker/Dockerfile \
|
|
--build-arg VERSION="$VERSION" \
|
|
--build-arg GIT_COMMIT="${GITHUB_SHA::12}" \
|
|
-t "$IMAGE:$VERSION" --load .
|
|
docker run --rm --entrypoint /usr/bin/chromium "$IMAGE:$VERSION" --version
|
|
|
|
- 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:
|
|
TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
|
UTENTE: ${{ gitea.actor }}
|
|
run: |
|
|
set -eu
|
|
# Le credenziali nella configurazione del client: buildx le passa al builder, il demone non c'entra.
|
|
CONFIG="${DOCKER_CONFIG:-$HOME/.docker}"
|
|
mkdir -p "$CONFIG"
|
|
[ -s "$CONFIG/config.json" ] || echo '{}' > "$CONFIG/config.json"
|
|
AUTH=$(printf '%s:%s' "$UTENTE" "$TOKEN" | base64 -w0)
|
|
jq --arg r "$REGISTRY" --arg a "$AUTH" '.auths[$r].auth = $a' "$CONFIG/config.json" > "$CONFIG/config.json.nuovo"
|
|
mv "$CONFIG/config.json.nuovo" "$CONFIG/config.json"
|
|
TAGS="-t $IMAGE:$VERSION"
|
|
case "$VERSION" in
|
|
*-*) echo "Versione di anteprima: :latest non si sposta." ;;
|
|
*) TAGS="$TAGS -t $IMAGE:latest" ;;
|
|
esac
|
|
# La stessa costruzione di prima (dalla cache del builder), questa volta spinta sul registro.
|
|
docker buildx build -f docker/Dockerfile \
|
|
--build-arg VERSION="$VERSION" \
|
|
--build-arg GIT_COMMIT="${GITHUB_SHA::12}" \
|
|
$TAGS --push .
|
|
echo "pubblicata=si" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Credenziali tolte
|
|
if: always()
|
|
run: |
|
|
CONFIG="${DOCKER_CONFIG:-$HOME/.docker}/config.json"
|
|
if [ -s "$CONFIG" ] && [ -n "${REGISTRY:-}" ]; then
|
|
jq --arg r "$REGISTRY" 'if .auths then .auths |= del(.[$r]) else . end' "$CONFIG" > "$CONFIG.nuovo" && mv "$CONFIG.nuovo" "$CONFIG"
|
|
fi
|
|
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
# Le prove sono verdi, l'installatore c'è e l'immagine si è costruita: pubblicata, o non pubblicata per la sola
|
|
# mancanza del segreto (il lavoro «immagine» lo dice e le note lo riportano). Se la costruzione o la spinta sul
|
|
# registro falliscono, non esce nessuna release.
|
|
needs: [prove, windows, immagine]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
name: windows
|
|
path: out
|
|
|
|
- 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 # le versioni 0.x sono anteprime
|
|
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}): \`:latest\` resta sulla versione precedente, e Unraid e Docker Compose continuano a usare quella. 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")
|
|
|
|
ID=$(curl -sf -H "Authorization: token $TOKEN" "$API/releases/tags/$TAG" | jq -r '.id // empty' || true)
|
|
if [ -z "$ID" ]; then
|
|
ID=$(jq -n --arg t "$TAG" --arg n "Febe $VERSION" --arg b "$NOTE" --argjson p "$PRE" \
|
|
'{tag_name:$t, name:$n, body:$b, draft:false, prerelease:$p}' \
|
|
| curl -sf -X POST -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
|
--data-binary @- "$API/releases" | jq -r .id)
|
|
echo "Release $TAG creata (id $ID)"
|
|
else
|
|
# Le note dicono come è andata questa volta (per esempio: l'immagine ora è pubblicata).
|
|
jq -n --arg b "$NOTE" '{body:$b}' \
|
|
| 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 indica il profilo seccomp con un percorso relativo: l'archivio li porta insieme.
|
|
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"
|
|
|
|
ESISTENTI=$(curl -sf -H "Authorization: token $TOKEN" "$API/releases/$ID/assets" | jq -r '.[].name')
|
|
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
|