diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 26165c5aa8..a8b91a7170 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -555,13 +555,39 @@ jobs: - name: Exclude flatpak-multisrc artifacts from release run: rm -rf ./artifacts/flatpak-multisrc-* + # Generate the notes ourselves with an explicit previous tag. GitHub's automatic + # previous-release selection considers any published release, including the rolling + # "snapshot" prerelease that main-check.yml recreates on every push to main — when + # snapshot's commit is an ancestor of this tag it wins and the notes come out empty + # (see v2.8.0-open.3). Internal releases are drafts and invisible to the API's + # auto-selection, so pick the newest published v* release ourselves. + - name: Generate release notes + env: + GH_TOKEN: ${{ github.token }} + REPO: ${{ github.repository }} + TAG: ${{ inputs.tag_name }} + TARGET: ${{ inputs.commit_sha || github.sha }} + run: | + # Fail the step if the listing itself fails — an empty PREV must only ever + # mean "no published v* release exists yet", never a swallowed API error, + # because empty PREV re-enables the automatic selection this step avoids. + PUBLISHED_TAGS=$(gh api "repos/${REPO}/releases" --paginate \ + --jq '.[] | select(.draft == false) | .tag_name') + PREV=$(printf '%s\n' "$PUBLISHED_TAGS" | grep -E '^v[0-9]' | grep -Fxv "$TAG" | head -1 || true) + echo "Previous release tag: ${PREV:-}" + gh api "repos/${REPO}/releases/generate-notes" \ + -f tag_name="$TAG" \ + -f target_commitish="$TARGET" \ + ${PREV:+-f previous_tag_name="$PREV"} \ + --jq '.body' > release-notes.md + - name: Create or Update GitHub Release uses: softprops/action-gh-release@v3 with: tag_name: ${{ inputs.tag_name }} target_commitish: ${{ inputs.commit_sha || github.sha }} name: ${{ inputs.tag_name }} (${{ needs.prepare-build-info.outputs.APP_VERSION_CODE }}) - generate_release_notes: true + body_path: release-notes.md files: ./artifacts/**/* draft: true prerelease: true