v1.2.0 #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Version Badge | |
| on: | |
| release: | |
| types: [published, edited] | |
| permissions: | |
| contents: write | |
| jobs: | |
| update-readme: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.RELEASE_PLEASE_TOKEN }} | |
| - name: Extract tag version | |
| id: get_version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| VERSION=${VERSION#v} # Remove o 'v' se existir | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Tag: ${{ github.ref }} → Version: $VERSION" | |
| - name: Update version in README | |
| run: | | |
| # Verifica padrões comuns de badges | |
| if grep -q "shields.io/badge/version-" README.md; then | |
| echo "🔄 Atualizando badge shields.io..." | |
| sed -i.bak -E "s|(https://img\.shields\.io/badge/version-)[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+)|\\1${{ steps.get_version.outputs.version }}\\2|g" README.md | |
| elif grep -q "badge/version-v" README.md; then | |
| echo "🔄 Atualizando badge com 'v'..." | |
| sed -i.bak "s|badge/version-v[0-9]*\.[0-9]*\.[0-9]*|badge/version-v${{ steps.get_version.outputs.version }}|g" README.md | |
| else | |
| echo "⚠️ Nenhum badge de versão encontrado no padrão esperado" | |
| echo "📋 Procure no README por 'version-' e ajuste o regex acima" | |
| exit 0 | |
| fi | |
| # Mostra diferenças | |
| echo "📊 Mudanças:" | |
| git diff README.md || true | |
| - name: Commit and push | |
| if: success() | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add README.md | |
| if git diff --cached --quiet; then | |
| echo "✅ Nenhuma alteração necessária" | |
| else | |
| git commit -m "docs: update version badge to v${{ steps.get_version.outputs.version }}" | |
| git push | |
| echo "🚀 README atualizado com sucesso!" | |
| fi |