|
72 | 72 | if: needs.package.outputs.released == 'true' || github.event_name == 'workflow_dispatch' |
73 | 73 | runs-on: ubuntu-latest |
74 | 74 | permissions: |
75 | | - contents: read |
| 75 | + # contents: write is required by the POST /releases/generate-notes endpoint, |
| 76 | + # even though it only returns text and doesn't actually write anything. |
| 77 | + contents: write |
76 | 78 | strategy: |
77 | 79 | fail-fast: false |
78 | 80 | matrix: |
@@ -160,16 +162,22 @@ jobs: |
160 | 162 |
|
161 | 163 | # Prefer GitHub's auto-generated notes for the range (nicely formatted |
162 | 164 | # with PR links and contributors). Fall back to git log if unavailable. |
163 | | - if [ -n "$base_tag" ] && notes=$(gh api \ |
164 | | - --method POST \ |
165 | | - "/repos/${{ github.repository }}/releases/generate-notes" \ |
166 | | - -f tag_name="${current_tag}" \ |
167 | | - -f previous_tag_name="${base_tag}" \ |
168 | | - --jq '.body' 2>/dev/null) && [ -n "$notes" ]; then |
169 | | - echo "$notes" > /tmp/changelog.md |
170 | | - elif [ -n "$base_tag" ]; then |
171 | | - git log --oneline "${base_tag}..HEAD" > /tmp/changelog.md |
| 165 | + echo "Base tag: ${base_tag:-<none>} / Current tag: ${current_tag}" |
| 166 | + if [ -n "$base_tag" ]; then |
| 167 | + if notes=$(gh api \ |
| 168 | + --method POST \ |
| 169 | + "/repos/${{ github.repository }}/releases/generate-notes" \ |
| 170 | + -f tag_name="${current_tag}" \ |
| 171 | + -f previous_tag_name="${base_tag}" \ |
| 172 | + --jq '.body') && [ -n "$notes" ]; then |
| 173 | + echo "Using auto-generated release notes" |
| 174 | + echo "$notes" > /tmp/changelog.md |
| 175 | + else |
| 176 | + echo "generate-notes API call failed or empty; falling back to git log" |
| 177 | + git log --oneline "${base_tag}..HEAD" > /tmp/changelog.md |
| 178 | + fi |
172 | 179 | else |
| 180 | + echo "No base tag found; using last 20 commits" |
173 | 181 | git log --oneline -20 > /tmp/changelog.md |
174 | 182 | fi |
175 | 183 |
|
|
0 commit comments