| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
function user_continue() { |
| 4 |
read -p "Do you want to continue? [y/n]" -n 1 -r |
| 5 |
echo |
| 6 |
if [[ ! $REPLY =~ ^[Yy]$ ]]; then |
| 7 |
exit 1 |
| 8 |
fi |
| 9 |
} |
| 10 |
|
| 11 |
if [ "$#" -ne 5 ]; then |
| 12 |
echo "USAGE: `basename $0` <branch> <release-version> <next-version> <sonatype-user> <sonatype-passwd>" |
| 13 |
exit |
| 14 |
fi |
| 15 |
|
| 16 |
if [ ! -f "distribution/release" ]; then |
| 17 |
echo "Script must be executed in the root directory of this project" |
| 18 |
exit |
| 19 |
fi |
| 20 |
|
| 21 |
BRANCH="${1}" |
| 22 |
RELEASE_VERSION="${2}" |
| 23 |
if [[ ! "${RELEASE_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 24 |
echo "<release-version> must be of the form 'MAJOR.MINOR.REVISION'" |
| 25 |
exit |
| 26 |
fi |
| 27 |
NEXT_VERSION="${3}" |
| 28 |
if [[ ! "${NEXT_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT$ ]]; then |
| 29 |
echo "<next-version> must be of the form 'MAJOR.MINOR.REVISION-SNAPSHOT'" |
| 30 |
exit |
| 31 |
fi |
| 32 |
SONATYPE_USER="${4}" |
| 33 |
SONATYPE_PASSWORD="${5}" |
| 34 |
|
| 35 |
if [ -z $(git config --get user.signingkey) ]; then |
| 36 |
echo "Git signing must be enabled. Add user.signingkey to ~/.gitconfig" |
| 37 |
exit |
| 38 |
fi |
| 39 |
|
| 40 |
if [ $(git tag -l | grep "$RELEASE_VERSION") ]; then |
| 41 |
echo "Tag ${RELEASE_VERSION} already exists" |
| 42 |
exit |
| 43 |
fi |
| 44 |
|
| 45 |
echo "=================================================================" |
| 46 |
echo "BEGIN RELEASE" |
| 47 |
echo "BRANCH TO TAG: ${BRANCH}" |
| 48 |
echo "RELEASE VERSION: ${RELEASE_VERSION}" |
| 49 |
echo "NEXT VERSION: ${NEXT_VERSION}" |
| 50 |
echo "=================================================================" |
| 51 |
user_continue |
| 52 |
|
| 53 |
# update pom to release version |
| 54 |
./mvn_cmd clean |
| 55 |
./mvn_cmd versions-set ${RELEASE_VERSION} |
| 56 |
echo "Updated pom to release version ${RELEASE_VERSION}" |
| 57 |
user_continue |
| 58 |
|
| 59 |
# commit pom changes |
| 60 |
git commit -a -m "Update version for ${RELEASE_VERSION} release." |
| 61 |
|
| 62 |
# tag the release version |
| 63 |
git tag -s v${RELEASE_VERSION} -m "Tagging ${RELEASE_VERSION} release." |
| 64 |
echo "Tagged release ${RELEASE_VERSION}" |
| 65 |
|
| 66 |
# update pom to the next version |
| 67 |
./mvn_cmd versions-set ${NEXT_VERSION} |
| 68 |
echo "Updated pom to next version ${NEXT_VERSION}" |
| 69 |
|
| 70 |
# commit pom changes |
| 71 |
git commit -a -m "Bump version to ${NEXT_VERSION}." |
| 72 |
|
| 73 |
# push commits |
| 74 |
git push origin ${BRANCH} |
| 75 |
|
| 76 |
# push release tag |
| 77 |
git push origin v${RELEASE_VERSION} |
| 78 |
|
| 79 |
# checkout the release tag |
| 80 |
git checkout v${RELEASE_VERSION} |
| 81 |
echo "Switched to the tag version ${RELEASE_VERSION}" |
| 82 |
|
| 83 |
# build the release distribution |
| 84 |
./mvn_cmd install |
| 85 |
./mvn_cmd bundle-create |
| 86 |
gpg --armor --detach-sign distribution/target/ldaptive-${RELEASE_VERSION}-dist.tar.gz |
| 87 |
gpg --armor --detach-sign distribution/target/ldaptive-${RELEASE_VERSION}-dist.zip |
| 88 |
|
| 89 |
# update the javadocs |
| 90 |
echo "Updating javadocs" |
| 91 |
user_continue |
| 92 |
|
| 93 |
git checkout gh-pages |
| 94 |
git pull origin gh-pages |
| 95 |
# remove root directory javadocs |
| 96 |
git rm -r javadocs/org javadocs/*.html javadocs/*.css javadocs/*.js javadocs/package-list |
| 97 |
# add new javadocs to root directory |
| 98 |
cp distribution/target/ldaptive-distribution-${RELEASE_VERSION}-javadoc.jar javadocs |
| 99 |
pushd javadocs |
| 100 |
jar xf ldaptive-distribution-${RELEASE_VERSION}-javadoc.jar |
| 101 |
rm -rf META-INF ldaptive-distribution-${RELEASE_VERSION}-javadoc.jar |
| 102 |
popd |
| 103 |
# add new javadocs to release version directory |
| 104 |
mkdir javadocs/${RELEASE_VERSION} |
| 105 |
cp distribution/target/ldaptive-distribution-${RELEASE_VERSION}-javadoc.jar javadocs/${RELEASE_VERSION} |
| 106 |
pushd javadocs/${RELEASE_VERSION} |
| 107 |
jar xf ldaptive-distribution-${RELEASE_VERSION}-javadoc.jar |
| 108 |
rm -rf META-INF ldaptive-distribution-${RELEASE_VERSION}-javadoc.jar |
| 109 |
popd |
| 110 |
git add javadocs |
| 111 |
git commit -a -m "Updated javadocs for ${RELEASE_VERSION} release." |
| 112 |
echo "Committed new javadocs" |
| 113 |
|
| 114 |
# update the spring ext schema |
| 115 |
echo "Updating schema" |
| 116 |
user_continue |
| 117 |
|
| 118 |
cp beans/target/classes/org/ldaptive/beans/spring/spring-ext.xsd schema/spring-ext.xsd |
| 119 |
cp beans/target/classes/org/ldaptive/beans/spring/spring-ext.xsd schema/spring-ext-${RELEASE_VERSION}.xsd |
| 120 |
git add schema |
| 121 |
git commit -a -m "Updated schema for ${RELEASE_VERSION} release." |
| 122 |
echo "Committed new schema" |
| 123 |
|
| 124 |
# add new binaries |
| 125 |
echo "Adding release binaries" |
| 126 |
user_continue |
| 127 |
|
| 128 |
mkdir downloads/${RELEASE_VERSION} |
| 129 |
cp distribution/target/ldaptive-${RELEASE_VERSION}-dist* downloads/${RELEASE_VERSION} |
| 130 |
git add downloads/${RELEASE_VERSION} |
| 131 |
git commit -a -m "Added binaries for ${RELEASE_VERSION} release." |
| 132 |
echo "Committed new release binaries" |
| 133 |
|
| 134 |
# push changes to the server |
| 135 |
git push origin gh-pages |
| 136 |
|
| 137 |
# upload bundle jars to sonatype |
| 138 |
echo "Uploading bundle jars to sonatype" |
| 139 |
user_continue |
| 140 |
|
| 141 |
curl -i -u ${SONATYPE_USER}:${SONATYPE_PASSWORD} \ |
| 142 |
-F "file=@target/ldaptive-parent-"${RELEASE_VERSION}"-bundle.jar" \ |
| 143 |
"https://oss.sonatype.org/service/local/staging/bundle_upload" |
| 144 |
curl -i -u ${SONATYPE_USER}:${SONATYPE_PASSWORD} \ |
| 145 |
-F "file=@core/target/ldaptive-"${RELEASE_VERSION}"-bundle.jar" \ |
| 146 |
"https://oss.sonatype.org/service/local/staging/bundle_upload" |
| 147 |
curl -i -u ${SONATYPE_USER}:${SONATYPE_PASSWORD} \ |
| 148 |
-F "file=@json/target/ldaptive-json-"${RELEASE_VERSION}"-bundle.jar" \ |
| 149 |
"https://oss.sonatype.org/service/local/staging/bundle_upload" |
| 150 |
curl -i -u ${SONATYPE_USER}:${SONATYPE_PASSWORD} \ |
| 151 |
-F "file=@beans/target/ldaptive-beans-"${RELEASE_VERSION}"-bundle.jar" \ |
| 152 |
"https://oss.sonatype.org/service/local/staging/bundle_upload" |
| 153 |
curl -i -u ${SONATYPE_USER}:${SONATYPE_PASSWORD} \ |
| 154 |
-F "file=@templates/target/ldaptive-templates-"${RELEASE_VERSION}"-bundle.jar" \ |
| 155 |
"https://oss.sonatype.org/service/local/staging/bundle_upload" |
| 156 |
|
| 157 |
echo "Finished release ${RELEASE_VERSION} for ldaptive." |
| 158 |
|