name: Release # Na main valida o commit (chamando o ci.yml). Numa tag v*, gera o .deb com a # versão da tag e publica a release no Gitea com o pacote, o SHA256SUMS e as # notas da seção do CHANGELOG.md. Se o commit da tag já passou na main, a suíte # não roda de novo. on: push: branches: [main] paths-ignore: ['**.md', 'LICENSE', '.claude/**', '.wolf/**'] tags: ['v*'] workflow_dispatch: concurrency: group: release cancel-in-progress: false jobs: plano: name: Plano (este commit já foi validado?) runs-on: ubuntu-24.04-arm outputs: reuse: ${{ steps.plano.outputs.reuse }} steps: - uses: actions/checkout@v4 - id: plano run: scripts/plano-ci.sh "${{ gitea.server_url }}" "${{ gitea.repository }}" "${{ gitea.sha }}" "${{ gitea.token }}" >> "$GITHUB_OUTPUT" ci: needs: plano if: ${{ needs.plano.outputs.reuse != 'true' }} uses: ./.gitea/workflows/ci.yml release: name: Publica a release needs: [plano, ci] # O ci é pulado, e não bem-sucedido, quando o commit já foi validado. if: ${{ !cancelled() && needs.plano.result == 'success' && (needs.ci.result == 'success' || needs.plano.outputs.reuse == 'true') && startsWith(gitea.ref, 'refs/tags/v') }} runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Pacote run: | empacotamento/gerar-deb.sh "${GITEA_REF_NAME#v}" (cd dist && sha256sum copiado_all.deb > SHA256SUMS) env: GITEA_REF_NAME: ${{ gitea.ref_name }} - name: Release env: TAG: ${{ gitea.ref_name }} TOKEN: ${{ gitea.token }} API: ${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }} run: | scripts/release-notes.sh "$TAG" > notes.md jq -n --arg tag "$TAG" --arg name "Copiado ${TAG#v}" --rawfile body notes.md \ '{tag_name:$tag, name:$name, body:$body, prerelease:false}' > release.json id=$(curl -fsS -X POST "$API/releases" -H "Authorization: token $TOKEN" \ -H 'Content-Type: application/json' -d @release.json | jq -r .id) for f in dist/copiado_all.deb dist/SHA256SUMS; do curl -fsS -X POST "$API/releases/$id/assets?name=$(basename "$f")" \ -H "Authorization: token $TOKEN" -F "attachment=@$f" >/dev/null done