From 0ceffc87f4b69772de754e237d417d360a49d80d Mon Sep 17 00:00:00 2001 From: kite Date: Mon, 22 Jun 2026 15:52:06 +0800 Subject: [PATCH] feat(release): auto-generate structured release notes from conventional commits Satisfy the OpenSSF Best Practices "release_notes" criterion by parsing commits between tags and categorizing them into Features, Bug Fixes, Refactoring, and Documentation sections. --- .github/release.yml | 21 +++++++++++ .github/workflows/release.yml | 66 ++++++++++++++++++++++++++++++++++- 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 .github/release.yml diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..82b5f6f --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,21 @@ +changelog: + categories: + - title: "🚀 Features" + labels: + - enhancement + - feat + - title: "🐛 Bug Fixes" + labels: + - bug + - fix + - title: "📖 Documentation" + labels: + - documentation + - docs + - title: "🔧 Maintenance" + labels: + - chore + - refactor + - title: "Other Changes" + labels: + - "*" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b16ad10..829ca1f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -61,6 +61,70 @@ jobs: container: image: ubuntu:24.04 steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Trust workspace + run: git config --global safe.directory '*' + + - name: Generate release notes from commits + id: notes + run: | + CURRENT_TAG="${GITHUB_REF_NAME}" + PREV_TAG=$(git describe --tags --abbrev=0 "${CURRENT_TAG}^" 2>/dev/null || echo "") + + if [ -z "$PREV_TAG" ]; then + RANGE="$CURRENT_TAG" + else + RANGE="${PREV_TAG}..${CURRENT_TAG}" + fi + + FEATS="" + FIXES="" + REFACTORS="" + DOCS="" + OTHERS="" + + while IFS= read -r line; do + msg="${line#* }" + case "$msg" in + feat*) FEATS="${FEATS}- ${msg} + ";; + fix*) FIXES="${FIXES}- ${msg} + ";; + refactor*) REFACTORS="${REFACTORS}- ${msg} + ";; + docs*) DOCS="${DOCS}- ${msg} + ";; + *) OTHERS="${OTHERS}- ${msg} + ";; + esac + done < <(git log --oneline --no-merges "$RANGE") + + { + echo "body<> "$GITHUB_OUTPUT" + - uses: actions/download-artifact@v4 with: pattern: binary-* @@ -72,10 +136,10 @@ jobs: - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: + body: ${{ steps.notes.outputs.body }} files: | opencodereview-* sha256sum.txt - generate_release_notes: true npm-publish: needs: release