forked from fleipold/jproc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·77 lines (51 loc) · 1.92 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
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
if [[ -z "${1-}" ]]; then
echo "Missing parameter version">&2
exit 1
fi
version="$1"
JAR_NAME=jproc
PROJECT_NAME=jproc
dirty=$(git status --porcelain)
if [ "${dirty}" ]; then
echo "Cannot release because these files are dirty:"
echo "${dirty}"
exit 1
fi >&2
find . -name target -prune -exec rm -r {} \;
mvn test package javadoc:jar source:jar
mv target/$JAR_NAME-VERSION.jar target/$JAR_NAME-${version}.jar
mv target/$JAR_NAME-VERSION-sources.jar target/$JAR_NAME-${version}-sources.jar
mv target/$JAR_NAME-VERSION-javadoc.jar target/$JAR_NAME-${version}-javadoc.jar
sed s/VERSION/${version}/g <pom.xml > target/pom.xml
STAGING_URL=https://oss.sonatype.org/service/local/staging/deploy/maven2/
#rm -rf target
#mkdir target
echo "Releasing version ${version}"
mvn gpg:sign-and-deploy-file \
-Durl=$STAGING_URL \
-DrepositoryId=sonatype-nexus-staging \
-DpomFile=target/pom.xml \
-Dsources=target/$JAR_NAME-${version}-sources.jar \
-Djavadoc=target/$JAR_NAME-${version}-javadoc.jar \
-Dfile=target/$JAR_NAME-${version}.jar \
-e
tag="v${version}"
previous_release_tag=$( git describe --abbrev=0 || git rev-list HEAD | tail -n 1 )
git log ${previous_release_tag}..HEAD > /tmp/release-notes-candidate.txt
vim /tmp/release-notes-candidate.txt
release_notes=$(cat /tmp/release-notes-candidate.txt)
sed -i "" -E "s%(.*)<version>[^<]*</version>%\1<version>${version}</version>%g" README.md
git branch --force "release-${tag}"
git checkout "release-${tag}"
sed -i "" -E 's/(.*"org.programmiersportgruppe.sbt" %% "[^"]*" % ")[^"]*(.*)/\1'"${version}"'\2/' README.md
git commit -a -m "Releasing ${version}." || echo "Nothing to commit"
git tag -f "${tag}" --annotate --message "${release_notes}"
git push origin "${tag}" "release-${tag}:master"
git checkout master
git pull --rebase
git branch -d "release-${tag}"