From 0e31d28342fa4cb4551bcff1cec91e0ec3f63f6c Mon Sep 17 00:00:00 2001 From: Lucas Rayan Date: Fri, 30 Oct 2026 12:37:01 -0300 Subject: [PATCH] ci: create a Gitea release when a v* tag is pushed Notes come from the matching CHANGELOG.md section. The macOS and Windows binaries the old release workflow built need runners this Gitea does not have. The CI also ignores .wolf, .claude and the release files. Co-Authored-By: Claude Sonnet 5.5 --- .gitea/workflows/ci.yml | 4 ++-- .gitea/workflows/release.yml | 31 +++++++++++++++++++++++++++++++ scripts/release-notes.sh | 28 ++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 .gitea/workflows/release.yml create mode 100755 scripts/release-notes.sh diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index a173b6d..dd085e7 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -4,9 +4,9 @@ on: # Mudança só de documentação não precisa de 6 jobs em 3 sistemas. push: branches: [main] - paths-ignore: ['**.md', 'docs/**', 'LICENSE*', '.gitignore', '.githooks/**'] + paths-ignore: ['**.md', 'docs/**', 'LICENSE*', '.gitignore', '.githooks/**', '.wolf/**', '.claude/**', 'scripts/release-notes.sh', '.gitea/workflows/release.yml'] pull_request: - paths-ignore: ['**.md', 'docs/**', 'LICENSE*', '.gitignore', '.githooks/**'] + paths-ignore: ['**.md', 'docs/**', 'LICENSE*', '.gitignore', '.githooks/**', '.wolf/**', '.claude/**', 'scripts/release-notes.sh', '.gitea/workflows/release.yml'] concurrency: group: ci-${{ github.ref }} diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..6ebe9d2 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,31 @@ +name: Release + +# Cria a entrada em "Releases" quando uma tag v* é enviada, com as notas da +# seção correspondente do CHANGELOG.md (scripts/release-notes.sh). +# +# Só as notas: os binários para macOS e Windows exigiam runners que o Gitea daqui +# não tem (o único runner é Linux arm64), então não são gerados neste fluxo. +on: + push: + tags: ['v*'] + +jobs: + release: + name: Cria a release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + - 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 + pre=false; case "$TAG" in *-*) pre=true ;; esac + jq -n --arg tag "$TAG" --arg name "Sabiá ${TAG#v}" --rawfile body notes.md --argjson pre "$pre" \ + '{tag_name:$tag, name:$name, body:$body, prerelease:$pre}' > release.json + curl -fsS -X POST "$API/releases" -H "Authorization: token $TOKEN" \ + -H 'Content-Type: application/json' -d @release.json diff --git a/scripts/release-notes.sh b/scripts/release-notes.sh new file mode 100755 index 0000000..c73ead8 --- /dev/null +++ b/scripts/release-notes.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Imprime as notas de uma release: a seção do CHANGELOG.md daquela versão, ou o +# log de commits desde a tag anterior quando o changelog não tem a seção. +# +# scripts/release-notes.sh v1.2.3 +set -euo pipefail + +tag=${1:?uso: release-notes.sh } +version=${tag#v} + +section="" +if [ -f CHANGELOG.md ]; then + section=$(awk -v head="## [$version]" ' + index($0, head) == 1 { found = 1; next } + found && /^## \[/ { exit } + found && /^\[[^]]+\]: / { next } + found { print } + ' CHANGELOG.md) +fi + +if [ -n "$(printf '%s' "$section" | tr -d '[:space:]')" ]; then + printf '%s\n' "$section" +else + previous=$(git describe --tags --abbrev=0 "$tag^" 2>/dev/null || true) + echo "## Mudanças${previous:+ desde $previous}" + echo + git log --no-merges --format='- %s (%h)' "${previous:+$previous..}$tag" +fi