From e56d9039ad3dfbe7ca6c1df780e9f7e9e843a104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sat, 9 Dec 2023 00:13:54 +0100 Subject: [PATCH 1/2] Improve release changelogs This improves the release by only adding the relevant parts of the CHANGELOG.md file. Besides that it also adds information on how to reproduce the build with srtool. Closes: https://github.com/polkadot-fellows/runtimes/issues/66 --- .github/changelog-processor.py | 23 ++++++++++++++++++++--- .github/workflows/release.yml | 19 ++++++++++++++----- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/.github/changelog-processor.py b/.github/changelog-processor.py index b005c620d8..8546f50b1f 100755 --- a/.github/changelog-processor.py +++ b/.github/changelog-processor.py @@ -26,21 +26,38 @@ help="Should a release be made? Prints `1` or `0`.", action="store_true" ) +group.add_argument( + "--print-changelog-until-previous-version", + dest="changelog_until_previous", + help="Print the entire changelog until the previous version.", + action="store_true" +) args = parser.parse_args() with open(args.changelog, "r") as changelog: lines = changelog.readlines() + changelog_until_previous_version = "" + found_last_version = False + # Find the latest version for line in lines: if not line.startswith("## ["): + changelog_until_previous_version += line continue + elif not found_last_version: + changelog_until_previous_version += line + found_last_version = True + version = line.strip().removeprefix("## [").split("]")[0] + else: + break - version = line.strip().removeprefix("## [").split("]")[0] - break - if args.print_latest_version: + if args.changelog_until_previous: + print(changelog_until_previous_version, end = "") + sys.exit(0) + elif args.print_latest_version: print(version, end = "") sys.exit(0) elif args.should_release: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d19cbe550c..f273317516 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -105,12 +105,21 @@ jobs: CONTEXT=$(find . -name '*_srtool_output.json') SRTOOL() { <$(<<<$CONTEXT head -n1) jq -r .$1; } WASM() { <${JSON} jq -r ".runtimes.compressed.subwasm.$1"; } + + # Copy the relevant parts of the changelog + .github/changelog-processor.py CHANGELOG.md --print-changelog-until-previous-version > DRAFT + tee -a DRAFT <<-EOF - EOF - tee -a DRAFT Date: Tue, 12 Dec 2023 20:44:21 +0100 Subject: [PATCH 2/2] Apply suggestions from code review --- .github/changelog-processor.py | 16 ++++++++-------- .github/workflows/release.yml | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/changelog-processor.py b/.github/changelog-processor.py index 8546f50b1f..10750aade7 100755 --- a/.github/changelog-processor.py +++ b/.github/changelog-processor.py @@ -27,9 +27,9 @@ action="store_true" ) group.add_argument( - "--print-changelog-until-previous-version", - dest="changelog_until_previous", - help="Print the entire changelog until the previous version.", + "--print-changelog-from-last-release", + dest="changelog_last_release", + help="Print the changelog from the last release.", action="store_true" ) @@ -38,24 +38,24 @@ with open(args.changelog, "r") as changelog: lines = changelog.readlines() - changelog_until_previous_version = "" + changelog_last_release = "" found_last_version = False # Find the latest version for line in lines: if not line.startswith("## ["): - changelog_until_previous_version += line + changelog_last_release += line continue elif not found_last_version: - changelog_until_previous_version += line + changelog_last_release += line found_last_version = True version = line.strip().removeprefix("## [").split("]")[0] else: break - if args.changelog_until_previous: - print(changelog_until_previous_version, end = "") + if args.changelog_last_release: + print(changelog_last_release, end = "") sys.exit(0) elif args.print_latest_version: print(version, end = "") diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f273317516..aa5dc01b45 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -107,7 +107,7 @@ jobs: WASM() { <${JSON} jq -r ".runtimes.compressed.subwasm.$1"; } # Copy the relevant parts of the changelog - .github/changelog-processor.py CHANGELOG.md --print-changelog-until-previous-version > DRAFT + .github/changelog-processor.py CHANGELOG.md --print-changelog-from-last-release > DRAFT tee -a DRAFT <<-EOF # Runtime info