feat: add Max Battles quick pick support #56
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 Changelog | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: [main] | |
| jobs: | |
| update-changelog: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Categorize PR | |
| id: categorize | |
| run: | | |
| TITLE="${{ github.event.pull_request.title }}" | |
| PR_NUM="${{ github.event.pull_request.number }}" | |
| PR_URL="${{ github.event.pull_request.html_url }}" | |
| # Extract category from conventional commit prefix | |
| if echo "$TITLE" | grep -qiE '^feat(\(.*\))?[!]?:'; then | |
| CATEGORY="Added" | |
| elif echo "$TITLE" | grep -qiE '^fix(\(.*\))?[!]?:'; then | |
| CATEGORY="Fixed" | |
| elif echo "$TITLE" | grep -qiE '^refactor(\(.*\))?[!]?:'; then | |
| CATEGORY="Changed" | |
| elif echo "$TITLE" | grep -qiE '^perf(\(.*\))?[!]?:'; then | |
| CATEGORY="Changed" | |
| elif echo "$TITLE" | grep -qiE '^breaking(\(.*\))?[!]?:'; then | |
| CATEGORY="Changed" | |
| elif echo "$TITLE" | grep -qiE '^deprecate(\(.*\))?[!]?:'; then | |
| CATEGORY="Deprecated" | |
| elif echo "$TITLE" | grep -qiE '^remove(\(.*\))?[!]?:'; then | |
| CATEGORY="Removed" | |
| elif echo "$TITLE" | grep -qiE '^security(\(.*\))?[!]?:'; then | |
| CATEGORY="Security" | |
| elif echo "$TITLE" | grep -qiE '^docs(\(.*\))?[!]?:'; then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| elif echo "$TITLE" | grep -qiE '^(style|chore|ci|test)(\(.*\))?[!]?:'; then | |
| echo "skip=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| else | |
| CATEGORY="Changed" | |
| fi | |
| # Strip prefix from title for the entry text | |
| ENTRY=$(echo "$TITLE" | sed -E 's/^[a-zA-Z]+(\(.*\))?[!]?:\s*//') | |
| echo "category=$CATEGORY" >> "$GITHUB_OUTPUT" | |
| echo "entry=$ENTRY" >> "$GITHUB_OUTPUT" | |
| echo "pr_num=$PR_NUM" >> "$GITHUB_OUTPUT" | |
| echo "pr_url=$PR_URL" >> "$GITHUB_OUTPUT" | |
| echo "skip=false" >> "$GITHUB_OUTPUT" | |
| - name: Update CHANGELOG.md | |
| if: steps.categorize.outputs.skip != 'true' | |
| run: | | |
| CATEGORY="${{ steps.categorize.outputs.category }}" | |
| ENTRY="${{ steps.categorize.outputs.entry }}" | |
| PR_NUM="${{ steps.categorize.outputs.pr_num }}" | |
| PR_URL="${{ steps.categorize.outputs.pr_url }}" | |
| # Skip if this PR is already referenced in the [Unreleased] section | |
| # (e.g., changelog was updated manually in the PR branch) | |
| UNRELEASED_BLOCK=$(awk '/^## \[Unreleased\]/,/^## \[[0-9]/' CHANGELOG.md 2>/dev/null) | |
| if echo "$UNRELEASED_BLOCK" | grep -qF "#$PR_NUM"; then | |
| echo "PR #$PR_NUM already referenced in [Unreleased] — skipping auto-insert" | |
| exit 0 | |
| fi | |
| # Check if CHANGELOG.md exists | |
| if [ ! -f CHANGELOG.md ]; then | |
| cat > CHANGELOG.md << 'INIT' | |
| # Changelog | |
| All notable changes to this project are documented in this file. | |
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). | |
| ## [Unreleased] | |
| INIT | |
| fi | |
| # Use awk to insert entry under [Unreleased] only (not older release sections) | |
| # Pass values via environment to avoid awk -v escaping issues with special characters | |
| export AWK_CATEGORY="### $CATEGORY" | |
| export AWK_ENTRY="- $ENTRY ([PR #$PR_NUM]($PR_URL))" | |
| awk ' | |
| BEGIN { category=ENVIRON["AWK_CATEGORY"]; entry=ENVIRON["AWK_ENTRY"]; found_unreleased=0; inserted=0 } | |
| /^## \[Unreleased\]/ { found_unreleased=1; print; next } | |
| # If we hit the next version section, unreleased block is over | |
| found_unreleased && /^## \[/ { | |
| if (!inserted) { | |
| print "" | |
| print category | |
| print entry | |
| inserted=1 | |
| } | |
| found_unreleased=0 | |
| print; next | |
| } | |
| # Found existing category header under [Unreleased] | |
| found_unreleased && !inserted && $0 == category { | |
| print entry | |
| inserted=1 | |
| next | |
| } | |
| # Hit a different category or blank line before any matching category — insert new section before it | |
| found_unreleased && !inserted && /^### / { | |
| print category | |
| print entry | |
| print "" | |
| inserted=1 | |
| print; next | |
| } | |
| { print } | |
| END { | |
| if (!inserted) { | |
| print "" | |
| print category | |
| print entry | |
| } | |
| } | |
| ' CHANGELOG.md > CHANGELOG.tmp | |
| if [ -s CHANGELOG.tmp ]; then | |
| mv CHANGELOG.tmp CHANGELOG.md | |
| else | |
| echo "::error::awk produced empty output — CHANGELOG.md not modified" | |
| rm -f CHANGELOG.tmp | |
| exit 1 | |
| fi | |
| - name: Commit and push | |
| if: steps.categorize.outputs.skip != 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add CHANGELOG.md | |
| git diff --cached --quiet || (git commit -m "docs: update changelog for PR #${{ github.event.pull_request.number }}" && git push) |