-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbump
executable file
·45 lines (33 loc) · 1.3 KB
/
bump
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
#!/bin/bash
# This script creates and pushes a release
# It takes one parameter: the version number of the release
# The current version number is in ih-core/bin/VERSION
# This command will fail if the repo is dirty, or if the release already exists.
# It will cause a commit with the new version updates
THIS_DIR=$(dirname "$(realpath "$0")")
ROOT_DIR=$(dirname "$THIS_DIR")
CURRENT_VERSION=$(cat "$ROOT_DIR/VERSION")
VERSION=${1:?"You must provide a version for the release (current version is $CURRENT_VERSION)"}
if [[ $(git status --short) != '' ]]; then
echo 'Working directory is dirty, commit and push everything making a release commit.'
exit 1
fi
echo "Bumping version to $VERSION and pushing."
# We want to abort if any of the following commands fail
set -e
git pull
# Update the formula and the version file with the new version
if [ "$(uname)" = "Linux" ]; then
sed -i "s/VERSION=.*/VERSION=\"$VERSION\""/ "$ROOT_DIR/formula/ih-core.rb"
else
sed -i '' "s/VERSION=.*/VERSION=\"$VERSION\""/ "$ROOT_DIR/formula/ih-core.rb"
fi
echo "$VERSION" >"$ROOT_DIR/VERSION"
# If updating the files caused a change then commit that change.
if [[ $(git status --short) != '' ]]; then
git add "$ROOT_DIR/formula/ih-core.rb"
git add "$ROOT_DIR/VERSION"
git commit -m "Bump version to $VERSION"
fi
git push
set +e