Skip to content

Commit b514f15

Browse files
committed
fix(ci): read tag annotation via GitHub REST API so Release body shows the real notes
1 parent 99e138f commit b514f15

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

.github/workflows/build-firmware.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,22 @@ jobs:
7373
7474
- name: Read tag annotation as release body
7575
id: notes
76+
env:
77+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7678
run: |
77-
BODY=$(git tag -l --format='%(contents)' "${GITHUB_REF_NAME}")
79+
# Read annotation via GitHub REST API instead of `git tag -l --format`.
80+
# actions/checkout@v4 with fetch-depth:0 sometimes leaves annotated tags
81+
# as lightweight refs locally, in which case %(contents) returns the
82+
# commit subject (e.g. "sync(rx): rx-v2.8.6") instead of the annotated
83+
# body. The REST API path always returns the true annotation message.
84+
OBJ_SHA=$(gh api "repos/${GITHUB_REPOSITORY}/git/refs/tags/${GITHUB_REF_NAME}" --jq '.object.sha')
85+
OBJ_TYPE=$(gh api "repos/${GITHUB_REPOSITORY}/git/refs/tags/${GITHUB_REF_NAME}" --jq '.object.type')
86+
if [ "$OBJ_TYPE" = "tag" ]; then
87+
BODY=$(gh api "repos/${GITHUB_REPOSITORY}/git/tags/${OBJ_SHA}" --jq '.message')
88+
else
89+
# Lightweight tag — fall back to the commit subject so we don't fail.
90+
BODY=$(gh api "repos/${GITHUB_REPOSITORY}/git/commits/${OBJ_SHA}" --jq '.message')
91+
fi
7892
{
7993
echo "body<<__END_OF_BODY__"
8094
echo "$BODY"

0 commit comments

Comments
 (0)