# ============================================================================= # Release — a ogni tag vX.Y.Z: verifica completa, pacchetto (zip, tar.gz, SHA256SUMS.txt, # BUILD-INFO.txt) e pubblicazione nella sezione «Release» del repository Forgejo. # # Come rilasciare (dettagli nel README): # 1. aggiornare "version" in package.json e la sezione ## [X.Y.Z] di CHANGELOG.md; # 2. commit su main; 3. git tag vX.Y.Z && git push origin vX.Y.Z # Il workflow si ferma se il tag non coincide con la versione di package.json o se manca # la sezione del CHANGELOG. # # RUNNER: `runs-on: docker` è il label più comune di forgejo-runner; sostituirlo se il # runner dell'istanza ne usa un altro (es. `ubuntu-latest`). # # TOKEN: su alcune istanze il token automatico del workflow non può creare release. # In tal caso creare un access token (Impostazioni utente → Applicazioni → Genera token, # permesso «write:repository») e salvarlo come segreto del repository con nome # FORGEJO_TOKEN (Impostazioni del repository → Actions → Segreti). Se l'istanza non accetta # nomi che iniziano con FORGEJO_, usare RELEASE_TOKEN. Se il segreto esiste viene usato al # posto del token automatico; serve anche per avviare il deploy automatico facoltativo # (gli eventi creati con il token automatico non avviano altri workflow). # # PUBBLICAZIONE: prima con l'action forgejo-release; se l'action non riesce (es. strumenti # mancanti nell'immagine), lo step successivo pubblica la stessa release con l'API REST # (scripts/release-upload.sh, solo curl e node). # ============================================================================= name: Release on: push: tags: ['v*.*.*'] env: ASTRO_TELEMETRY_DISABLED: '1' CI: 'true' jobs: release: name: Pacchetto e pubblicazione runs-on: docker # label del runner: adattare (es. ubuntu-latest) container: image: mcr.microsoft.com/playwright:v1.56.1-noble # = versione di @playwright/test timeout-minutes: 40 steps: - uses: https://code.forgejo.org/actions/checkout@v4 with: fetch-depth: 0 - uses: https://code.forgejo.org/actions/setup-node@v4 with: node-version-file: .nvmrc cache: npm - name: Data riproducibile (data del commit) run: echo "SOURCE_DATE_EPOCH=$(git log -1 --format=%ct)" >> "$GITHUB_ENV" - name: Dipendenze run: npm ci - name: Controlli preliminari (tag, versione, CHANGELOG) env: RELEASE_VERSION: ${{ github.ref_name }} run: | node -e 'const v=require("./package.json").version; const t=process.env.RELEASE_VERSION.replace(/^v/,""); if (v!==t) { console.error(`Il tag ${process.env.RELEASE_VERSION} non corrisponde a package.json (${v})`); process.exit(1); }' node scripts/changelog-notes.mjs "$RELEASE_VERSION" > /dev/null - name: npm run verify # nessuna release senza test verdi run: npm run verify - name: npm run package # crea release/ e ne verifica il contenuto run: npm run package env: RELEASE_VERSION: ${{ github.ref_name }} - name: Note di rilascio dal CHANGELOG id: notes run: | { echo 'notes<> "$GITHUB_OUTPUT" - name: Pubblica la release su Forgejo id: action continue-on-error: true # in caso di errore pubblica lo step successivo (API REST) uses: https://code.forgejo.org/actions/forgejo-release@v2 with: direction: upload url: ${{ github.server_url }} repo: ${{ github.repository }} tag: ${{ github.ref_name }} token: ${{ secrets.FORGEJO_TOKEN || secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }} release-dir: release # contiene SOLO zip, tar.gz, SHA256SUMS.txt, BUILD-INFO.txt release-notes: ${{ steps.notes.outputs.notes }} prerelease: ${{ contains(github.ref_name, '-') }} verbose: true - name: Pubblica la release (API REST, se l'action non è riuscita) if: steps.action.outcome == 'failure' env: FORGEJO_URL: ${{ github.server_url }} FORGEJO_REPO: ${{ github.repository }} FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN || secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }} run: bash scripts/release-upload.sh "${{ github.ref_name }}" release - name: Report Playwright (solo in caso di errore) if: failure() uses: https://code.forgejo.org/actions/upload-artifact@v3 # usare @v4 se l'istanza Forgejo lo supporta with: name: playwright-report path: playwright-report retention-days: 14