Skip to content

Commit 647762f

Browse files
committed
change release script
1 parent 40094b7 commit 647762f

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

Diff for: release.sh

+18-22
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
#!/bin/sh
22

3+
# Check if we're running in patch mode
4+
if [ "$1" = "patch" ]; then
5+
# Get the current version from package.json
6+
current_version=$(jq -r '.version' package.json)
7+
# Increment the patch version
8+
version=$(echo $current_version | awk -F. -v OFS=. '{$NF += 1; print}')
9+
echo "Creating patch release: $current_version -> $version"
10+
elif [ "$1" = "minor" ]; then
11+
# Get the current version from package.json
12+
current_version=$(jq -r '.version' package.json)
13+
# Increment the minor version
14+
version=$(echo $current_version | awk -F. -v OFS=. '{$2 += 1; $NF = 0; print}')
15+
echo "Creating minor release: $current_version -> $version"
316
# ensure that we have at least one argument conforming to semver
4-
if [ $# -ne 1 ] || ! echo $1 | grep -qE "^[0-9]+\.[0-9]+\.[0-9]+$"; then
5-
echo "Usage: $0 <version>"
17+
elif [ $# -ne 1 ] || ! echo $1 | grep -qE "^[0-9]+\.[0-9]+\.[0-9]+$"; then
18+
echo "Usage: $0 <version> or $0 patch or $0 minor"
619
exit 1
20+
else
21+
version=$1
722
fi
823

924
# ensure we are on the master branch otherwise exit
@@ -27,25 +42,6 @@ if [ -n "$(git ls-files --others --exclude-standard)" ]; then
2742
exit 1
2843
fi
2944

30-
# if the first argument is not a valid semver, exit
31-
if ! echo $1 | grep -qE "^[0-9]+\.[0-9]+\.[0-9]+$"; then
32-
echo "Invalid semver, exiting"
33-
exit 1
34-
fi
35-
36-
# get the current version from package.json
37-
current_version=$(jq -r '.version' package.json)
38-
39-
# take the version from teh virst argument unless it's "patch" or "minor"
40-
# don't use the semver tool because it's not installed on the CI
41-
if [ "$2" = "patch" ]; then
42-
version=$(echo $current_version | awk -F. -v OFS=. '{$NF += 1; print}')
43-
elif [ "$2" = "minor" ]; then
44-
version=$(echo $current_version | awk -F. -v OFS=. '{$2 += 1; $NF = 0; print}')
45-
else
46-
version=$1
47-
fi
48-
4945
# update the version in package.json
5046
sed -i '' -e "s/\"version\": \".*\"/\"version\": \"$version\"/" package.json
5147

@@ -57,7 +53,7 @@ cargo build
5753
git add Cargo.toml package.json Cargo.lock
5854
git commit -m ":rocket: - Release v$version"
5955

60-
# tag current commit with the first argument
56+
# tag current commit with the version
6157
git tag -a v$version -m ":rocket: - Release v$version"
6258

6359
# push the changes

0 commit comments

Comments
 (0)