From a1a258708e050f47a5d899cc2420b2f12817a0b8 Mon Sep 17 00:00:00 2001 From: welpo Date: Sun, 31 Dec 2023 12:54:15 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20chore(release-script):=20suggest=20?= =?UTF-8?q?version=20if=20none=20provided?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- release | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/release b/release index 40ae116..af3bbf2 100644 --- a/release +++ b/release @@ -2,14 +2,25 @@ # Bash script to prepare a release using git-cliff. # Inspired by https://github.com/orhun/git-cliff/blob/main/release.sh -if [ "$#" -ne 1 ]; then - echo "A version tag is required." - echo "Example: bash $0 1.5.0" - exit 1 +# Check if a version tag is provided. +if [ "$#" -eq 1 ]; then + VERSION_TAG=$1 +else + # After git-cliff version 1.4.0 it should be possible to run `git cliff --bumped-version`. + suggested_version=$(git cliff --unreleased --bump --context | jq -r .[0].version) + echo -n "No version tag provided. git-cliff suggests $suggested_version. Proceed? [Y/n] " + read user_input + + # Check if input is empty or a variation of "yes". + if [[ -z "$user_input" || "$user_input" =~ ^[Yy](es)?$ ]]; then + echo "Proceeding with version $suggested_version." + VERSION_TAG=$suggested_version + else + echo "Release preparation cancelled." + exit 1 + fi fi -VERSION_TAG=$1 - # Update CHANGELOG. git cliff --tag "$VERSION_TAG" -o CHANGELOG.md