Skip to content

Merge pull request #144 from rtenorioh/beta #26

Merge pull request #144 from rtenorioh/beta

Merge pull request #144 from rtenorioh/beta #26

Workflow file for this run

name: Create Release on Tag Push
on:
push:
tags:
- "v*"
jobs:
create_release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Validar que a tag segue o padrão semântico de versão (vX.X.X)
- name: Validate tag format
if: startsWith(github.ref, 'refs/tags/v')
run: |
if ! [[ "${GITHUB_REF#refs/tags/}" =~ ^v[0-9]+(\.[0-9]+){2}$ ]]; then
echo "Tag format is invalid. Must follow vX.X.X"
exit 1
fi
# Instalar GitHub CLI
- name: Install GitHub CLI
run: sudo apt-get install gh
# Autenticar GitHub CLI usando o token do GitHub Actions
- name: Authenticate GitHub CLI
run: gh auth login --with-token <<< "${{ secrets.TOKEN_GITHUB }}"
# Pegar a tag anterior corretamente
- name: Get previous tag
id: prev_tag
run: |
echo "Fetching the previous tag..."
previous_tag=$(git describe --tags $(git rev-list --tags --skip=1 --max-count=1))
echo "Previous tag: $previous_tag"
echo "previous_tag=$previous_tag" >> $GITHUB_OUTPUT
# Listar issues fechadas desde a tag anterior
- name: List closed issues
id: list_closed_issues
run: |
echo "Fetching closed issues since the previous tag..."
issues=$(gh issue list --state closed --search "closed:>${{ steps.prev_tag_date.outputs.prev_tag_date }}" --json title,number --jq '.[] | "- \(.title) (#\(.number))"')
if [ -z "$issues" ]; then
issues="No issues closed."
fi
echo "Issues: $issues"
echo "issues=$issues" >> $GITHUB_OUTPUT
# Atualizar o log de commits
- name: Get commit log
id: commit_log
run: |
echo "Fetching commit log since the previous tag..."
log=$(git log --pretty=format:'- %s (%h)' --abbrev-commit ${{ steps.prev_tag.outputs.previous_tag }}..HEAD)
if [ -z "$log" ]; then
log="No commits."
fi
echo "Log: $log"
echo "log=$log" >> $GITHUB_OUTPUT
# Criar a release com as informações coletadas
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
with:
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
body: |
# O que mudou:
${{ steps.commit_log.outputs.log }}
**Issues Fechadas:**
${{ steps.list_closed_issues.outputs.issues }}
**Comparação de Alterações:**
[Comparar alterações](https://github.com/${{ github.repository }}/compare/${{ steps.prev_tag.outputs.previous_tag }}...${{ github.ref_name }})