Skip to content

Commit

Permalink
Add release script
Browse files Browse the repository at this point in the history
  • Loading branch information
golles committed Jun 25, 2024
1 parent daa8c02 commit 77402c4
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions scripts/release
Original file line number Diff line number Diff line change
@@ -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 <new_version>"
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

0 comments on commit 77402c4

Please sign in to comment.