From 706509666ea07eed2f9977b4d34b4db522724c78 Mon Sep 17 00:00:00 2001 From: Michelle Blanchette Date: Sat, 4 May 2024 15:13:59 +0000 Subject: [PATCH] bash script for doing release checklist, resolves #223 --- prepare_release.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 prepare_release.sh diff --git a/prepare_release.sh b/prepare_release.sh new file mode 100755 index 00000000..6b52d3d7 --- /dev/null +++ b/prepare_release.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# Get the last version tag +readonly LAST_VERSION_TAG=$(git describe --abbrev=0 --tags) + +# Prompt user for new version +read -p "Enter the new version number (most recent tag: ${LAST_VERSION_TAG#"v"}): " NEW_VERSION +readonly NEW_VERSION + +# Validate input: Check if the input is a valid version number +if ! [[ $NEW_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Error: Invalid version number. Please try again with proper semver formatting." + exit 1 +fi + +####################################### + +# Replace [unreleased] placeholders throughout src files +grep -FRl --exclude='*/node_modules/*' --exclude='*/vendor/*' '[unreleased]' src assets | xargs sed -i -e "s/\[unreleased\]/$NEW_VERSION/g" + +# Replace header value in readme.txt for WordPress.org plugin page +sed -i "s/Stable tag: .*/Stable tag: $NEW_VERSION/" readme.txt + +# Replace release heading in changelog.md with specified new version and current date +readonly TODAY=$(date +'%Y-%m-%d') +sed -i "s/### \[unreleased\]/### $NEW_VERSION - $TODAY/" changelog.md + +####################################### + +# Review and confirm changes +echo +echo "Release checklist changes applied." +echo "Please review the changes and confirm this release:" +echo +echo "git status" +echo "git diff" +echo +echo "git commit -m \"bump v$NEW_VERSION\"" +echo "git tag -a \"v$NEW_VERSION\" -m \"see changelog.md\"" +echo "git push --tags" +echo