Skip to content

Commit 62957d1

Browse files
Fix permission for "reading" changelogs (#95)
1 parent c98e05a commit 62957d1

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

.github/workflows/package-skill.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ jobs:
7272
if: needs.package.outputs.released == 'true' || github.event_name == 'workflow_dispatch'
7373
runs-on: ubuntu-latest
7474
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
7678
strategy:
7779
fail-fast: false
7880
matrix:
@@ -160,16 +162,22 @@ jobs:
160162
161163
# Prefer GitHub's auto-generated notes for the range (nicely formatted
162164
# 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
172179
else
180+
echo "No base tag found; using last 20 commits"
173181
git log --oneline -20 > /tmp/changelog.md
174182
fi
175183

0 commit comments

Comments
 (0)