diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7a07e2d..b9415a6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -213,6 +213,12 @@ jobs: run: shell: bash steps: + # Checked out before the download, so the checkout's clean can't touch dist/. + # Only CHANGELOG.md is read, and nothing here pushes, so the token stays out. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: pattern: terminus-* @@ -236,6 +242,22 @@ jobs: exit 1 fi + # The release notes are this version's CHANGELOG section, minus the link + # block at the foot. A tag with no section gets no draft. + - name: Slice the CHANGELOG section for this version + run: | + set -euo pipefail + ver="${GITHUB_REF_NAME#v}" + awk -v ver="$ver" ' + $0 ~ "^## \\[" ver "\\]" { f = 1; next } + f && /^## \[/ { exit } + f && !/^\[[^]]+\]: *http/ { print } + ' CHANGELOG.md > RELEASE_NOTES.md + if [ ! -s RELEASE_NOTES.md ]; then + echo "::error::CHANGELOG.md has no section for ${ver}" + exit 1 + fi + # A draft, never a prerelease: releases/latest skips prereleases, and # that is where install.sh looks once the owner publishes. - name: Create the draft @@ -247,4 +269,4 @@ jobs: --draft --verify-tag \ --repo "$GITHUB_REPOSITORY" \ --title "$GITHUB_REF_NAME" \ - --notes "" + --notes-file RELEASE_NOTES.md