Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split sbt release in stages? #220

Open
todor-kolev opened this issue Mar 5, 2018 · 1 comment
Open

Split sbt release in stages? #220

todor-kolev opened this issue Mar 5, 2018 · 1 comment

Comments

@todor-kolev
Copy link

todor-kolev commented Mar 5, 2018

I have an SBT project and a CD pipeline and what I want is to execute the following sequence of events:

  1. Checkout my project from the git repo
  2. Tag the commit
  3. Run the tests
  4. Package my app
  5. Now at this point I don't want to release anything yet as I will promote the binaries to another environment to run the end-to-end tests. Only if they complete successfully would I want to push the git tags and upload my artefact to the remote artefactory repository. So I want something similar to this in my build.sbt but I'm not quite sure how exactly to extend the existing release process:
lazy val prepareRelease = settingKey[Seq[ReleaseStep]]("Prepare the release")
prepareRelease := Seq[ReleaseStep](
      checkSnapshotDependencies, 
      inquireVersions,
      runClean,
      runTest,
      setReleaseVersion,
      commitReleaseVersion,
      tagRelease
  )

lazy val doRelease = settingKey[Seq[ReleaseStep]]("Perform the release")
doRelease := Seq[ReleaseStep](
      publishArtifacts,
      setNextVersion,
      commitNextVersion,
      pushChanges
  )

What I want to achieve really is to be able to first run sbt prepereRelease after which I will promote to my TEST environment and later, if everything goes ok, to run sbt doRelease.

Is there a way to achieve this atm?

@todor-kolev
Copy link
Author

todor-kolev commented Mar 13, 2018

What I ended up doing it is creating two custom commands and appending the releaseProcess setting to the state object which I then pass onto the release plugin. Not sure if there's a better way of doing the same thing:

// Defines the release process
releaseIgnoreUntrackedFiles := true

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

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
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant