forked from alpas/alpas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release
executable file
·45 lines (32 loc) · 1.16 KB
/
release
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
#!/usr/bin/env bash
set -e
# current Git branch
branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
version=$1
# v1.0.0, v1.5.2, etc.
versionLabel=v$version
# establish branch and tag name variables
devBranch=develop
masterBranch=master
releaseBranch=release-$versionLabel
# create the release branch from the -develop branch
git checkout -b $releaseBranch $devBranch
# file in which to update version number
versionFile="build.gradle"
# find version number assignment ("= v1.5.5" for example)
# and replace it with newly specified version number
sed -i.backup -E "s/version = '[0-9.]+'/version = '$version'/" $versionFile $versionFile
# remove backup file created by sed command
rm $versionFile.backup
# commit version number increment
git commit -am "Bump version to $versionLabel"
# merge release branch with the new version number into master
git checkout $masterBranch
git merge --no-ff $releaseBranch --no-edit
# create tag for new version from -master
git tag $versionLabel
# merge release branch with the new version number back into develop
git checkout $devBranch
git merge --no-ff $releaseBranch --no-edit
# remove release branch
git branch -d $releaseBranch