# Le Gitea Actions del gioco: girano sul runner del PC di Andrea (make runner; label ubuntu-latest = node:22-bookworm). # A ogni push su main e a ogni tag i test unitari; su un tag vX.Y.Z, se passano, la release con i commit dal tag prima. # Il controllo dei file pubblicabili non sta qui (a pipeline partita il push è già pubblico): è l'hook pre-push. name: test on: push: branches: [main] tags: ['v*'] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Test unitari run: node --version && node --test tests/*.test.mjs release: needs: test if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Release del tag env: TOKEN: ${{ secrets.GITEA_TOKEN }} TAG: ${{ github.ref_name }} API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }} run: | prev=$(git describe --tags --abbrev=0 "$TAG^" 2>/dev/null || true) { echo "Si gioca su https://50037.manzolo.it; qui sotto lo zip di questa versione." echo echo "Cosa cambia${prev:+ da $prev}:" echo git log --no-merges --format='- %s' ${prev:+$prev..}"$TAG" | grep -v -e '^- Versione [0-9]' | cut -c1-400 } > note.md node -e 'const fs=require("fs");process.stdout.write(JSON.stringify({tag_name:process.env.TAG,name:"Versione "+process.env.TAG.slice(1),body:fs.readFileSync("note.md","utf8")}))' > release.json code=$(curl -s -o risposta.json -w '%{http_code}' -X POST -H "Authorization: token $TOKEN" -H 'Content-Type: application/json' --data @release.json "$API/releases") cat risposta.json | head -c 400; echo [ "$code" = 201 ] || [ "$code" = 409 ]