.github/workflows/release.yml #48
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: Create Release | ||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*' # Se dispara cuando se sube un tag que empieza con 'v' | ||
| jobs: | ||
| release: | ||
| name: Create GitHub Release | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write # Necesario para crear releases | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 # Necesario para obtener el historial completo y el mensaje del tag | ||
| - name: Get tag name | ||
| id: tag | ||
| run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | ||
| - name: Get tag message | ||
| id: tag_message | ||
| run: | | ||
| TAG_NAME=${GITHUB_REF#refs/tags/} | ||
| # Obtener el mensaje del tag anotado, o usar el nombre del tag si no hay mensaje | ||
| TAG_MESSAGE=$(git tag -l --format='%(contents)' "$TAG_NAME" 2>/dev/null || echo "") | ||
| if [ -z "$TAG_MESSAGE" ]; then | ||
| TAG_MESSAGE="Release $TAG_NAME" | ||
| fi | ||
| # Preservar saltos de línea usando heredoc (no se necesita escape) | ||
| { | ||
| echo "MESSAGE<<EOF" | ||
| echo "$TAG_MESSAGE" | ||
| echo "EOF" | ||
| } >> $GITHUB_OUTPUT | ||
| - name: Extract version from tag | ||
| id: version | ||
| run: | | ||
| TAG_NAME=${GITHUB_REF#refs/tags/} | ||
| # Remover el prefijo 'v' si existe | ||
| VERSION=${TAG_NAME#v} | ||
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | ||
| - name: Get changelog entry | ||
| id: changelog | ||
| run: | | ||
| VERSION="${{ steps.version.outputs.VERSION }}" | ||
| CHANGELOG_FILE="docs/CHANGELOG.md" | ||
| if [ -f "$CHANGELOG_FILE" ]; then | ||
| # Buscar la sección del changelog para esta versión | ||
| # Busca líneas que empiecen con ## seguido de la versión (con o sin v) | ||
| CHANGELOG_ENTRY=$(awk "/^## \[?$VERSION\]?/ {flag=1; next} /^## \[?[0-9]/ {flag=0} flag" "$CHANGELOG_FILE" 2>/dev/null || echo "") | ||
| if [ -n "$CHANGELOG_ENTRY" ]; then | ||
| # Preservar saltos de línea usando heredoc (no se necesita escape) | ||
| echo "HAS_CHANGELOG=true" >> $GITHUB_OUTPUT | ||
| { | ||
| echo "ENTRY<<EOF" | ||
| echo "$CHANGELOG_ENTRY" | ||
| echo "EOF" | ||
| } >> $GITHUB_OUTPUT | ||
| else | ||
| echo "HAS_CHANGELOG=false" >> $GITHUB_OUTPUT | ||
| fi | ||
| else | ||
| echo "HAS_CHANGELOG=false" >> $GITHUB_OUTPUT | ||
| fi | ||
| - name: Create Release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| tag_name: ${{ steps.tag.outputs.TAG_NAME }} | ||
| name: Release ${{ steps.tag.outputs.TAG_NAME }} | ||
| body: | | ||
| ${{ steps.tag_message.outputs.MESSAGE }} | ||
| ${{ steps.changelog.outputs.HAS_CHANGELOG == 'true' && format(' | ||
| ## Changelog | ||
| {0}', steps.changelog.outputs.ENTRY) || '' }} | ||
| draft: false | ||
| prerelease: ${{ contains(steps.tag.outputs.TAG_NAME, '-alpha') || contains(steps.tag.outputs.TAG_NAME, '-beta') || contains(steps.tag.outputs.TAG_NAME, '-rc') }} | ||
| generate_release_notes: true # GitHub generará notas automáticas basadas en los commits | ||
| # Maintainer: Héctor Franco Aceituno (@HecFranco) | ||
| # Organization: nowo-tech (https://github.com/nowo-tech) | ||