From f0a6a281c38fd6cd6c51aeb4a1227c458f39b415 Mon Sep 17 00:00:00 2001 From: Peter Grayson Date: Sun, 10 Dec 2023 23:22:12 -0500 Subject: [PATCH] ci: add latest-changelog.awk --- .github/workflows/ci.yml | 4 ++++ contrib/release/latest-changelog.awk | 30 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100755 contrib/release/latest-changelog.awk diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52750e13..2d7fdb20 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -286,10 +286,14 @@ jobs: - name: Make source archive run: | ./contrib/release/make-archive.sh artifacts + - name: Latest Changes + run: | + ./contrib/release/latest-changelog.awk CHANGELOG.md >latest-changes.md - name: Draft Release uses: softprops/action-gh-release@v1 with: draft: true + body_path: latest-changes.md fail_on_unmatched_files: true files: | artifacts/stgit-*.tar.gz diff --git a/contrib/release/latest-changelog.awk b/contrib/release/latest-changelog.awk new file mode 100755 index 00000000..2a4301c0 --- /dev/null +++ b/contrib/release/latest-changelog.awk @@ -0,0 +1,30 @@ +#!/usr/bin/env -S awk -f + +# Extract the latest release notes from CHANGELOG.md. +# +# The h3 sections from the first h2 section are printed. + +BEGIN { + foundFirstH2 = 0 + foundFirstH3 = 0 + foundSecondH2 = 0 +} + +{ + if (!foundFirstH2) { + if ($0 ~ /^## /) { + foundFirstH2 = 1 + } + } else if (!foundFirstH3) { + if ($0 ~ /^### /) { + foundFirstH3 = 1 + print $0 + } + } else if (!foundSecondH2) { + if ($0 ~ /^## /) { + foundSecondH2 = 1 + } else { + print $0 + } + } +}