-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
bump-version.sh
executable file
·47 lines (35 loc) · 1.45 KB
/
bump-version.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# https://github.com/pksunkara/cargo-workspaces#version
_BUMP=${BUMP:?bump is required}
_GENERATE_CHANGELOG=${GENERATE_CHANGELOG:=1}
# desktop, mobile, core -> default is core
_TARGETS=${TARGETS:=core}
# If no targets are specified, exit. This _shouldn't_ happen since the default is core
if [ -z "$_TARGETS" ]; then
echo "No targets specified. Exiting..."
exit 1
fi
if [[ $_TARGETS == *"core"* ]]; then
# Bump the Cargo workspaces version, this is interactive
cargo workspaces version $BUMP --no-git-commit
# Get the current version in the root package.json
_VERSION=$(jq -r '.version' package.json)
# Update the version according to the bump (major, minor, patch)
_NEW_VERSION=$(yarn -s semver $_VERSION -i $_BUMP)
# if _NEW_VERSION is empty, exit
if [ -z "$_NEW_VERSION" ]; then
echo "Something went wrong while bumping the version. Exiting..."
exit 1
fi
# Update the version in the root package.json and in: (apps/*/package.json, packages/*/package.json, interface/package.json)
PATHS=("package.json" "apps/*/package.json" "packages/*/package.json")
for path in ${PATHS[@]}; do
jq ".version = \"$_NEW_VERSION\"" $path > tmp.$$.json && mv tmp.$$.json $path
done
# Fix the formatting of the JSON files from the previous step
yarn prettify
fi
# https://docs.gitmoji-changelog.dev/#/?id=%f0%9f%93%9a-how-it-works
if [ $_GENERATE_CHANGELOG == 1 ]; then
npx gitmoji-changelog --output ./.github/CHANGELOG.md
fi