-
Notifications
You must be signed in to change notification settings - Fork 8
/
release.sh
executable file
·56 lines (43 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
48
49
50
51
52
53
54
55
#!/bin/bash
set -eu
readonly VERSION=$(date +%Y.%-m.%-d)
pushd $(dirname $0) &>/dev/null
if [ $# -eq 0 ]; then
echo "Usage: $0 module1 [module2 ...]"
exit 2
fi
declare MODULES=()
for module in "$@"; do
relmodule=$(realpath --relative-base=. "$module")
relmodule=${relmodule%/pom.xml}
if [[ $relmodule = */* ]] || [ ! -d "$relmodule" ] || [ ! -f "$relmodule/pom.xml" ]; then
echo "ERROR: $module is not a module of the project"
exit 1
fi
MODULES+=("$relmodule")
done
unset relmodule
if [[ -n $(git status --porcelain) ]]; then
echo "ERROR: Working tree is dirty"
exit 1
fi
git checkout $(git rev-parse --verify HEAD)
for module in "${MODULES[@]}"; do
mvn versions:set -DgenerateBackupPoms=false -DnewVersion="$VERSION" -pl "$module"
git add "$module/pom.xml"
done
git commit -m "Prepare release of ${MODULES[*]} $VERSION"
if [[ -n $(git status --porcelain) ]]; then
echo "ERROR: Working tree is dirty after version updates"
exit 1
fi
declare TAGS=()
for module in "${MODULES[@]}"; do
mvn clean verify -pl "$module"
git tag -a -m "Releasing $module $VERSION" "$module-$VERSION"
TAGS+=("tag" "$module-$VERSION")
done
mvn clean deploy -Prelease -pl $(IFS=, ; echo "${MODULES[*]}")
git push origin "${TAGS[@]}"
git checkout -
popd &>/dev/null