From 08e7ee995a66697df42697346d6e25622f04fc55 Mon Sep 17 00:00:00 2001 From: Mario Sarcevic Date: Fri, 26 Jan 2024 14:51:25 +0100 Subject: [PATCH 1/5] chore: Add npm script (and bash) to automate (and syncronize) version bumping and tagging --- package.json | 5 +++- tag_release.sh | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100755 tag_release.sh diff --git a/package.json b/package.json index 2dfbff78c..e6c2e9a25 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,7 @@ { "name": "explorer", + "description": "Tangle Explorer", + "version": "3.3.2", "scripts": { "setup:client": "cd client && npm install && npm run postinstall", "setup:api": "cd api && npm install && npm run build-compile && npm run build-config", @@ -7,7 +9,8 @@ "clear": "rimraf api/node_modules api/dist client/node_modules client/build", "dev": "concurrently 'cd api && npm run start-dev' 'cd client && npm run start'", "prepare": "husky install", - "format": "concurrently 'cd api && npm run format' 'cd client && npm run format'" + "format": "concurrently 'cd api && npm run format' 'cd client && npm run format'", + "tag:release": "./tag_release.sh" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^6.18.1", diff --git a/tag_release.sh b/tag_release.sh new file mode 100755 index 000000000..155794ec7 --- /dev/null +++ b/tag_release.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# Read target version from command line +TARGET_VERSION=$1 +CURRENT_VERSION=$(sed -n 's/.*\version\": \"\([^"]*\).*$/\1/p' package.json) + +if [[ -z $TARGET_VERSION ]]; then + echo "Current version (root) is v$CURRENT_VERSION" + read -p "Please specify target version: " TARGET_VERSION + read -n 1 -p "Confirm version change 'v$CURRENT_VERSION' -> 'v$TARGET_VERSION' ? (Enter): " CONFIRM_VERSION + + if [[ $CONFIRM_VERSION != "" ]]; then + echo "Aborting..." + exit 1 + fi +else + echo "Target version: v$TARGET_VERSION" +fi + +echo "Bumping version in package.json..." +sed -i.bak "4s/version\": \"\(.*\)\"/version\": \"$TARGET_VERSION\"/g" package.json +rm package.json.bak + +echo "Bumping version in api/package.json..." +cd "./api" +sed -i.bak "4s/version\": \"\(.*\)\"/version\": \"$TARGET_VERSION\"/g" package.json +rm package.json.bak + +echo "Bumping version in client/package.json..." +cd "../client" +sed -i.bak "4s/version\": \"\(.*\)\"/version\": \"$TARGET_VERSION\"/g" package.json +rm package.json.bak +cd "../" + +read -n 1 -p "Confirm making a bump commit and tagging with 'v$TARGET_VERSION' ? (Enter): " CONFIRM_BUMP + +if [[ $CONFIRM_BUMP != "" ]]; then + echo "Aborting..." + exit 1 +fi + +cd "./api" +npm i +cd "../client" +npm i +cd "../" + +echo "Making a bump commit..." +git add . +git commit -S -m "chore: bump version to v$TARGET_VERSION" + +echo "Tagging commit with 'v$TARGET_VERSION'..." +git tag v$TARGET_VERSION + +read -n 1 -p "Do you want to push brench and tags ? (Enter): " CONFIRM_PUSH +if [[ $CONFIRM_PUSH != "" ]]; then + echo "Exiting without pushing..." + exit 1 +fi + +echo "Pushing branch and tags..." +# git push +# git push --tags +echo "Done!" + From d0921f5f6ae3150d80c269e7704c9292c1e6a36f Mon Sep 17 00:00:00 2001 From: Mario Sarcevic Date: Tue, 30 Jan 2024 16:45:03 +0100 Subject: [PATCH 2/5] fix: Fix PR comments --- tag_release.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tag_release.sh b/tag_release.sh index 155794ec7..b82e5051b 100755 --- a/tag_release.sh +++ b/tag_release.sh @@ -2,7 +2,7 @@ # Read target version from command line TARGET_VERSION=$1 -CURRENT_VERSION=$(sed -n 's/.*\version\": \"\([^"]*\).*$/\1/p' package.json) +CURRENT_VERSION=$(sed -n 's/.*"version": "\([^"]*\)".*/\1/p' package.json) if [[ -z $TARGET_VERSION ]]; then echo "Current version (root) is v$CURRENT_VERSION" @@ -46,13 +46,22 @@ npm i cd "../" echo "Making a bump commit..." -git add . +files_to_add=("package.json" "package-lock.json") +folders_to_add=("." "api" "client") +for folder in "${folders_to_add[@]}" +do + for file in "${files_to_add[@]}" + do + git add "$folder/$file" + done +done + git commit -S -m "chore: bump version to v$TARGET_VERSION" echo "Tagging commit with 'v$TARGET_VERSION'..." git tag v$TARGET_VERSION -read -n 1 -p "Do you want to push brench and tags ? (Enter): " CONFIRM_PUSH +read -n 1 -p "Do you want to push branch and tags ? (Enter): " CONFIRM_PUSH if [[ $CONFIRM_PUSH != "" ]]; then echo "Exiting without pushing..." exit 1 From 316c12af6a5801836062d692131a7e516521f2c8 Mon Sep 17 00:00:00 2001 From: Mario Sarcevic Date: Tue, 30 Jan 2024 16:48:26 +0100 Subject: [PATCH 3/5] feat: Move tag_release script to scripts folder --- package.json | 2 +- tag_release.sh => scripts/tag_release.sh | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename tag_release.sh => scripts/tag_release.sh (100%) diff --git a/package.json b/package.json index e6c2e9a25..737fdc362 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "dev": "concurrently 'cd api && npm run start-dev' 'cd client && npm run start'", "prepare": "husky install", "format": "concurrently 'cd api && npm run format' 'cd client && npm run format'", - "tag:release": "./tag_release.sh" + "tag:release": "./scripts/tag_release.sh" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^6.18.1", diff --git a/tag_release.sh b/scripts/tag_release.sh similarity index 100% rename from tag_release.sh rename to scripts/tag_release.sh From 4b4e5d73af3908c8d97f2f331bff09f4822173b9 Mon Sep 17 00:00:00 2001 From: Mario Sarcevic Date: Tue, 30 Jan 2024 16:49:13 +0100 Subject: [PATCH 4/5] feat: Uncomment push step in tag_release script --- scripts/tag_release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/tag_release.sh b/scripts/tag_release.sh index b82e5051b..d605b05a8 100755 --- a/scripts/tag_release.sh +++ b/scripts/tag_release.sh @@ -68,7 +68,7 @@ if [[ $CONFIRM_PUSH != "" ]]; then fi echo "Pushing branch and tags..." -# git push -# git push --tags +git push +git push --tags echo "Done!" From 081ad56903e03a6ae3690fb37cb83ffb8df1c049 Mon Sep 17 00:00:00 2001 From: Mario Sarcevic Date: Tue, 30 Jan 2024 17:37:55 +0100 Subject: [PATCH 5/5] feat: Push only newly added tag --- scripts/tag_release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/tag_release.sh b/scripts/tag_release.sh index d605b05a8..8fce4cb1d 100755 --- a/scripts/tag_release.sh +++ b/scripts/tag_release.sh @@ -69,6 +69,6 @@ fi echo "Pushing branch and tags..." git push -git push --tags +git push origin refs/tags/v$TARGET_VERSION echo "Done!"