From 91457b649046a69f9e43864a7efcefe9410d790a Mon Sep 17 00:00:00 2001 From: Felipe Coutinho Date: Sat, 28 Mar 2026 15:13:26 +0000 Subject: [PATCH] =?UTF-8?q?chore(ci):=20adicionar=20workflow=20de=20releas?= =?UTF-8?q?e=20autom=C3=A1tico?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cria tag e GitHub Release a partir da versão do package.json e da entrada correspondente no CHANGELOG.md ao fazer push na branch main. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/release.yml | 59 +++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a8b6b08 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,59 @@ +name: Release + +on: + push: + branches: + - main + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Read version from package.json + id: version + run: | + VERSION=$(jq -r '.version' package.json) + echo "value=$VERSION" >> $GITHUB_OUTPUT + echo "tag=v$VERSION" >> $GITHUB_OUTPUT + + - name: Check if tag already exists + id: tag_check + run: | + if git ls-remote --tags origin "refs/tags/v${{ steps.version.outputs.value }}" | grep -q .; then + echo "exists=true" >> $GITHUB_OUTPUT + else + echo "exists=false" >> $GITHUB_OUTPUT + fi + + - name: Extract changelog for this version + if: steps.tag_check.outputs.exists == 'false' + id: changelog + run: | + VERSION="${{ steps.version.outputs.value }}" + # Extrai o bloco entre ## [X.Y.Z] e o próximo ## [ + NOTES=$(awk "/^## \[$VERSION\]/{found=1; next} found && /^## \[/{exit} found{print}" CHANGELOG.md) + # Remove linhas em branco do início e fim + NOTES=$(echo "$NOTES" | sed '/./,$!d' | sed -e :a -e '/^\n*$/{$d;N;ba}') + { + echo "notes<> $GITHUB_OUTPUT + + - name: Create tag and GitHub Release + if: steps.tag_check.outputs.exists == 'false' + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.version.outputs.tag }} + name: ${{ steps.version.outputs.tag }} + body: ${{ steps.changelog.outputs.notes }} + draft: false + prerelease: false