Piattaforme: istanza unica dopo lo spostamento dei dati, avvio sicuro del contenitore, rilascio con prove e immagine, accesso senza reindirizzamenti esterni (pkg-1, pkg-2, pkg-3, pkg-4, pkg-5, pkg-6, websec-2, web-8, websec-3)
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
This commit is contained in:
36 files changed
+1683
-152
No files matched your search
+143
-29
@@ -1,16 +1,25 @@
|
||||
# Rilascio a ogni tag vX.Y.Z (anche vX.Y.Z-qualcosa per un'anteprima):
|
||||
# 1. controlla che il tag coincida con <Version> di Directory.Build.props;
|
||||
# 2. Windows: pubblica Febe.exe in un file solo e costruisce il programma di installazione NSIS e lo zip portabile
|
||||
# (installer/costruisci.sh, gira su Linux);
|
||||
# 3. Docker: costruisce l'immagine (le prove girano dentro la build) e la pubblica sul registro dei container di
|
||||
# Gitea come <registro>/<proprietario>/febe:X.Y.Z e :latest (solo per le versioni senza trattino);
|
||||
# 4. crea la release (o la completa, se esiste già) con installatore, zip portabile, modello Unraid e compose.
|
||||
# 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 ma non si pubblica, e il lavoro lo dice.
|
||||
# «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 registro in HTTP: buildx lo tratta come insicuro (configurazione qui sotto).
|
||||
# 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:
|
||||
@@ -18,7 +27,7 @@ on:
|
||||
tags: ["v*"]
|
||||
|
||||
jobs:
|
||||
windows:
|
||||
prove:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -27,7 +36,35 @@ jobs:
|
||||
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; }
|
||||
echo "VERSION=$V" >> "$GITHUB_ENV"
|
||||
|
||||
- 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:
|
||||
@@ -52,48 +89,99 @@ jobs:
|
||||
|
||||
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=$(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; }
|
||||
V="${GITHUB_REF_NAME#v}"
|
||||
REGISTRY="${{ vars.REGISTRY }}"
|
||||
[ -n "$REGISTRY" ] || REGISTRY=$(echo "${{ gitea.server_url }}" | sed -E 's#^https?://##; s#/$##')
|
||||
[ -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 build -f docker/Dockerfile \
|
||||
docker buildx build -f docker/Dockerfile \
|
||||
--build-arg VERSION="$VERSION" \
|
||||
--build-arg GIT_COMMIT="${GITHUB_SHA::12}" \
|
||||
-t "$IMAGE:$VERSION" .
|
||||
-t "$IMAGE:$VERSION" --load .
|
||||
docker run --rm --entrypoint /usr/bin/chromium "$IMAGE:$VERSION" --version
|
||||
|
||||
- name: Pubblicazione sul registro di Gitea
|
||||
- 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 ma non pubblicata."
|
||||
echo "Aggiungi il segreto (token con package: read and write) e rilancia questo lavoro."
|
||||
exit 1
|
||||
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
|
||||
echo "$TOKEN" | docker login "$REGISTRY" -u "${{ gitea.actor }}" --password-stdin
|
||||
docker push "$IMAGE:$VERSION"
|
||||
|
||||
- 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." ;;
|
||||
*) docker tag "$IMAGE:$VERSION" "$IMAGE:latest" && docker push "$IMAGE:latest" ;;
|
||||
*) TAGS="$TAGS -t $IMAGE:latest" ;;
|
||||
esac
|
||||
docker logout "$REGISTRY"
|
||||
# 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
|
||||
needs: windows
|
||||
# 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
|
||||
|
||||
@@ -102,10 +190,13 @@ jobs:
|
||||
name: windows
|
||||
path: out
|
||||
|
||||
- name: Release con installatore, zip portabile, modello Unraid e compose
|
||||
- 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}"
|
||||
@@ -113,6 +204,17 @@ jobs:
|
||||
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" \
|
||||
@@ -121,12 +223,24 @@ jobs:
|
||||
--data-binary @- "$API/releases" | jq -r .id)
|
||||
echo "Release $TAG creata (id $ID)"
|
||||
else
|
||||
echo "Release $TAG già presente (id $ID): aggiungo gli allegati mancanti"
|
||||
# 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"
|
||||
cp docker/compose.yml "out/febe-compose-$VERSION.yml"
|
||||
# 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" "out/febe-compose-$VERSION.yml"; do
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user