@@ -125,57 +125,54 @@ jobs:
125125 TAG : ${{ env.use_release_tag }}
126126 DRAFT : ${{ env.create_draft }}
127127 BODY : ${{ env.sha_summary }}
128- # Replaces a SHA-pinned `softprops/action-gh-release@d4e8205` call
129- # (Dec 2022) that ran with `generate_release_notes: true` and
130- # `append_body: true`. The branches below mirror the three code
131- # paths in that pinned source (src/github.ts `release()`):
128+ # Publishes the collected binaries to a GitHub release using the
129+ # `gh` CLI. Three cases, in order:
132130 #
133- # 1. input_draft =true AND a release already exists for the tag
134- # → softprops returns it as-is and only re-uploads assets;
135- # it does NOT update the body. (Drafts can't be fetched by
136- # tag, so softprops scans allReleases for that case.)
137- # Mirrored as the first `if` branch .
131+ # 1. DRAFT =true AND a release already exists for $TAG
132+ # → leave the release body untouched and only re-upload assets
133+ # (with --clobber, so existing assets of the same name are
134+ # replaced). This avoids double-appending the SHA summary
135+ # on a re-run that targets the same draft tag .
138136 #
139- # 2. input_draft=false AND release exists → softprops updates
140- # via PATCH /releases. With append_body=true, body becomes
141- # `existingBody + "\n" + workflowBody`. `generate_release_notes`
142- # is silently ignored by PATCH /releases (verified: the
143- # production v3.5 body has no auto-gen markers despite 2.5
144- # years of softprops updates). draft is forced to false.
145- # name / target_commitish / prerelease are preserved.
146- # Mirrored as the second `elif` branch.
137+ # 2. DRAFT=false AND a release exists for $TAG (the rolling
138+ # release case, e.g. v3.5)
139+ # → append the new SHA summary to the existing release body
140+ # (single "\n" separator), publish if it was a draft
141+ # (--draft=false), then re-upload assets. `// ""` keeps a
142+ # null body field from being rendered as the literal "null".
143+ # Title, target commit and prerelease flag are left as-is.
147144 #
148- # 3. Release does not exist → softprops creates via POST
149- # /releases. With body + generate_release_notes=true, the
150- # GitHub REST contract pre-pends body to the auto-generated
151- # notes. `gh release create` rejects --generate-notes with
152- # --notes-file together, so we fetch generated notes via
153- # POST /releases/generate-notes and concatenate in the
154- # correct order: BODY + "\n\n" + auto-notes.
155- # Mirrored as the final `else` branch.
145+ # 3. No release exists for $TAG
146+ # → create a new release. Auto-generated notes are fetched
147+ # from POST /repos/.../releases/generate-notes and the SHA
148+ # summary is pre-pended (BODY + "\n\n" + auto-notes), since
149+ # `gh release create` does not allow --generate-notes and
150+ # --notes-file together. Created as a draft when DRAFT=true.
156151 #
157- # Asset upload uses `--clobber`, matching softprops's default
158- # `overwrite_files: true` (delete-then-upload by name) .
152+ # The release URL is exposed as the step output `url` for the
153+ # following "Add release url to summary" step .
159154 run : |
160155 set -e
161156 NOTES_FILE="$RUNNER_TEMP/release-notes.md"
162157
163- if [ "$DRAFT" = "true" ] && gh release view "$TAG" --json tagName >/dev/null 2>&1; then
164- # Path 1: draft re-run on the same tag — body untouched, assets refreshed.
158+ RELEASE_EXISTS=false
159+ if gh release view "$TAG" --json tagName >/dev/null 2>&1; then
160+ RELEASE_EXISTS=true
161+ fi
162+
163+ if [ "$DRAFT" = "true" ] && [ "$RELEASE_EXISTS" = "true" ]; then
164+ # Case 1.
165165 gh release upload "$TAG" artifact-shas/* artifact-binaries/* --clobber
166166
167- elif gh release view "$TAG" --json tagName >/dev/null 2>&1; then
168- # Path 2: update existing release. Append SHA summary to existing
169- # body using a single "\n" separator (matches softprops byte-for-byte).
170- # `// ""` defends against a null body field. `--draft=false` mirrors
171- # softprops's unconditional `draft: false` on this path.
167+ elif [ "$RELEASE_EXISTS" = "true" ]; then
168+ # Case 2.
172169 gh release view "$TAG" --json body --jq '.body // ""' > "$NOTES_FILE"
173170 printf '%s\n' "$BODY" >> "$NOTES_FILE"
174171 gh release edit "$TAG" --notes-file "$NOTES_FILE" --draft=false
175172 gh release upload "$TAG" artifact-shas/* artifact-binaries/* --clobber
176173
177174 else
178- # Path 3: create. Body pre-pended to auto-generated notes .
175+ # Case 3 .
179176 AUTO_NOTES="$RUNNER_TEMP/auto-notes.md"
180177 gh api -X POST "/repos/$GITHUB_REPOSITORY/releases/generate-notes" \
181178 -f tag_name="$TAG" --jq '.body' > "$AUTO_NOTES"
0 commit comments