Skip to content

Instantly share code, notes, and snippets.

@talios
Last active December 20, 2015 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talios/6190640 to your computer and use it in GitHub Desktop.
Save talios/6190640 to your computer and use it in GitHub Desktop.
Stage an Apache Maven artifact release into a separate repository based on the git commits SHA1, so to allow for interim, unmerged dependencies to resolve for other users.
#!/bin/sh
if ! git diff-index --quiet HEAD --; then
echo "Git is dirty, clean up your mess!"
exit 1
fi
VERSION=`xml sel -N x="http://maven.apache.org/POM/4.0.0" -t -v "/x:project/x:version" pom.xml`
ARTIFACTID=`xml sel -N x="http://maven.apache.org/POM/4.0.0" -t -v "/x:project/x:artifactId" pom.xml`
SHA1=`git rev-parse HEAD`
mvn -q -o versions:set -DnewVersion=$SHA1
echo "Building $ARTIFACTID $VERSION for staging with version $SHA1"
mvn -q -o clean install
echo "Deploying $ARTIFACTID $VERSION to staging with version $SHA1"
mvn -q -o install deploy:deploy -DaltDeploymentRepository=staging::default::http://..../repositories/staging/
git reset --hard
git clean -fd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment