From 77402c4f142f1a306588c77b12c23c5ef40b9e8b Mon Sep 17 00:00:00 2001 From: Sander Date: Tue, 25 Jun 2024 19:34:11 +0000 Subject: [PATCH] Add release script --- scripts/release | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 scripts/release diff --git a/scripts/release b/scripts/release new file mode 100755 index 0000000..f6bb12c --- /dev/null +++ b/scripts/release @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +set -e + +if ! command -v jq &> /dev/null; then + echo "Error: 'jq' is required but not installed. Please install 'jq' to proceed" + exit 1 +fi + +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +cd "$(dirname "$0")/.." + +PROJECT=$(jq -r .name custom_components/kamstrup_403/manifest.json) +CURRENT_VERSION=$(jq -r .version custom_components/kamstrup_403/manifest.json) +NEW_VERSION=$1 + +echo "Updating $PROJECT version from $CURRENT_VERSION to $NEW_VERSION" + +# Update project files that contain the version number (not perfect, but there is manual verification). +sed -i "s/$CURRENT_VERSION/$NEW_VERSION/g" .github/ISSUE_TEMPLATE/issue.yaml custom_components/kamstrup_403/const.py custom_components/kamstrup_403/manifest.json + +echo "Are the updated project files correct? Confirm with 'yes' or 'no':" +read -r CONFIRMATION + +if [[ "$CONFIRMATION" == "yes" ]]; then + echo "Committing changes..." + git add .github/ISSUE_TEMPLATE/issue.yaml custom_components/kamstrup_403/const.py custom_components/kamstrup_403/manifest.json + git commit -m "Release version \`$NEW_VERSION\`" + git tag "$NEW_VERSION" + echo "Pushing changes..." + git push origin + git push origin --tags + echo "Release commit and tag $NEW_VERSION created and pushed successfully" +else + echo "Aborted, going to revert changes..." + git checkout -- .github/ISSUE_TEMPLATE/issue.yaml custom_components/kamstrup_403/const.py custom_components/kamstrup_403/manifest.json + echo "Changes reverted" +fi