483ec9171c
GitHub renders release-note Markdown with GFM hard breaks, so every `\n` becomes `<br>`. The CHANGELOG is hard-wrapped at ~75 chars for readable diffs, which renders as awkward visible line breaks on the release page (see https://github.com/colbymchenry/codegraph/releases/tag/v0.7.10). Add `scripts/extract-release-notes.mjs` to extract a version block and join indented continuation lines into a single line per bullet. Nested list items, headings, and link references are preserved. `scripts/release.sh` now uses this helper instead of the inline awk extractor — repo-level CHANGELOG.md viewing is unaffected because CommonMark there treats newlines as spaces. Also fix the 0.7.10 entry: "Two underlying fixes" -> "Three", "Rust file-/level" broken hyphen, and move the closes/credit line above the nested list so it doesn't strand as a top-level paragraph. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
69 lines
2.0 KiB
Bash
Executable File
69 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Tag the current commit with the version in package.json and publish a
|
|
# matching GitHub Release whose body is the corresponding CHANGELOG.md entry.
|
|
#
|
|
# Run AFTER you have:
|
|
# - bumped package.json
|
|
# - added a `## [X.Y.Z] - YYYY-MM-DD` block at the top of CHANGELOG.md
|
|
# - committed, pushed to origin, and run `npm publish`
|
|
#
|
|
# Idempotent: safe to re-run after a partial failure. Skips steps that are
|
|
# already done (tag created, tag pushed, release published).
|
|
#
|
|
# Usage: ./scripts/release.sh
|
|
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
VERSION=$(node -p "require('./package.json').version")
|
|
TAG="v${VERSION}"
|
|
|
|
REPO=$(git remote get-url origin | sed -E 's|.*github\.com[:/]||; s|\.git$||')
|
|
if [ -z "${REPO}" ]; then
|
|
echo "error: could not derive owner/repo from origin remote URL" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if ! grep -q "^## \[${VERSION}\]" CHANGELOG.md; then
|
|
echo "error: no '## [${VERSION}]' entry found in CHANGELOG.md" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Extract notes with paragraph unwrapping — GitHub Releases render with
|
|
# GFM hard-breaks, so the CHANGELOG's hard-wrapped lines would show as
|
|
# visible `<br>` breaks otherwise. The helper joins continuation lines
|
|
# into a single line per bullet.
|
|
NOTES=$(node scripts/extract-release-notes.mjs "${VERSION}")
|
|
|
|
if [ -z "${NOTES}" ]; then
|
|
echo "error: failed to extract changelog notes for ${VERSION}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if git rev-parse "${TAG}" >/dev/null 2>&1; then
|
|
echo "✓ tag ${TAG} already exists locally"
|
|
else
|
|
echo "→ tagging ${TAG}"
|
|
git tag "${TAG}"
|
|
fi
|
|
|
|
if git ls-remote --exit-code --tags origin "${TAG}" >/dev/null 2>&1; then
|
|
echo "✓ tag ${TAG} already on origin"
|
|
else
|
|
echo "→ pushing ${TAG} to origin"
|
|
git push origin "${TAG}"
|
|
fi
|
|
|
|
if gh release view "${TAG}" --repo "${REPO}" >/dev/null 2>&1; then
|
|
echo "✓ release ${TAG} already published"
|
|
else
|
|
echo "→ creating GitHub Release ${TAG} on ${REPO}"
|
|
gh release create "${TAG}" \
|
|
--repo "${REPO}" \
|
|
--title "${TAG}" \
|
|
--notes "${NOTES}"
|
|
fi
|
|
|
|
echo "done: https://github.com/${REPO}/releases/tag/${TAG}"
|