ci: workflow Forgejo, pacchetto di rilascio e file di deploy
- .forgejo/workflows/ci.yml: npm run verify nel container Playwright a ogni push su main e pull request, report come artifact, link esterni non bloccanti - .forgejo/workflows/release.yml: ai tag vX.Y.Z verifica, pacchetto e pubblicazione nella sezione Release con forgejo-release (token FORGEJO_TOKEN) - scripts/package.mjs: zip e tar.gz riproducibili, SHA256SUMS.txt, BUILD-INFO.txt - scripts/check-package.mjs: confronto 1:1 con dist/, impronte, sha256sum -c - scripts/changelog-notes.mjs e release-upload.sh (API REST di Forgejo) - deploy/: nginx.conf.example, gestore PHP del modulo, esempio di deploy automatico (rsync, FTPS, rclone) non attivo Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016zJ9ZWGKvoKoxYwbmnRKdJ
This commit is contained in:
11 files changed
+1116
-8
No files matched your search
@@ -1,3 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
# Segnaposto della fase 0: l'implementazione completa arriva nella fase 7.
|
||||
echo "scripts/release-upload.sh: non ancora implementato (fase 0)."
|
||||
# =============================================================================
|
||||
# Pubblica una release su Forgejo tramite API REST e carica i file di release/.
|
||||
# Alternativa manuale (o step di riserva) all'action forgejo-release del workflow.
|
||||
#
|
||||
# Uso:
|
||||
# FORGEJO_URL=https://forgejo.example.it \
|
||||
# FORGEJO_REPO=proprietario/repository \
|
||||
# FORGEJO_TOKEN=<token con permesso write:repository> \
|
||||
# scripts/release-upload.sh v1.0.0 [cartella] # cartella predefinita: release
|
||||
#
|
||||
# Prima eseguire `npm run package` con RELEASE_VERSION=v1.0.0. Il tag deve già esistere
|
||||
# sul server (git push origin v1.0.0). Le note della release sono prese da CHANGELOG.md.
|
||||
# Se la release esiste già, i file con lo stesso nome vengono sostituiti.
|
||||
# =============================================================================
|
||||
set -euo pipefail
|
||||
|
||||
TAG="${1:-${RELEASE_VERSION:-}}"
|
||||
DIR="${2:-release}"
|
||||
|
||||
die() { echo "✘ $*" >&2; exit 1; }
|
||||
|
||||
[ -n "$TAG" ] || die "indicare il tag, es.: scripts/release-upload.sh v1.0.0"
|
||||
[ -n "${FORGEJO_URL:-}" ] || die "variabile FORGEJO_URL mancante (es. https://forgejo.example.it)"
|
||||
[ -n "${FORGEJO_REPO:-}" ] || die "variabile FORGEJO_REPO mancante (es. proprietario/repository)"
|
||||
[ -n "${FORGEJO_TOKEN:-}" ] || die "variabile FORGEJO_TOKEN mancante"
|
||||
[ -d "$DIR" ] || die "cartella $DIR assente: eseguire prima npm run package"
|
||||
command -v curl >/dev/null || die "curl non installato"
|
||||
command -v node >/dev/null || die "node non installato"
|
||||
|
||||
API="${FORGEJO_URL%/}/api/v1/repos/${FORGEJO_REPO}"
|
||||
AUTH="Authorization: token ${FORGEJO_TOKEN}"
|
||||
|
||||
json_field() { node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const v=JSON.parse(s)[process.argv[1]];if(v===undefined)process.exit(1);console.log(typeof v==="object"?JSON.stringify(v):v)})' "$1"; }
|
||||
|
||||
NOTES="$(node scripts/changelog-notes.mjs "$TAG")"
|
||||
PAYLOAD="$(node -e 'console.log(JSON.stringify({tag_name:process.argv[1],name:process.argv[1],body:process.argv[2],draft:false,prerelease:/-/.test(process.argv[1])}))' "$TAG" "$NOTES")"
|
||||
|
||||
echo "→ Release $TAG su $FORGEJO_REPO"
|
||||
if EXISTING="$(curl -fsS -H "$AUTH" "$API/releases/tags/$TAG" 2>/dev/null)"; then
|
||||
RELEASE_ID="$(printf '%s' "$EXISTING" | json_field id)"
|
||||
echo " release già esistente (id $RELEASE_ID): aggiornamento dei file"
|
||||
else
|
||||
CREATED="$(curl -fsS -X POST -H "$AUTH" -H 'Content-Type: application/json' -d "$PAYLOAD" "$API/releases")" \
|
||||
|| die "creazione della release non riuscita (permessi del token? il tag esiste sul server?)"
|
||||
RELEASE_ID="$(printf '%s' "$CREATED" | json_field id)"
|
||||
echo " release creata (id $RELEASE_ID)"
|
||||
fi
|
||||
|
||||
ASSETS="$(curl -fsS -H "$AUTH" "$API/releases/$RELEASE_ID/assets")"
|
||||
for FILE in "$DIR"/*; do
|
||||
[ -f "$FILE" ] || continue
|
||||
NAME="$(basename "$FILE")"
|
||||
OLD_ID="$(printf '%s' "$ASSETS" | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const a=JSON.parse(s).find(x=>x.name===process.argv[1]);if(a)console.log(a.id)})' "$NAME")"
|
||||
if [ -n "$OLD_ID" ]; then
|
||||
curl -fsS -X DELETE -H "$AUTH" "$API/releases/$RELEASE_ID/assets/$OLD_ID" >/dev/null
|
||||
fi
|
||||
curl -fsS -X POST -H "$AUTH" -F "attachment=@${FILE}" \
|
||||
"$API/releases/$RELEASE_ID/assets?name=$(node -e 'console.log(encodeURIComponent(process.argv[1]))' "$NAME")" >/dev/null \
|
||||
|| die "caricamento di $NAME non riuscito"
|
||||
echo " ✔ $NAME"
|
||||
done
|
||||
echo "✔ Release $TAG pubblicata: ${FORGEJO_URL%/}/${FORGEJO_REPO}/releases/tag/$TAG"
|
||||
Reference in new issue
Block a user