Split sbt release in stages?

I have an SBT project and a CD pipeline, and I want to complete the following sequence of steps:

  • Checkout my project from git repo
  • Mark commit
  • Run tests
  • Application package

Now at this point I don’t want to release anything, as I will push the binaries to another environment to run end-to-end tests. Only if they are completed successfully, I want to click the git tags and upload my artifact to the remote artifact repository. What I really want to achieve is to start first sbt prepereRelease, after which I will promote my testing environment, and later, if everything goes well, start it sbt doRelease. So I want something similar in my build.sbt:

releaseProcess := Seq[ReleaseStep](
      checkSnapshotDependencies,
      inquireVersions,
      runClean,
      runTest,
      setReleaseVersion,
      commitReleaseVersion,
      tagRelease,
      setNextVersion,
      commitNextVersion
)

commands += Command.command("prepareRelease")((state:State) => {
  val newState = Command.process("release",state)
  println("Release called from prepareRelease...")
  newState
})

releaseProcess := Seq[ReleaseStep](
      publishArtifacts,
      setNextVersion,
      commitNextVersion,
      pushChanges
)

commands += Command.command("doRelease")((state:State) => {
  val newState = Command.process("release",state)
  println("Release called from doRelease...")
  newState
})

, , release sbt-release releaseProcess - , , . , , releaseProcess , , .

+4
2

prepareRelease doRelease . , , . , ReleaseStep , , .

, sbt-release. , releaseProcess release .

0

, , - releaseProcess state, release:

// Defines the release process
releaseIgnoreUntrackedFiles := true

commands += Command.command("prepareRelease")((state: State) => {
  println("Preparing release...")
  val extracted = Project extract state
  val customState = extracted.append(Seq(releaseProcess := Seq[ReleaseStep](
    checkSnapshotDependencies,
    inquireVersions,
    runClean,
    setReleaseVersion,
    commitReleaseVersion,
    tagRelease,
    runTest
  )), state)
  val newState = Command.process("release with-defaults", customState)
  Command.process("dist", newState)
})

commands += Command.command("completeRelease")((state: State) => {
  println("Completing release...")
  val extracted = Project extract state
  val customState = extracted.append(Seq(releaseProcess := Seq[ReleaseStep](
    inquireVersions,
    setNextVersion,
    commitNextVersion,
    pushChanges
  )), state)
  val newState = Command.process("release with-defaults", customState)
  newState
})

, - :

  • sbt prepareRelease

  • TEST

  • , sbt completeRelease

  • , , curl zip

0

Source: https://habr.com/ru/post/1694440/


All Articles