-
Notifications
You must be signed in to change notification settings - Fork 5
/
get_release_commands.sh
executable file
·89 lines (64 loc) · 2.59 KB
/
get_release_commands.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
#!/bin/sh
if [[ "$1" = "-h" ]] || [[ "$1" = "--help" ]]; then
echo "Usage: './get_release_commands.sh VERSION_TO_RELEASE [NEW_DEV_VERSION]'"
echo "Prints out commands to run to release sgf4j-parser to Maven Central."
echo "VERSION_TO_RELEASE must be a number (integer or floating). NEW_DEV_VERSION is optional"
exit 0
fi
if ! [[ "$1" =~ ^[0-9]*\.?[0-9]\.?[0-9]*$ ]] || [[ "$1z" = "z" ]]; then
echo "Not a valid version number given, use -h to get usage options"
exit 1
fi
version=$1
version_after_dot=${version##*.}
version_str_length=${#version}-${#version_after_dot}
incr_last_digit=$((${version_after_dot}+1))
version_without_last_digit=${version: 0:${version_str_length}}
new_version="${version_without_last_digit}${incr_last_digit}-SNAPSHOT"
echo "#!/bin/sh"
echo "set -xe"
if [[ "$2z" = "z" ]]; then
echo "# No new development version given using ${new_version}"
else
new_version=$2
echo "# New development version will be ${new_version}"
fi
echo "# To release sgf4j-parser version ${version} run these commands:"
echo ""
echo "# 1) set release version"
echo "./mvnw versions:set -DnewVersion=${version}"
echo ""
echo "# 2) commit & tag"
echo "git add pom.xml; "
echo "git commit -m \"Prepare release sgf4j-parser-${version}\""
echo "git tag sgf4j-parser-${version}"
echo ""
echo "# 3) build release"
echo "./mvnw clean install"
echo ""
echo "# 4) generate javadoc archive"
echo "./mvnw javadoc:jar"
echo ""
echo "# 5) generate sources archive"
echo "./mvnw source:jar"
echo ""
echo "# 6) deploy and sign releases archive"
echo "./mvnw gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=pom.xml -Dfile=target/sgf4j-parser-$1.jar"
echo ""
echo "# 7) deploy and sign sources archive"
echo "./mvnw gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=pom.xml -Dfile=target/sgf4j-parser-$1-sources.jar -Dclassifier=sources"
echo ""
echo "# 8) deploy and sign javadoc archive"
echo "./mvnw gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=pom.xml -Dfile=target/sgf4j-parser-$1-javadoc.jar -Dclassifier=javadoc"
echo ""
echo "# 9) set new development version"
echo "./mvnw versions:set -DnewVersion=${new_version}"
echo "git add pom.xml; "
echo "git commit -m \"prepare for next development iteration\""
echo ""
echo "# 10) push to GitHub"
echo "git push"
echo "git push --tags"
echo ""
echo "# 11) clean local repo"
echo "git clean -f"