File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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"
You can’t perform that action at this time.
0 commit comments