88 tag :
99 description : ' Release tag (e.g., v0.3.3)'
1010 required : true
11+ target_ref :
12+ description : ' Branch to check out and update when writing changelog changes'
13+ default : main
14+ required : true
1115
1216permissions :
1317 contents : write
@@ -18,15 +22,20 @@ jobs:
1822 steps :
1923 - uses : actions/checkout@v6
2024 with :
25+ ref : ${{ github.event_name == 'release' && github.event.release.target_commitish || inputs.target_ref }}
2126 fetch-depth : 0 # full history for tag detection and diff stats
2227
2328 - name : Resolve tag
2429 id : tag
2530 run : |
2631 if [[ "${{ github.event_name }}" == "release" ]]; then
2732 echo "tag=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT"
33+ echo "target_ref=${{ github.event.release.target_commitish }}" >> "$GITHUB_OUTPUT"
34+ echo "markdown_post_to=step-summary" >> "$GITHUB_OUTPUT"
2835 else
2936 echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
37+ echo "target_ref=${{ inputs.target_ref }}" >> "$GITHUB_OUTPUT"
38+ echo "markdown_post_to=release,step-summary" >> "$GITHUB_OUTPUT"
3039 fi
3140
3241 # ── Surface 1: GitHub Release body + step summary ──────────
3948 data-format : github-prs
4049 head-ref : ${{ steps.tag.outputs.tag }}
4150 release-tag : ${{ steps.tag.outputs.tag }}
42- post-to : release,step-summary
51+ post-to : ${{ steps.tag.outputs.markdown_post_to }}
4352 token : ${{ secrets.GITHUB_TOKEN }}
4453
4554 # ── Surface 2: Terminal-formatted release asset ────────────
5968
6069 # ── Surface 3: Compact notes for changelog ─────────────────
6170 - name : Generate release notes (compact)
71+ if : github.event_name == 'workflow_dispatch'
6272 uses : ./
6373 id : compact
6474 with :
7282 token : ${{ secrets.GITHUB_TOKEN }}
7383
7484 - name : Commit changelog updates
75- if : steps.compact.outcome == 'success'
85+ if : github.event_name == 'workflow_dispatch' && steps.compact.outcome == 'success'
7686 run : |
7787 if git diff --quiet CHANGELOG.md 2>/dev/null; then
7888 echo "No changelog changes to commit."
8191 git config user.email "github-actions[bot]@users.noreply.github.com"
8292 git add CHANGELOG.md
8393 git commit -m "docs: update CHANGELOG for ${{ steps.tag.outputs.tag }}"
84- git push
94+ git push origin "HEAD:${{ steps.tag.outputs.target_ref }}"
8595 fi
0 commit comments