Flusso di rilascio (installatore Windows, immagine Docker, release) e decisioni dell'ondata 5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
2 files changed
+167
No files matched your search
@@ -0,0 +1,134 @@
|
||||
# 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.
|
||||
#
|
||||
# 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.
|
||||
# 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).
|
||||
name: rilascio
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
|
||||
jobs:
|
||||
windows:
|
||||
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; }
|
||||
echo "VERSION=$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
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Versione, registro e nome dell'immagine
|
||||
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; }
|
||||
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"
|
||||
|
||||
- name: Costruzione dell'immagine (le prove girano dentro la build)
|
||||
run: |
|
||||
docker build -f docker/Dockerfile \
|
||||
--build-arg VERSION="$VERSION" \
|
||||
--build-arg GIT_COMMIT="${GITHUB_SHA::12}" \
|
||||
-t "$IMAGE:$VERSION" .
|
||||
docker run --rm --entrypoint /usr/bin/chromium "$IMAGE:$VERSION" --version
|
||||
|
||||
- name: Pubblicazione sul registro di Gitea
|
||||
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
|
||||
fi
|
||||
echo "$TOKEN" | docker login "$REGISTRY" -u "${{ gitea.actor }}" --password-stdin
|
||||
docker push "$IMAGE:$VERSION"
|
||||
case "$VERSION" in
|
||||
*-*) echo "Versione di anteprima: :latest non si sposta." ;;
|
||||
*) docker tag "$IMAGE:$VERSION" "$IMAGE:latest" && docker push "$IMAGE:latest" ;;
|
||||
esac
|
||||
docker logout "$REGISTRY"
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: windows
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: windows
|
||||
path: out
|
||||
|
||||
- name: Release con installatore, zip portabile, modello Unraid e compose
|
||||
env:
|
||||
TOKEN: ${{ github.token }}
|
||||
API: ${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}
|
||||
run: |
|
||||
set -eu
|
||||
TAG="${GITHUB_REF_NAME}"
|
||||
VERSION="${TAG#v}"
|
||||
case "$VERSION" in *-*) PRE=true ;; *) PRE=false ;; esac
|
||||
NOTE=$(awk -v v="$VERSION" '/^## /{p=($2==v)} p' CHANGELOG.md || true)
|
||||
[ -n "$NOTE" ] || NOTE="Febe $VERSION"
|
||||
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
|
||||
echo "Release $TAG già presente (id $ID): aggiungo gli allegati mancanti"
|
||||
fi
|
||||
cp docker/unraid/febe.xml "out/febe-unraid-$VERSION.xml"
|
||||
cp docker/compose.yml "out/febe-compose-$VERSION.yml"
|
||||
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
|
||||
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
|
||||
Reference in new issue
Block a user