-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathrelease
More file actions
executable file
·157 lines (132 loc) · 5 KB
/
release
File metadata and controls
executable file
·157 lines (132 loc) · 5 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
set -e
function user_continue() {
read -p "Do you want to continue? [y/n]" -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
}
if [ "$#" -ne 5 ]; then
echo "USAGE: `basename $0` <branch> <release-version> <next-version> <sonatype-user> <sonatype-passwd>"
exit
fi
PROJECT="cryptacular"
BRANCH="${1}"
if [ ! $(git rev-parse --abbrev-ref HEAD) = "${BRANCH}" ]; then
echo "The current branch must be ${BRANCH}"
exit
fi
RELEASE_VERSION="${2}"
if [[ ! "${RELEASE_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "<release-version> must be of the form 'MAJOR.MINOR.REVISION'"
exit
fi
NEXT_VERSION="${3}"
if [[ ! "${NEXT_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT$ ]]; then
echo "<next-version> must be of the form 'MAJOR.MINOR.REVISION-SNAPSHOT'"
exit
fi
SONATYPE_USER="${4}"
SONATYPE_PASSWORD="${5}"
if [ -z $(git config --get user.signingkey) ]; then
echo "Git signing must be enabled. Add user.signingkey to ~/.gitconfig"
exit
fi
if [ $(git tag -l | grep "$RELEASE_VERSION") ]; then
echo "Tag ${RELEASE_VERSION} already exists"
exit
fi
echo "================================================================="
echo "BEGIN RELEASE"
echo "PROJECT: ${PROJECT}"
echo "BRANCH TO TAG: ${BRANCH}"
echo "RELEASE VERSION: ${RELEASE_VERSION}"
echo "NEXT VERSION: ${NEXT_VERSION}"
echo "================================================================="
user_continue
# update pom to release version
if ! mvn clean; then
echo "maven clean command failed, check your environment"
exit
fi
mvn versions:set -DnewVersion=${RELEASE_VERSION} -DgenerateBackupPoms=false
echo "Updated pom to release version ${RELEASE_VERSION}"
POM_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
if [ "${POM_VERSION}" != "${RELEASE_VERSION}" ]; then
echo "POM version ${POM_VERSION} does not equal ${RELEASE_VERSION}"
exit
fi
user_continue
# commit pom changes
git commit pom.xml -m "Update version for ${RELEASE_VERSION} release."
# tag the release version
git tag -s v${RELEASE_VERSION} -m "Tagging ${RELEASE_VERSION} release."
echo "Tagged release ${RELEASE_VERSION}"
# update pom to the next version
mvn versions:set -DnewVersion=${NEXT_VERSION} -DgenerateBackupPoms=false
echo "Updated pom to next version ${NEXT_VERSION}"
# commit pom changes
git commit pom.xml -m "Bump version to ${NEXT_VERSION}."
# push commits
git push origin ${BRANCH}
# push release tag
git push origin v${RELEASE_VERSION}
# checkout the release tag
git checkout v${RELEASE_VERSION}
echo "Switched to the tag version ${RELEASE_VERSION}"
# build the release distribution
echo "Prime gpg-agent caches"
echo "prime" | gpg --clearsign
mvn deploy -Dmaven.test.skip=true -Daether.checksums.algorithms=MD5,SHA-1,SHA-256,SHA-512 -Dsign=true -DaltDeploymentRepository=local::file:target/deploy-maven
COMPILE_VERSION=$(javap -classpath target/${PROJECT}-${RELEASE_VERSION}.jar -verbose org.cryptacular.CryptoException |grep "major version:" |tr -d '[:space:]' |cut -d':' -f2)
echo "Class compile version is ${COMPILE_VERSION}"
if [ "${COMPILE_VERSION}" != "52" ]; then
echo "Release must be compiled for Java 8"
exit
fi
jar cMf target/${PROJECT}-${RELEASE_VERSION}-maven.zip -C target/deploy-maven .
gpg --armor --detach-sign target/${PROJECT}-${RELEASE_VERSION}-dist.tar.gz
gpg --armor --detach-sign target/${PROJECT}-${RELEASE_VERSION}-dist.zip
# update the javadocs
echo "Updating javadocs"
user_continue
git checkout gh-pages
git pull origin gh-pages
# remove root directory javadocs
git rm -r javadocs/org javadocs/*.html javadocs/*.css javadocs/*.js javadocs/package-list
# add new javadocs to root directory
cp target/${PROJECT}-${RELEASE_VERSION}-javadoc.jar javadocs
pushd javadocs
jar xf ${PROJECT}-${RELEASE_VERSION}-javadoc.jar
rm -rf META-INF ${PROJECT}-${RELEASE_VERSION}-javadoc.jar
popd
# add new javadocs to release version directory
mkdir javadocs/${RELEASE_VERSION}
cp target/${PROJECT}-${RELEASE_VERSION}-javadoc.jar javadocs/${RELEASE_VERSION}
pushd javadocs/${RELEASE_VERSION}
jar xf ${PROJECT}-${RELEASE_VERSION}-javadoc.jar
rm -rf META-INF ${PROJECT}-${RELEASE_VERSION}-javadoc.jar
popd
git add javadocs
git commit -a -m "Updated javadocs for ${RELEASE_VERSION} release."
echo "Committed new javadocs"
# add new binaries
echo "Adding release binaries"
user_continue
mkdir downloads/${RELEASE_VERSION}
cp target/*-dist* downloads/${RELEASE_VERSION}
git add downloads/${RELEASE_VERSION}
git commit -a -m "Added binaries for ${RELEASE_VERSION} release."
echo "Committed new release binaries"
# push changes to the server
git push origin gh-pages
# upload bundle jar to sonatype
echo "Uploading bundle jar to sonatype"
user_continue
SONATYPE_TOKEN=$(echo -n "${SONATYPE_USER}:${SONATYPE_PASSWORD}" | base64)
curl --verbose --request POST \
--header "Authorization: Bearer ${SONATYPE_TOKEN}" \
-F "file=@target/${PROJECT}-${RELEASE_VERSION}-maven.zip" \
"https://central.sonatype.com/api/v1/publisher/upload?name=${PROJECT}-${RELEASE_VERSION}&publishingType=USER_MANAGED"
echo "Finished ${PROJECT} release ${RELEASE_VERSION}"