Skip to content

Commit

Permalink
Improve release changelogs (#117)
Browse files Browse the repository at this point in the history
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: #66

<!-- Remember that you can run `/merge` to enable auto-merge in the PR
-->

---------

Co-authored-by: Oliver Tale-Yazdi <[email protected]>
  • Loading branch information
bkchr and ggwpez authored Jan 4, 2024
1 parent 923f6c1 commit ce1ed26
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
23 changes: 20 additions & 3 deletions .github/changelog-processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,38 @@
help="Should a release be made? Prints `1` or `0`.",
action="store_true"
)
group.add_argument(
"--print-changelog-from-last-release",
dest="changelog_last_release",
help="Print the changelog from the last release.",
action="store_true"
)

args = parser.parse_args()

with open(args.changelog, "r") as changelog:
lines = changelog.readlines()

changelog_last_release = ""
found_last_version = False

# Find the latest version
for line in lines:
if not line.startswith("## ["):
changelog_last_release += line
continue
elif not found_last_version:
changelog_last_release += 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_last_release:
print(changelog_last_release, end = "")
sys.exit(0)
elif args.print_latest_version:
print(version, end = "")
sys.exit(0)
elif args.should_release:
Expand Down
19 changes: 14 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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-from-last-release > DRAFT
tee -a DRAFT <<-EOF
EOF
tee -a DRAFT <CHANGELOG.md
tee -a DRAFT <<-EOF
## Runtime info
# Runtime info
*These runtimes were built with **$(SRTOOL rustc)** using **[$(SRTOOL gen)](https://github.com/paritytech/srtool)***
To replicate the build, use the following command:
```sh
srtool build \
--root --profile production \
--package CRATE_NAME --runtime-dir PATH_TO_CRATE \
--build-opts="--features=on-chain-release-build"
```
EOF
for JSON in $(<<<$CONTEXT sort -sr)
Expand All @@ -127,7 +136,7 @@ jobs:
tee -a DRAFT <<-EOF
### $HEADING
## $HEADING
~~~
🏋️ Runtime Size: $(numfmt --to iec-i --format "%.2f" $(WASM size)) ($(WASM size) bytes)
🗜 Compressed: $(WASM 'compression | if .compressed then "Yes: \(1 - .size_compressed / .size_decompressed | . * 10000 | round / 100)%" else "No" end')
Expand Down

0 comments on commit ce1ed26

Please sign in to comment.