Prepare v2.5.1 release #34
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@v7 | |
| 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/} | |
| TAG_MESSAGE=$(git tag -l --format='%(contents)' "$TAG_NAME" 2>/dev/null || echo "") | |
| if [ -z "$TAG_MESSAGE" ]; then | |
| TAG_MESSAGE="Release $TAG_NAME" | |
| fi | |
| DELIM="EOF_MSG_$(openssl rand -hex 8)" | |
| { echo "MESSAGE<<${DELIM}"; printf '%s' "$TAG_MESSAGE"; echo ""; echo "${DELIM}"; } >> $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 }}" | |
| # Escapar puntos para usar versión en regex (ej. 1.0.10 -> 1\.0\.10) | |
| VERSION_RE=$(echo "$VERSION" | sed 's/\./\\./g') | |
| CHANGELOG_FILE="docs/CHANGELOG.md" | |
| if [ -f "$CHANGELOG_FILE" ]; then | |
| CHANGELOG_ENTRY=$(awk "/^## \\[?${VERSION_RE}\\]?/ {flag=1; next} /^## \\[?[0-9]/ {flag=0} flag" "$CHANGELOG_FILE" 2>/dev/null || echo "") | |
| if [ -n "$CHANGELOG_ENTRY" ]; then | |
| echo "HAS_CHANGELOG=true" >> $GITHUB_OUTPUT | |
| DELIM="EOF_CL_$(openssl rand -hex 8)" | |
| { echo "ENTRY<<${DELIM}"; printf '%s' "$CHANGELOG_ENTRY"; echo ""; echo "${DELIM}"; } >> $GITHUB_OUTPUT | |
| else | |
| echo "HAS_CHANGELOG=false" >> $GITHUB_OUTPUT | |
| fi | |
| else | |
| echo "HAS_CHANGELOG=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Prepare release body | |
| id: body | |
| env: | |
| TAG_MSG: ${{ steps.tag_message.outputs.MESSAGE }} | |
| HAS_CHANGELOG: ${{ steps.changelog.outputs.HAS_CHANGELOG }} | |
| CHANGELOG_ENTRY: ${{ steps.changelog.outputs.ENTRY }} | |
| run: | | |
| BODY="$TAG_MSG" | |
| if [ "$HAS_CHANGELOG" = "true" ] && [ -n "$CHANGELOG_ENTRY" ]; then | |
| BODY=$(printf '%s\n\n## Changelog\n\n%s' "$TAG_MSG" "$CHANGELOG_ENTRY") | |
| fi | |
| DELIM=$(openssl rand -hex 16) | |
| { echo "content<<${DELIM}"; printf '%s' "$BODY"; echo ""; echo "${DELIM}"; } >> $GITHUB_OUTPUT | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| tag_name: ${{ steps.tag.outputs.TAG_NAME }} | |
| name: Release ${{ steps.tag.outputs.TAG_NAME }} | |
| body: ${{ steps.body.outputs.content }} | |
| 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) | |