Publishing a library is not an atomic operation in my project because the process involves number of side-effects that need to be cleaned up in the case of a failure. Errors can occur due to timeouts, attempting to publish an already existing version, staging repo already existing, problems with signing key, etc. Currently the manual steps I perform to rollback a botched release consist of
- Login to Sonatype Nexus and drop staging repository
- Remove version increase commit:
git reset --hard sha
- Remove tag:
git tag -d name
Is there a way to make the publishing process atomic such that all the changes are reverted automatically on failure?
My project's release process is similar to How to release a Scala library to Maven Central using sbt? namely
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
publishArtifacts,
setNextVersion,
commitNextVersion,
releaseStepCommand("sonatypeReleaseAll"),
pushChanges
)
where plugins.sbt
has
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.11")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.5")