How can I publish a snapshot artifact using sbt-release?

6.6k Views Asked by At

I managed to set up sbt-release in my CI pipeline to publish a release artifact (e.g. v0.0.1). From that point in time, I can add local changes and the build versions change to snapshot along with my commits (v0.0.1-1-SHA1-SNAPSHOT). At this stage, how can I publish a snapshot artifact without releasing? I mean, I may not want to release v.0.0.2 at this stage, I only want to publish a snapshot. Also, I want to do that in such a way the version format is preserved and I do not need to manually input the version.

1

There are 1 best solutions below

2
On

Eventually I responded to my requirements by using separate "sbt release" command for publishing a release artifact and "sbt publish" to publish a snapshot artifact. I also needed to set the publish location in the build.sbt file as follows.

publishTo <<= version { v: String =>
 val nexus: String = "https://xxxxxxxx/repository/"
 if (v.trim.endsWith("SNAPSHOT"))
   Some("Snapshots" at nexus + "snapshots")
 else
   Some("Releases" at nexus + "releases")
}

From the "sbt-release" section of the linked posted in my comment

Below is a sample release process for an application, to switch it to a library you would uncomment the publishArtifacts and comment the next line which is used to publish the package from the Universal namespace.

releaseProcess := Seq( checkSnapshotDependencies, inquireVersions, setReleaseVersion, runTest, tagRelease, // publishArtifacts, ReleaseStep(releaseStepTask(publish in Universal)), pushChanges )