Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/changelog.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import createPreset, { DEFAULT_COMMIT_TYPES } from 'conventional-changelog-conventionalcommits'

// The conventionalcommits preset hides docs, style, chore, refactor, test,
// build and ci from the changelog. Release notes here list every commit, so
// clear the `hidden` effect and let each type render under its own section.
export default createPreset({
types: DEFAULT_COMMIT_TYPES.map(type =>
type.effect === 'hidden'
? { type: type.type, section: type.section }
: type,
),
})
29 changes: 23 additions & 6 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,36 @@ jobs:
with:
bun-version: 1.3.14

# conventional-changelog v8 ships without presets, so both it and the
# preset used by .github/changelog.config.mjs come from devDependencies.
- name: Install dependencies
run: bun install --frozen-lockfile --ignore-scripts

- name: Create the GitHub release
env:
TAG: ${{ github.ref_name }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail

# Build the changelog for just this release (latest tag .. previous tag),
# grouped into Features / Bug Fixes by conventional-commit type. Strip
# the auto-generated version header — the release title already shows the
# version. Fall back to GitHub's generated notes if it comes back empty.
NOTES="$(bunx conventional-changelog-cli -p conventionalcommits -r 1 \
| sed -E '/^#+ \[?v?[0-9]+\.[0-9]+\.[0-9]+/d')"
PREV_TAG="$(git describe --tags --abbrev=0 "$TAG^" 2>/dev/null || true)"

# Build the changelog for just this release (previous tag .. this tag),
# grouped into sections by conventional-commit type. The range has to
# be explicit: on its own, -r 1 emits the unreleased section, which is
# empty when HEAD is the tag being released. --stdout is required as
# well, since the CLI writes to CHANGELOG.md by default.
ARGS=(-n .github/changelog.config.mjs --stdout -r 1 --to "$TAG")
if [ -n "$PREV_TAG" ]; then
ARGS+=(--from "$PREV_TAG")
fi

# Strip the `## <version>` headings — the release title already shows
# the version — and the blank lines they leave at the top. Fall back to
# GitHub's generated notes if the result comes back empty.
NOTES="$(bunx conventional-changelog "${ARGS[@]}" \
| sed -E '/^## /d' \
| awk 'NF { p = 1 } p')"

if [ -n "$(printf '%s' "$NOTES" | tr -d '[:space:]')" ]; then
printf '%s\n' "$NOTES" > "$RUNNER_TEMP/notes.md"
Expand Down
32 changes: 32 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"@antfu/eslint-config": "^7.7.3",
"@types/bencode": "^2.0.4",
"@types/bun": "latest",
"conventional-changelog": "^8.1.3",
"conventional-changelog-conventionalcommits": "^10.4.0",
"eslint": "10.6.0",
"eslint-plugin-markdown-links": "0.9.1"
}
Expand Down