Skip to content

Commit

Permalink
Improve release script.
Browse files Browse the repository at this point in the history
Add additional sanity checks.
Add artifact upload to sonatype.
  • Loading branch information
dfish3r committed Apr 8, 2022
1 parent 5b28d50 commit f7dbd7a
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions release
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,36 @@ function user_continue() {
fi
}

if [ "$#" -ne 3 ]; then
echo "USAGE: `basename $0` <branch> <release-version> <next-version>"
if [ "$#" -ne 5 ]; then
echo "USAGE: `basename $0` <branch> <release-version> <next-version> <sonatype-user> <sonatype-passwd>"
exit
fi

PROJECT="cryptacular"
BRANCH="${1}"
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}"
Expand All @@ -36,7 +57,7 @@ user_continue
git commit pom.xml -m "Update version for ${RELEASE_VERSION} release."

# tag the release version
git tag -a v${RELEASE_VERSION} -m "Tagging ${RELEASE_VERSION} release."
git tag -s v${RELEASE_VERSION} -m "Tagging ${RELEASE_VERSION} release."
echo "Tagged release ${RELEASE_VERSION}"

# update pom to the next version
Expand Down Expand Up @@ -90,5 +111,13 @@ 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

curl -i -u ${SONATYPE_USER}:${SONATYPE_PASSWORD} \
-F "file=@target/${PROJECT}-"${RELEASE_VERSION}"-bundle.jar" \
"https://oss.sonatype.org/service/local/staging/bundle_upload"

echo "Finished release ${RELEASE_VERSION} for ${PROJECT}"

0 comments on commit f7dbd7a

Please sign in to comment.