-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrelease.sh
executable file
·93 lines (75 loc) · 2.67 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash -ue
#
# Before you run it, please follow the commnds given below.
#
# $ git checkout develop
# [ATTENTION] The develop branch's version in pom.xml must be 'x.x.x-SNAPSHOT'.
# $ git flow init
# $ git flow release start VERSION
# [ATTENTION] Update version in pom.xml to 'x.x.x'.
# $ git flow release finish VERSION
# $ git push
# $ git tag -d VERSION
# [ATTENTION] Don't push the tag created by git-flow.
# Because this script will create tag.
#
# Make sure that we're on `master` branch
if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then
echo "You must be on the master branch to release."
exit 1
fi
# create dist directory
mkdir -p "${HOME}/public_html/maven"
#
# [NOTE]
#
# Jubatus Java client is auto-generated.
# And the generated codes are not commited to the repository.
#
# If we commit the generated codes to the repository, this script don't need to create temporary branch like 'release/x.x.x'.
#
VERSION_LINE=10
VERSION=`head -${VERSION_LINE} pom.xml | tail -1 | sed -n 's#^\s\+<version>\(.\+\)</version>#\1#p'`
# create work branch
git checkout -b "release/${VERSION}"
sed -i "${VERSION_LINE} s#<version>\(.\+\)</version>#<version>\1-SNAPSHOT</version>#" pom.xml
# generate code
./generate.sh
# temporary commit for release-plugin
sed -i '/^src\/main\/java\/us\/jubat\/\*/D' .gitignore
git add src/main/*
git commit -a -m "generate code"
# release
BASEPORT="22200" # avoid confriction with Jenkins
mvn release:prepare -DreleaseVersion="${VERSION}" -DscmCommentPrefix="" -DtagNameFormat="@{project.version}" -Darguments="-Djubatus.baseport=${BASEPORT}"
mvn release:perform
# remove generated code
# TODO(@rimms): more elegant
echo "src/main/java/us/jubat/*" >> .gitignore
git rm -r src/main/java/us/jubat/anomaly
git rm -r src/main/java/us/jubat/bandit
git rm -r src/main/java/us/jubat/burst
git rm -r src/main/java/us/jubat/classifier
git rm -r src/main/java/us/jubat/clustering
git rm -r src/main/java/us/jubat/graph
git rm -r src/main/java/us/jubat/nearest_neighbor
git rm -r src/main/java/us/jubat/recommender
git rm -r src/main/java/us/jubat/regression
git rm -r src/main/java/us/jubat/stat
git rm -r src/main/java/us/jubat/weight
git commit -a -m "remove generated code"
# merge to develop
git checkout develop
git merge --squash "release/${VERSION}"
git commit -a -m "prepared development iteration of next version"
# create tag
git checkout master
git tag -d "${VERSION}"
git tag -a "${VERSION}" -m "release ${VERSION}"
# delete work branch
git branch -D "release/${VERSION}"
echo "Follow-up actions:"
echo "- Check the released files and commits on develop branch"
echo "- When done, run:"
echo " git push"
echo " git push --tags"