From 59636e307bbf6b28ec573938f6da7b87bb64ae62 Mon Sep 17 00:00:00 2001 From: Dirk Ehrhardt Date: Thu, 22 Aug 2024 14:54:07 +0200 Subject: [PATCH] chore: update release and changelog script --- package.json | 2 +- prepare_release.sh | 29 ++++++++++++++++++----------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index f077582..12a2183 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "private": true, "version": "0.1.0", "scripts": { - "changelog": "conventional-changelog -i CHANGELOG.md -s -r 0 --config ./changelog.config.js" + "changelog": "conventional-changelog -i CHANGELOG.md -s --config ./changelog.config.js" }, "repository": { "type": "git", diff --git a/prepare_release.sh b/prepare_release.sh index bd715ea..4d2a1a9 100755 --- a/prepare_release.sh +++ b/prepare_release.sh @@ -13,24 +13,26 @@ fi # Check if an argument is provided if [ -z "$VERSION" ]; then - echo "Error: No version number provided." - echo "Usage: $0 " - exit 1 + echo "Error: No version number provided." + echo "Usage: $0 " + exit 1 fi # Check if the argument matches the format int.int.int if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Valid version number: $VERSION" + echo "Valid version number: $VERSION" else - echo "Error: Invalid version number format." - echo "Usage: $0 " - exit 1 + echo "Error: Invalid version number format." + echo "Usage: $0 " + exit 1 fi # tag should start with a 'v' TAG="v${VERSION}" COMMUNICATOR_CONFIG_CLASS_PATH="./src/PayoneCommercePlatform/Sdk/CommunicatorConfiguration.php" COMPOSER_JSON_PATH="./composer.json" +PACKAGE_JSON_PATH="./package.json" +PACKAGE_LOCK_JSON_PATH="./package-lock.json" SED_COMMUNICATOR_CONFIG_CMD=$(printf 's/public const SDK_VERSION = .[0-9]*\.[0-9]*\.[0-9]*./public const SDK_VERSION = %s/' "'${VERSION}'") @@ -38,22 +40,27 @@ SED_COMMUNICATOR_CONFIG_CMD=$(printf 's/public const SDK_VERSION = .[0-9]*\.[0-9 sed -i '' "$SED_COMMUNICATOR_CONFIG_CMD" $COMMUNICATOR_CONFIG_CLASS_PATH # Update the version number in the composer.json file -jq --arg version "$VERSION" '.version = $version' composer.json > tmp.json && mv tmp.json composer.json +jq --arg version "$VERSION" '.version = $version' composer.json >tmp.json && mv tmp.json composer.json # Update the version number in the package.json file -jq --arg version "$VERSION" '.version = $version' package.json > tmp.json && mv tmp.json package.json +jq --arg version "$VERSION" '.version = $version' package.json >tmp.json && mv tmp.json package.json # Update the version number in the package-lock.json file for changelog generation jq --arg version "$VERSION" ' .version = $version | .packages[""].version = $version ' package-lock.json >tmp.json && mv tmp.json package-lock.json +rm -f tmp.json git add "$COMMUNICATOR_CONFIG_CLASS_PATH" "$COMPOSER_JSON_PATH" -git commit -m "Update version to $VERSION" +git add $PACKAGE_JSON_PATH +git add $PACKAGE_LOCK_JSON_PATH +npm install +npm run changelog +git add CHANGELOG.md git tag -a $TAG -m "Release version $VERSION" +git commit -m "Update version to $VERSION" echo "Version updated to $VERSION and tagged in Git." echo "" echo "If this was a mistake, you can run" echo " git reset --soft HEAD~1" echo " git tag -d ${TAG}" -