ci(release): optimize changelog git log regex pattern #1
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: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Release version tag (e.g. v1.0.0, leave empty for automated numerical version)' | |
| required: false | |
| default: '' | |
| permissions: | |
| contents: write | |
| jobs: | |
| test: | |
| name: Run Tests & Verification | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Source | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: 'go.mod' | |
| cache: true | |
| - name: Install CGO build dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc pkg-config libgtk-3-dev libayatana-appindicator3-dev | |
| - name: Run Linters | |
| run: make lint | |
| - name: Run Tests | |
| run: make test | |
| build-and-release: | |
| name: Build & Release | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Source (full history) | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: 'go.mod' | |
| cache: true | |
| - name: Install CGO build dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc pkg-config libgtk-3-dev libayatana-appindicator3-dev | |
| - name: Determine Release Tag & Time | |
| id: release_info | |
| run: | | |
| export TZ=Asia/Kolkata | |
| DISPLAY_TIME=$(date +'%d %b %Y, %H:%M IST') | |
| echo "DISPLAY_TIME=$DISPLAY_TIME" >> $GITHUB_OUTPUT | |
| BASE_VER=$(grep -m1 '^VERSION' Makefile | cut -d'=' -f2 | tr -d ' ' | sed 's/^v//') | |
| if [ -z "$BASE_VER" ]; then | |
| BASE_VER="1.0.0" | |
| fi | |
| MAJOR_MINOR=$(echo "$BASE_VER" | cut -d'.' -f1,2) | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.version }}" ]; then | |
| TAG="${{ github.event.inputs.version }}" | |
| [[ "$TAG" != v* ]] && TAG="v$TAG" | |
| elif [ "${{ github.ref_type }}" = "tag" ]; then | |
| TAG="${{ github.ref_name }}" | |
| else | |
| TAG="v${MAJOR_MINOR}.${{ github.run_number }}" | |
| fi | |
| echo "TAG=$TAG" >> $GITHUB_OUTPUT | |
| - name: Build Binary with Makefile | |
| run: make build VERSION=${{ steps.release_info.outputs.TAG }} | |
| - name: Generate SHA256 Checksums | |
| run: | | |
| cd builds | |
| sha256sum WarpGUI_Linux_x64 > checksums.txt | |
| cat checksums.txt | |
| - name: Generate Structured Changelog | |
| id: changelog | |
| run: | | |
| LAST_TAG=$(git describe --tags --exclude='latest' --abbrev=0 HEAD~1 2>/dev/null || echo "") | |
| RANGE="HEAD" | |
| if [ -n "$LAST_TAG" ]; then | |
| RANGE="${LAST_TAG}..HEAD" | |
| fi | |
| FEATS=$(git log "$RANGE" -E --grep="^[Ff]eat" --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))") | |
| FIXES=$(git log "$RANGE" -E --grep="^[Ff]ix" --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))") | |
| CHORES=$(git log "$RANGE" -E --grep="^([Cc]hore|[Dd]ocs|[Cc]i|[Rr]efactor|[Ss]tyle|[Tt]est)" --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))") | |
| OTHERS=$(git log "$RANGE" --invert-grep -E --grep="^([Ff]eat|[Ff]ix|[Cc]hore|[Dd]ocs|[Cc]i|[Rr]efactor|[Ss]tyle|[Tt]est)" --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))") | |
| CL_FILE=$(mktemp) | |
| { | |
| echo "### 💡 Highlights" | |
| echo "WarpGUI automated release build (${{ steps.release_info.outputs.TAG }})." | |
| echo "" | |
| if [ -n "$FEATS" ]; then | |
| echo "### 🚀 Features & Enhancements" | |
| echo "$FEATS" | |
| echo "" | |
| fi | |
| if [ -n "$FIXES" ]; then | |
| echo "### 🐛 Bug Fixes" | |
| echo "$FIXES" | |
| echo "" | |
| fi | |
| if [ -n "$CHORES" ]; then | |
| echo "### 🧹 Maintenance & Chores" | |
| echo "$CHORES" | |
| echo "" | |
| fi | |
| if [ -n "$OTHERS" ]; then | |
| echo "### 📋 Other Commits" | |
| echo "$OTHERS" | |
| echo "" | |
| fi | |
| if [ -n "$LAST_TAG" ]; then | |
| echo "### 🔗 Full Changelog" | |
| echo "https://github.com/${{ github.repository }}/compare/${LAST_TAG}...${{ steps.release_info.outputs.TAG }}" | |
| echo "" | |
| fi | |
| } > "$CL_FILE" | |
| { | |
| echo "CHANGELOG<<EOF" | |
| cat "$CL_FILE" | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| rm -f "$CL_FILE" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.release_info.outputs.TAG }} | |
| name: "WarpGUI Release #${{ github.run_number }} (${{ steps.release_info.outputs.TAG }})" | |
| make_latest: "true" | |
| body: | | |
| ⚡ **WarpGUI Automated Release** | |
| 📅 **Built at:** ${{ steps.release_info.outputs.DISPLAY_TIME }} | |
| ${{ steps.changelog.outputs.CHANGELOG }} | |
| ### 📦 Artifacts & Integrity | |
| Binary assets are attached below along with `checksums.txt` (SHA256). | |
| files: | | |
| builds/WarpGUI_Linux_x64 | |
| builds/checksums.txt | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |