From a09d529027472ce4f77211dbe0c090795a558dab Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Mon, 9 Jun 2025 21:37:00 +0200 Subject: [PATCH] chore: add branch check to release script --- scripts/development/create-release.sh | 35 ++++++++++++++++++--------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/scripts/development/create-release.sh b/scripts/development/create-release.sh index d0ce7958..8c6e3149 100755 --- a/scripts/development/create-release.sh +++ b/scripts/development/create-release.sh @@ -4,6 +4,29 @@ if [ ! -f .version ] || [ ! -f frontend/package.json ] || [ ! -f CHANGELOG.md ]; exit 1 fi +# Check if conventional-changelog is installed, if not install it +if ! command -v conventional-changelog &>/dev/null; then + echo "conventional-changelog not found, installing..." + npm install -g conventional-changelog-cli + # Verify installation was successful + if ! command -v conventional-changelog &>/dev/null; then + echo "Error: Failed to install conventional-changelog-cli." + exit 1 + fi +fi + +# Check if GitHub CLI is installed +if ! command -v gh &>/dev/null; then + echo "Error: GitHub CLI (gh) is not installed. Please install it and authenticate using 'gh auth login'." + exit 1 +fi + +# Check if we're on the main branch +if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then + echo "Error: This script must be run on the main branch." + exit 1 +fi + # Read the current version from .version VERSION=$(cat .version) @@ -88,12 +111,6 @@ git add .version jq --arg new_version "$NEW_VERSION" '.version = $new_version' frontend/package.json >frontend/package_tmp.json && mv frontend/package_tmp.json frontend/package.json git add frontend/package.json -# Check if conventional-changelog is installed, if not install it -if ! command -v conventional-changelog &>/dev/null; then - echo "conventional-changelog not found, installing..." - npm install -g conventional-changelog-cli -fi - # Generate changelog echo "Generating changelog..." conventional-changelog -p conventionalcommits -i CHANGELOG.md -s @@ -109,12 +126,6 @@ git tag "v$NEW_VERSION" git push git push --tags -# Check if GitHub CLI is installed -if ! command -v gh &>/dev/null; then - echo "GitHub CLI (gh) is not installed. Please install it and authenticate using 'gh auth login'." - exit 1 -fi - # Extract the changelog content for the latest release echo "Extracting changelog content for version $NEW_VERSION..." CHANGELOG=$(awk '/^## / {if (NR > 1) exit} NR > 1 {print}' CHANGELOG.md | awk 'NR > 2 || NF {print}')