@@ -137,5 +137,26 @@ jobs:
137137 sha256sum --check SHA256SUMS
138138 flags=()
139139 if [[ "$TAG" == *-* ]]; then flags+=(--prerelease); fi
140+ gh api --method POST "repos/$GH_REPO/releases/generate-notes" \
141+ -f tag_name="$TAG" --jq .body > "$RUNNER_TEMP/release-changes.md"
142+ python3 - <<'PY'
143+ import os, re
144+ from pathlib import Path
145+ from urllib.parse import quote
146+ temp = Path(os.environ['RUNNER_TEMP'])
147+ changes = (temp / 'release-changes.md').read_text().strip()
148+ changes = re.sub(r"^## What's Changed\s*", '', changes)
149+ changes = re.sub(r'^(#{1,5}) ', r'\1# ', changes, flags=re.MULTILINE)
150+ lines = ['## Changes', '', changes or 'Initial release.', '', '## Downloads', '']
151+ assets = sorted([*Path('.').glob('*.jar'), *Path('.').glob('*.tar.gz')])
152+ assets += [Path('SHA256SUMS'), Path('build.json')]
153+ base = f"https://github.com/{os.environ['GH_REPO']}/releases/download/{quote(os.environ['TAG'], safe='')}/"
154+ for asset in assets:
155+ if not asset.is_file():
156+ raise SystemExit(f'Missing release asset: {asset}')
157+ description = {'SHA256SUMS': ' — SHA-256 checksums.', 'build.json': ' — Build metadata.'}.get(asset.name, '')
158+ lines.append(f'- [`{asset.name}`]({base}{quote(asset.name)}){description}')
159+ (temp / 'release-notes.md').write_text('\n'.join(lines) + '\n')
160+ PY
140161 gh release create "$TAG" ./*.jar SHA256SUMS build.json \
141- --verify-tag --draft --title "$TAG" --generate- notes "${flags[@]}"
162+ --verify-tag --draft --title "$TAG" --notes-file "$RUNNER_TEMP/release- notes.md" "${flags[@]}"
0 commit comments