From f70d6b0cf031bd37e5c3d8a949b9bc28f851e55b Mon Sep 17 00:00:00 2001 From: Nick Groenen Date: Fri, 24 Sep 2021 11:58:27 +0200 Subject: [PATCH] Simplify releases with a script --- docs/Release-checklist.md | 11 ++--------- make-new-release.sh | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 9 deletions(-) create mode 100755 make-new-release.sh diff --git a/docs/Release-checklist.md b/docs/Release-checklist.md index cfd8a45..1f3efe7 100644 --- a/docs/Release-checklist.md +++ b/docs/Release-checklist.md @@ -1,14 +1,7 @@ # Release process -- [ ] Update version number in `Cargo.toml` -- [ ] Run `cargo check` -- [ ] Commit changes to `Cargo.*` with the message format `Release vN.N.N` -- [ ] Make git tag `vN.N.N` -- [ ] Run `gitchangelog`, review and make any manual adjustments as needed -- [ ] Regenerate README: `docs/generate.sh` -- [ ] Stage `CHANGES.md`, `README.md` and amend previous commit -- [ ] Force update git tag `vN.N.N` -- [ ] Push changes & tag +- [ ] Run `./make-new-release.sh` +- [ ] Push the created release commit/tag to GitHub - [ ] Wait for builds to turn green () - [ ] Run `cargo publish` - [ ] Publish drafted release () diff --git a/make-new-release.sh b/make-new-release.sh new file mode 100755 index 0000000..36c419e --- /dev/null +++ b/make-new-release.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -euo pipefail + +get_next_version_number() { + DATEPART=$(date +%y.%-m) + ITERATION=0 + + while true; do + VERSION_STRING="${DATEPART}.${ITERATION}" + if git rev-list "v$VERSION_STRING" > /dev/null 2>&1; then + ((ITERATION++)) + else + echo "$VERSION_STRING" + return + fi + done +} + +VERSION=$(get_next_version_number) + +sed -i -E "s/^version = \".+\"$/version = \"${VERSION}\"/" Cargo.toml +cargo check +git commit "Cargo.*" --message "Release v${VERSION}" +git tag "v${VERSION}" + +gitchangelog +${EDITOR:-vim} CHANGES.md +docs/generate.sh +git add CHANGES.md README.md +git commit --amend --no-edit +git tag "v${VERSION}" --force + +printf "\n\nSuccessfully created release %s\n" "v${VERSION}" +printf "\nYou'll probably want to continue with:\n" +printf "\tgit push origin main\n" +printf "\tgit push origin %s\n" "v${VERSION}"