-
Notifications
You must be signed in to change notification settings - Fork 249
/
release.sh
executable file
·47 lines (37 loc) · 1.26 KB
/
release.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
#!/usr/bin/env bash
set -o errexit # Exit the script with error if any of the commands fail
if [ "$#" -lt 3 ] || [ "$#" -gt 4 ]; then
echo "Usage: $0 <current version> <release version> <next release version> <remote (defaults to origin)>" >&2
exit 1
fi
CURRENT=$1
RELEASE=$2
NEXT=$3
REMOTE=${4:-origin}
BRANCH=`git rev-parse --abbrev-ref HEAD`
echo "Current version: ${CURRENT}"
echo "Release: ${RELEASE}"
echo "Next version: ${NEXT}"
echo "Remote: ${REMOTE}"
echo "Branch: ${BRANCH}"
[[ "$(read -e -p 'Continue? [y/N]> '; echo $REPLY)" == [Yy]* ]]
# Update to release version
echo "Updating build.gradle.kts to release version ${RELEASE}"
sed -i '' "s/version = \"${CURRENT}\"/version = \"${RELEASE}\"/g" build.gradle.kts
git add build.gradle.kts
git commit -m "Version: bump ${RELEASE}"
git push ${REMOTE} ${BRANCH}
echo "Sleeping for 5 ..."
sleep 5
# Tag it
echo "Tagging release ${RELEASE}"
git tag -a r${RELEASE} -m "${RELEASE}"
git push ${REMOTE} r${RELEASE}
echo "Sleeping for 5 ..."
sleep 5
# Update to next snapshot version
echo "Updating build.gradle.kts to next snapshot version ${NEXT}"
sed -i '' "s/version = \"${RELEASE}\"/version = \"${NEXT}\"/g" build.gradle.kts
git add build.gradle.kts
git commit -m "Version: bump ${NEXT}"
git push ${REMOTE} ${BRANCH}