Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Automate version bumping and tagging #1020

Merged
merged 6 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"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",
"setup:dev": "npm run clear && npm run prepare && npm run setup:client && npm run setup:api",
"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": "./scripts/tag_release.sh"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.18.1",
Expand Down
74 changes: 74 additions & 0 deletions scripts/tag_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/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..."
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 branch 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 origin refs/tags/v$TARGET_VERSION
echo "Done!"

Loading