GithubHelp home page GithubHelp logo

sbt-release's Introduction

sbt-release

This sbt plugin provides a customizable release process that you can add to your project.

sbt-release Scala version support

Notice: This README contains information for the latest release. Please refer to the documents for a specific version by looking up the respective tag.

Requirements

  • sbt 1.x
  • The version of the project should follow the semantic versioning scheme on semver.org with the following additions:
    • The minor and bugfix (and beyond) part of the version are optional.
    • There is no limit to the number of subversions you may have.
    • The appendix after the bugfix part must be alphanumeric ([0-9a-zA-Z]) but may also contain dash characters -.
    • These are all valid version numbers:
      • 1.2.3
      • 1.2.3-SNAPSHOT
      • 1.2beta1
      • 1.2-beta.1
      • 1.2
      • 1
      • 1-BETA17
      • 1.2.3.4.5
      • 1.2.3.4.5-SNAPSHOT
  • A publish repository configured. (Required only for the default release process. See further below for release process customizations.)
  • git [optional]

Usage

Add the following lines to ./project/plugins.sbt. See the section Using Plugins in the sbt website for more information.

addSbtPlugin("com.github.sbt" % "sbt-release" % "1.3.0")

version.sbt

Since the build definition is actual Scala code, it's not as straight forward to change something in the middle of it as it is with an XML definition.

For this reason, sbt-release won't ever touch your build definition files, but instead writes the new release or development version to a file defined by the setting releaseVersionFile, which is set to file("version.sbt") by default and points to $PROJECT_ROOT/version.sbt.

By default the version is set on the build level (using ThisBuild / version). This behavior can be controlled by setting releaseUseGlobalVersion to false, after which a version like version := "1.2.3" will be written to version.sbt.

Release Process

The default release process consists of the following tasks:

  1. Check that the working directory is a git repository and the repository has no outstanding changes. Also prints the hash of the last commit to the console.
  2. If there are any snapshot dependencies, ask the user whether to continue or not (default: no).
  3. Ask the user for the release version and the next development version. Sensible defaults are provided.
  4. Run clean.
  5. Run test:test, if any test fails, the release process is aborted.
  6. Write ThisBuild / version := "$releaseVersion" to the file version.sbt and also apply this setting to the current build state.
  7. Commit the changes in version.sbt.
  8. Tag the previous commit with v$version (eg. v1.2, v1.2.3).
  9. Run publish.
  10. Write ThisBuild / version := "nextVersion" to the file version.sbt and also apply this setting to the current build state.
  11. Commit the changes in version.sbt.

In case of a failure of a task, the release process is aborted.

Non-interactive release

You can run a non-interactive release by providing the argument with-defaults (tab completion works) to the release command.

For all interactions, the following default value will be chosen:

  • Continue with snapshots dependencies: no
  • Release Version: current version without the qualifier (eg. 1.2-SNAPSHOT -> 1.2)
  • Next Version: increase the minor version segment of the current version and set the qualifier to '-SNAPSHOT' (eg. 1.2.1-SNAPSHOT -> 1.3.0-SNAPSHOT)
  • VCS tag: default is abort if the tag already exists. It is possible to override the answer to VCS by default-tag-exists-answer with one of:
    • o override
    • k do not overwrite
    • a abort (default)
    • <tag-name> an explicit custom tag name (e.g. 1.2-M3)
  • VCS push:
    • Abort if no remote tracking branch is set up.
    • Abort if remote tracking branch cannot be checked (eg. via git fetch).
    • Abort if the remote tracking branch has unmerged commits.

Set release version and next version as command arguments

You can set the release version using the argument release-version and next version with next-version.

Example:

release release-version 1.0.99 next-version 1.2.0-SNAPSHOT

Skipping tests

For that emergency release at 2am on a Sunday, you can optionally avoid running any tests by providing the skip-tests argument to the release command.

Cross building during a release

Since version 0.7, sbt-release comes with built-in support for cross building and cross publishing. A cross release can be triggered in two ways:

  1. via the setting releaseCrossBuild (by default set to false)

  2. by using the option cross for the release command

    > release cross with-defaults

Combining both ways of steering a cross release, it is possible to generally disable automatic detection of cross release by using releaseCrossBuild := false and running release cross.

Of the predefined release steps, the clean, test, and publish release steps are set up for cross building.

A cross release behaves analogous to using the + command:

  1. If no crossScalaVersions are set, then running release or release cross will not trigger a cross release (i.e. run the release with the scala version specified in the setting scalaVersion).
  2. If the crossScalaVersions setting is set, then only these scala versions will be used. Make sure to include the regular/default scalaVersion in the crossScalaVersions setting as well. Note that setting running release cross on a root project with crossScalaVersions set to Nil will not release anything.

In the section Customizing the release process we take a look at how to define a ReleaseStep to participate in a cross build.

Versioning Strategies

As of version 0.8, sbt-release comes with several strategies for computing the next snapshot version via the releaseVersionBump setting. These strategies are defined in sbtrelease.Version.Bump. By default, the Next strategy is used:

  • Major: always bumps the major part of the version
  • Minor: always bumps the minor part of the version
  • Bugfix: always bumps the bugfix part of the version
  • Nano: always bumps the nano part of the version
  • Next (default): bumps the last version part, including the qualifier (e.g. 0.17 -> 0.18, 0.11.7 -> 0.11.8, 3.22.3.4.91 -> 3.22.3.4.92, 1.0.0-RC1 -> 1.0.0-RC2)
  • NextStable: bumps exactly like Next except that any prerelease qualifier is excluded (e.g. 1.0.0-RC1 -> 1.0.0)

Users can set their preferred versioning strategy in build.sbt as follows:

releaseVersionBump := sbtrelease.Version.Bump.Major

Default Versioning

The default settings make use of the helper class Version that ships with sbt-release.

releaseVersion: The current version in version.sbt, without the "-SNAPSHOT" ending. So, if version.sbt contains 1.0.0-SNAPSHOT, the release version will be set to 1.0.0.

releaseNextVersion: The "bumped" version according to the versioning strategy (explained above), including the -SNAPSHOT ending. So, if releaseVersion is 1.0.0, releaseNextVersion will be 1.0.1-SNAPSHOT.

Custom Versioning

sbt-release comes with two settings for deriving the release version and the next development version from a given version.

These derived versions are used for the suggestions/defaults in the prompt and for non-interactive releases.

Let's take a look at the types:

val releaseVersion     : TaskKey[String => String]
val releaseNextVersion : TaskKey[String => String]

If you want to customize the versioning, keep the following in mind:

  • releaseVersion

    • input: the current development version
    • output: the release version
  • releaseNextVersion

    • input: the release version (either automatically 'chosen' in a non-interactive build or from user input)
    • output: the next development version

Custom VCS messages

sbt-release has built in support to commit/push to Git, Mercurial and Subversion repositories. The messages for the tag and the commits can be customized to your needs with these settings:

val releaseTagComment        : TaskKey[String]
val releaseCommitMessage     : TaskKey[String]
val releaseNextCommitMessage : TaskKey[String]

// defaults
releaseTagComment        := s"Releasing ${(ThisBuild / version).value}",
releaseCommitMessage     := s"Setting version to ${(ThisBuild / version).value}",
releaseNextCommitMessage := s"Setting version to ${(ThisBuild / version).value}",

Publishing signed releases

SBT is able to publish signed releases using the sbt-pgp plugin.

After setting that up for your project, you can then tell sbt-release to use it by setting the releasePublishArtifactsAction key:

releasePublishArtifactsAction := PgpKeys.publishSigned.value

Customizing the release process

Not all releases are created equal

The release process can be customized to the project's needs.

  • Not using Git? Then rip it out.
  • Want to check for the existence of release notes at the start of the release and then publish it with posterous-sbt at the end? Just add the release step.

The release process is defined by State transformation functions (State => State), for which sbt-release defines this case class:

case class ReleaseStep (
  action: State => State,
  check: State => State = identity,
  enableCrossBuild: Boolean = false
)

The function action is used to perform the actual release step. Additionally, each release step can provide a check function that is run at the beginning of the release and can be used to prevent the release from running because of an unsatisfied invariant (i.e. the release step for publishing artifacts checks that publishTo is properly set up). The property enableCrossBuild tells sbt-release whether or not a particular ReleaseStep needs to be executed for the specified crossScalaVersions.

The sequence of ReleaseSteps that make up the release process is stored in the setting releaseProcess: SettingKey[Seq[ReleaseStep]].

The state transformations functions used in sbt-release are the same as the action/body part of a no-argument command. You can read more about building commands in the sbt website.

Release Steps

There are basically 2 ways to creating a new ReleaseStep:

Defining your own release steps

You can define your own state tansformation functions, just like sbt-release does, for example:

val checkOrganization = ReleaseStep(action = st => {
  // extract the build state
  val extracted = Project.extract(st)
  // retrieve the value of the organization SettingKey
  val org = extracted.get(Keys.organization)

  if (org.startsWith("com.acme"))
    sys.error("Hey, no need to release a toy project!")

  st
})

We will later see how to let this release step participate in the release process.

Reusing already defined tasks

Sometimes you just want to run an existing task or command. This is especially useful if the task raises an error in case something went wrong and therefore interrupts the release process.

sbt-release comes with a few convenience functions for converting tasks and commands to release steps:

  • releaseStepTask - Run an individual task. Does not aggregate builds.
  • releaseStepTaskAggregated - Run an aggregated task.
  • releaseStepInputTask - Run an input task, optionally taking the input to pass to it.
  • releaseStepCommand - Run a command.

For example:

releaseProcess := Seq[ReleaseStep](
  releaseStepInputTask(testOnly, " com.example.MyTest"),
  releaseStepInputTask(scripted),
  releaseStepTask(publish in subproject),
  releaseStepCommand("sonatypeRelease")
)

I highly recommend to make yourself familiar with the State API before you continue your journey to a fully customized release process.

Can we finally customize that release process, please?

Yes, and as a start, let's take a look at the default definition of releaseProcess:

The default release process

import ReleaseTransformations._

// ...

releaseProcess := Seq[ReleaseStep](
  checkSnapshotDependencies,              // : ReleaseStep
  inquireVersions,                        // : ReleaseStep
  runClean,                               // : ReleaseStep
  runTest,                                // : ReleaseStep
  setReleaseVersion,                      // : ReleaseStep
  commitReleaseVersion,                   // : ReleaseStep, performs the initial git checks
  tagRelease,                             // : ReleaseStep
  publishArtifacts,                       // : ReleaseStep, checks whether `publishTo` is properly set up
  setNextVersion,                         // : ReleaseStep
  commitNextVersion,                      // : ReleaseStep
  pushChanges                             // : ReleaseStep, also checks that an upstream branch is properly configured
)

The names of the individual steps of the release process are pretty much self-describing. Notice how we can just reuse the publish task by utilizing the releaseTask helper function, but keep in mind that it needs to be properly scoped (more info on Scopes).

Note, the commitReleaseVersion step requires that the working directory has no untracked files by default. It will abort the release in this case. You may disable this check by setting the releaseIgnoreUntrackedFiles key to true.

No Git, and no toy projects!

Let's modify the previous release process and remove the Git related steps, who uses that anyway.

import ReleaseTransformations._

// ...

ReleaseKeys.releaseProcess := Seq[ReleaseStep](
  checkOrganization,                // Look Ma', my own release step!
  checkSnapshotDependencies,
  inquireVersions,
  runTest,
  setReleaseVersion,
  publishArtifacts,
  setNextVersion
)

Overall, the process stayed pretty much the same:

  • The Git related steps were left out.
  • Our checkOrganization task was added in the beginning, just to be sure this is a serious project.

Release notes anyone?

Now let's also add steps for posterous-sbt:

import posterous.Publish._
import ReleaseTransformations._

// ...

val publishReleaseNotes = (ref: ProjectRef) => ReleaseStep(
  check  = releaseStepTaskAggregated(check in Posterous in ref),   // upfront check
  action = releaseStepTaskAggregated(publish in Posterous in ref) // publish release notes
)

// ...

ReleaseKeys.releaseProcess <<= thisProjectRef apply { ref =>
  import ReleaseStateTransformations._
  Seq[ReleaseStep](
    checkOrganization,
    checkSnapshotDependencies,
    inquireVersions,
    runTest,
    setReleaseVersion,
    publishArtifacts,
    publishReleaseNotes(ref) // we need to forward `thisProjectRef` for proper scoping of the underlying tasks
    setNextVersion
  )
}

The check part of the release step is run at the start, to make sure we have everything set up to post the release notes later on. After publishing the actual build artifacts, we also publish the release notes.

Credits

Thank you, Jason and Mark, for your feedback and ideas.

Contributors

Johannes Rudolph, Espen Wiborg, Eric Bowman, Petteri Valkonen, Gary Coady, Alexey Alekhin, Andrew Gustafson, Paul Davies, Stanislav Savulchik, Tim Van Laer, Lars Hupel

License

Copyright (c) 2011-2014 Gerolf Seitz

Published under the Apache License 2.0

sbt-release's People

Contributors

andrapyre avatar andreatp avatar atry avatar dependabot[bot] avatar dpdearing avatar dwijnand avatar espenhw avatar gseitz avatar jeffreyolchovy avatar jonathanhle avatar jroper avatar jrudolph avatar jsoref avatar jvican avatar ktoso avatar larsrh avatar laughedelic avatar leonardehrenfried avatar lmnet avatar lukajcb avatar mdedetrich avatar paulmdavies avatar pdalpra avatar pvalkone avatar rinmalavi avatar scala-steward-bot avatar sullis avatar timvlaer avatar voitau avatar xuwei-k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sbt-release's Issues

Error with fetch output and no message

When I run the release task, it gets to the point of setting the next version, which succeeds, then it logs at error level what seems to be git-fetch output (updated branches / tags).

Allow running `release` on a branch without a remote tracking branch

When cutting a release on a branch created from a tag (e.g. for a hot-fix release of an older version), it shouldn't be necessary to have a remote tracking branch set up.

The created tag will point to the commit anyway, so a remote tracking branch shouldn't be mandatory.

Working copy is dirty in git

When using git as vcs, "working copy is dirty" error is thrown when the user has untracked files, but no uncommitted changes

Publish a version for sbt 0.13

Hi, I need to use sbt 0.13 because it fixes a very important incremental recompilation issue (and also to work on the new test framework). So that would be very nice if you could publish a version for it. Thanks.

Add version, git commit sha and tag to manifest of built jar

It would be nice to have sbt-release write the git commit sha and tag of the release version that will be built, into the manifest file, as well as the release version that is decided upon by sbt-release (META-INF/MANIFEST.MF)

Some notes:
You can use git describe to get the current tag, and git rev-parse HEAD to get the commit tag at HEAD.

(Be sure to use 'git tag -a', so 'git describe' gives you the correct answer)

Move `GitLike#cmd` to `Vcs`

To make it easier to use the automatically detected VCS, the cmd method (currently protected in GitLike) should be made public and moved to the Vcs trait.

Allow version strings of the form num.num.num.alphaNumStr

sbt-release 0.8 allows versions like 1.2.3-M4 but does not allow 1.2.3.M4. The latter form is common for OSGi bundles that use the milestone (Mx), release candidate (RCx), and release (RELEASE) qualifier as the fourth component of a version string.

This can be supported by allowing a period in the VersionR pattern:

val VersionR = """([0-9]+)(?:(?:\.([0-9]+))?(?:\.([0-9]+))?)?([\-.0-9a-zA-Z]*)?""".r

Rather than submitting this as a PR, I'm opening a ticket based on our Twitter conversation -- I'm not sure if there are other version strings you want to add support for that aren't supported by the current regex.

Placate nervous releasers after git push stderr output shows in red

Push changes to the remote repository (y/n)? [y] > y
[error] To git@git:efgfp/analytics.git
[error]    ec38e8a..24aa91c  master -> master
[error] To git@git:efgfp/analytics.git
[error]  * [new tag]         v0.7.17 -> v0.7.17
[info] Set current project to analytics-tools (in build file:/C:/code/analytics/)

I'd suggest to add a line here with "git push sends it's console output to standard error, which will cause the next few lines to be marked as [error].

Support for Subversion

For as much as I would like to use Git, that's not currently possible in my organization. Can we please have Subversion support like Maven has?

Thanks.

version.sbt could override new version

If version.sbt is not scoped to ThisBuild, e.g: version := "0.1-SNAPSHOT". The release process will fail at applying the new version: version scoped to the current project will override version scoped to ThisBuild.

sbt-release ignores scalaVersion and uses 2.10.3 by default if crossScalaVersions is not set

sbt-release ignores scalaVersion and uses Scala 2.10.3 by default if crossScalaVersions is not set. I worked around this by setting

crossScalaVersions := Seq(scalaVersion.value)

The README.md implies that it should use scalaVersion by default in "Cross building during a release." Even before I read that, I expected it to use scalaVersion.

git clone https://github.com/dwalend/ScalaGraphMinimizer.git and comment out the crossScalaVersions line (after I push) in build.sbt if you want to mess around with some example code.

Thanks,

Dave

unable to release from branch with symbolic remote

I have a branch, release/0.1.1, from which I'm trying to run release with-defaults.

I run the following before doing so, so that it doesn't complain about a remote tracking branch: git branch --set-upstream release/0.1.1 origin/release/0.1.1

I receive the following error output and trace:

[info] Starting release process off commit: [removed by me]
[info] Checking remote [.] ...
[error] From .
[error]  * remote-tracking branch origin/release/0.1.1 -> FETCH_HEAD
java.lang.RuntimeException: Nonzero exit value: 128
    at scala.sys.package$.error(package.scala:27)
    at scala.Predef$.error(Predef.scala:142)
    at sbt.AbstractProcessBuilder.getString(ProcessImpl.scala:146)
    at sbt.AbstractProcessBuilder.$bang$bang(ProcessImpl.scala:149)
    at sbtrelease.Git$.isBehindRemote(Vcs.scala:104)
    at sbtrelease.ReleaseStateTransformations$$anonfun$checkUpstream$1.apply(ReleaseExtra.scala:195)
    at sbtrelease.ReleaseStateTransformations$$anonfun$checkUpstream$1.apply(ReleaseExtra.scala:181)
    at sbtrelease.ReleasePlugin$ReleaseKeys$$anonfun$2$$anonfun$apply$1.apply(ReleasePlugin.scala:49)
    at sbtrelease.ReleasePlugin$ReleaseKeys$$anonfun$2$$anonfun$apply$1.apply(ReleasePlugin.scala:49)
    at scala.collection.immutable.List.foreach(List.scala:318)
    at sbtrelease.ReleasePlugin$ReleaseKeys$$anonfun$2.apply(ReleasePlugin.scala:49)
    at sbtrelease.ReleasePlugin$ReleaseKeys$$anonfun$2.apply(ReleasePlugin.scala:33)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:60)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:60)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:62)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:62)
    at sbt.Command$.process(Command.scala:95)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:100)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:100)
    at sbt.State$$anon$1.process(State.scala:179)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:100)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:100)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
    at sbt.MainLoop$.next(MainLoop.scala:100)
    at sbt.MainLoop$.run(MainLoop.scala:93)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:71)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:66)
    at sbt.Using.apply(Using.scala:25)
    at sbt.MainLoop$.runWithNewLog(MainLoop.scala:66)
    at sbt.MainLoop$.runAndClearLast(MainLoop.scala:49)
    at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:33)
    at sbt.MainLoop$.runLogged(MainLoop.scala:25)
    at sbt.StandardMain$.runManaged(Main.scala:57)
    at sbt.xMain.run(Main.scala:29)
    at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:57)
    at xsbt.boot.Launch$.withContextLoader(Launch.scala:77)
    at xsbt.boot.Launch$.run(Launch.scala:57)
    at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
    at xsbt.boot.Launch$.launch(Launch.scala:65)
    at xsbt.boot.Launch$.apply(Launch.scala:16)
    at xsbt.boot.Boot$.runImpl(Boot.scala:32)
    at xsbt.boot.Boot$.main(Boot.scala:21)
    at xsbt.boot.Boot.main(Boot.scala)
[error] Nonzero exit value: 128
[error] Use 'last' for the full log.

By contrast and with nearly the same configuration (changing the git branch line as needed, etc.), if I try to release with-defaults from a branch like master without slashes, execution proceeds normally.

About my env: I am running with Jenkins 1.549, sbt 0.13.1 (and so sbt-release 0.8), git 1.7.9.5, for a scala 2.10 project, inside an Ubuntu 12.04 instance.

Updating library references in the README.md

There are files in a project that contain a reference to the version (like the README). It would be nice if we had a release step that could add it.

Below an example of how I hacked it in.

val updateReadmeVersion = { s:State =>
  val contents = IO.read(file("README.md"))
  //
  val p = Project.extract(s)
  //"org.qirx" %% "sbt-webjar-resources" % "version"
  val pattern = "(\"" + p.get(organization) + "\"\\s+%+\\s+\"" + p.get(name) + "\"\\s+%\\s+\")[\\w\\.]+(\")"
  val newContents = contents.replaceAll(pattern, "$1" + p.get(releaseVersion)(p.get(version)) + "$2")
  IO.write(file("README.md"), newContents)
  //
  val vcs = p.get(versionControlSystem).getOrElse(sys.error("Aborting release. Working directory is not a repository of a recognized VCS."))
  vcs.add(file("README.md").getAbsolutePath) !! s.log
  //
  s
}

releaseProcess := {
  val originalReleaseSteps = releaseProcess.value
  val (beforeCommitReleaseVersion, rest) =
    originalReleaseSteps.span(_ != commitReleaseVersion)
  //
  (beforeCommitReleaseVersion :+ (updateReadmeVersion:ReleaseStep)) ++
  rest.filter(_ != pushChanges)
}

Btw, awesome plugin! Thanks for providing it.

Allow for vesion without "in ThisBuild"

Appending of "in ThisBuild" to the version.sbt forces SBT to apply the same version across all subprojects, even if they are unrelated. We use the plugin for maintaining separate versions for each of the subprojects, and so would like to have a flag that disables this. Currently, after running 'release' we need to manually modify the version.sbt file to remove "in ThisBuild". So it would be great if that was configurable.

Errors when overriding nextVersion following documentation

I'm using SBT 0.12.3 and sbt-extras

I've added the following to my build.sbt file as outlined in the wiki documentation.

// required for release plugin
releaseSettings

// bump the bugfix version and append '-SNAPSHOT', eg. 1.2.1 -> 1.2.2-SNAPSHOT
nextVersion := { ver => Version(ver).map{_.bumpBugfix.asSnapshot.string}.getOrElse(versionFormatError) }

I then get the following errors.
(Paths have been removed)

$ sbt
Detected sbt version 0.12.3
Starting sbt: invoke with -help for other options
[info] Loading project definition from /.../project
/.../build.sbt:10: error: not found: value nextVersion
nextVersion := { ver => Version(ver).map{nextVersion;_.bumpBugfix.asSnapshot.string}.getOrElse(versionFormatError) }
^
/.../build.sbt:10: error: reassignment to val
nextVersion := { ver => Version(ver).map{nextVersion; _.bumpBugfix.asSnapshot.string}.getOrElse(versionFormatError) }

Thank you,

The git command doesn't seem to work on Windows

The git command doesn't seem to work on windows (dos or cygwin):

java.io.IOException: Cannot run program "git": CreateProcess error=2, The system cannot find the file specified

I suspect that it might be a path issue so it'd be good if you could open the git command definition (which is private now).

Adapt to plugin best practices

In order to make the user experience even better, I suggest the following refactorings according to the sbt plugins best practices:

  • Rename Release to ReleasePlugin (low priority) and extend Plugin (high priority); then we don't have to import sbtrelease._ or use fully qualified names
  • Put ReleaseKeys under ReleasePlugin, then again we don't need imports or fqns

Thanks for considering

Package definition in source files

Each of the source file (i.e Vcs.scala) contains next package declaration:

package sbt release;

On the other hand files are located under next directory src/main/scala as a result some IDE's does not handle properly such situation and it is harder to create some custom solution based on sbt-release plugin.
Could be possible to place those files under src/main/scala/sbtrelease direcotory in order to reflect package declaration?

publish is done with pre-release version, not the version supplied as releaseVersion to inquireVersions

I'm having trouble getting the release plugin (release 0.4, and my project is currently using sbt 0.11.1) to publish artifacts using the version I'm supplying as releaseVersion to inquireVersions.

Initially, my project has e.g. version := "0.1-SNAPSHOT".

I run "sbt release", using the default releaseProcess. In the inquireVersions ReleasePart, it suggests "0.1" as the releaseVersion, and I accept the suggestion.

When I reach the releaseTask(publish in Global in ref) ReleasePart, sbt packages and publishes a "0.1-SNAPSHOT" version of my artifact -- rather than the "0.1" artifacts I were expecting.

To check whether there's something strange in my project's sbt config that's causing these problems, I've also tried to add the release plugin to a checkout of the "sbt-release" project, and supplied a non-default releaseVersion there. However, that also did not work as I expected it to:

[info] Loading project definition from /Users/hmeland/src/sbt-release/project
[info] Set current project to sbt-release (in build file:/Users/hmeland/src/sbt-release/)
> about
[info] This is sbt 0.11.2
[info] The current project is {file:/Users/hmeland/src/sbt-release/}default-b74fd5
[info] The current project is built against Scala 2.9.1
[info] sbt, sbt plugins, and build definitions are using Scala 2.9.1
> release
[info] Starting release process off git commit: 114873ede58616d2a44a84330390955dc7e10465
[info] Updating {file:/Users/hmeland/src/sbt-release/}default-b74fd5...
[info] Resolving org.scala-tools.sbt#sbt_2.9.1;0.11.2 ...
[...]
[info] Done updating.
[info] Compiling 5 Scala sources to /Users/hmeland/src/sbt-release/target/scala-2.9.1/sbt-0.11.2/classes...
Release version [0.4] : 0.5
Next version [0.6-SNAPSHOT] : 
[info] No tests to run for test:test
[success] Total time: 0 s, completed Jan 3, 2012 6:00:08 PM
[info] Setting version to '0.5'.
[info] Reapplying settings...
[info] Set current project to sbt-release (in build file:/Users/hmeland/src/sbt-release/)
[info] Reapplying settings...
[info] Set current project to sbt-release (in build file:/Users/hmeland/src/sbt-release/)
[info] Reapplying settings...
[info] Set current project to sbt-release (in build file:/Users/hmeland/src/sbt-release/)
[info] Packaging /Users/hmeland/src/sbt-release/target/scala-2.9.1/sbt-0.11.2/sbt-release-0.4-sources.jar ...
[info] Generating API documentation for main sources...
[info] Packaging /Users/hmeland/src/sbt-release/target/scala-2.9.1/sbt-0.11.2/sbt-release-0.4.jar ...
[info] Wrote /Users/hmeland/src/sbt-release/target/scala-2.9.1/sbt-0.11.2/sbt-release-0.4.pom
[info] Done packaging.
[info] :: delivering :: com.github.gseitz#sbt-release;0.4 :: 0.4 :: release :: Tue Jan 03 18:00:09 CET 2012
[info]  delivering ivy file to /Users/hmeland/src/sbt-release/target/scala-2.9.1/sbt-0.11.2/ivy-0.4.xml
[info] Done packaging.
model contains 11 documentable templates
[info] API documentation generation successful.
[info] Packaging /Users/hmeland/src/sbt-release/target/scala-2.9.1/sbt-0.11.2/sbt-release-0.4-javadoc.jar ...
[info] Done packaging.
[info]  published sbt-release to /Users/hmeland/dev/repo/com/github/gseitz/sbt-release_2.9.1_0.11.2/0.4/sbt-release-0.4.pom
[info]  published sbt-release to /Users/hmeland/dev/repo/com/github/gseitz/sbt-release_2.9.1_0.11.2/0.4/sbt-release-0.4.jar
[info]  published sbt-release to /Users/hmeland/dev/repo/com/github/gseitz/sbt-release_2.9.1_0.11.2/0.4/sbt-release-0.4-sources.jar
[info]  published sbt-release to /Users/hmeland/dev/repo/com/github/gseitz/sbt-release_2.9.1_0.11.2/0.4/sbt-release-0.4-javadoc.jar
[success] Total time: 3 s, completed Jan 3, 2012 6:00:11 PM

Is this a bug (in the plugin or in sbt itself?), or is it just me that's going about this the wrong way, somehow?

Version file location can't be changed

Version.sbt file is written to a hard-coded location. This isn't always convenient; could it be a setting instead, with the current location as the default?

How to access the version from version.sbt from within Build.scala?

Hi,

how can i access the version from version.sbt file programmatically from within Build.scala. I'm trying to use sbt-release with a play2 project where the version has to be passed to the project itself like:

val appVersion = ""
val main = play.Project(appName, appVersion, appDependencies, settings = Defaults.defaultSettings ++ releaseSettings).settings( 

Sorry for asking here but i found no other appropriate place.

Thanks

Marcus

Example of custom release process

Is there a complete working example of using sbt-release with a custom release process somewhere?

I have tried to get the pieces from the README.md to work in my Build.scala file with no success. Most probably due to my inexperience with sbt...

What I want to do is call the one-jar task from sbt-onejar instead of publish when doing a release.

java.lang.RuntimeException: Nonzero exit value: 1

I'm getting this exception during release:

I'm running scala 2.9.1 with sbt 0.11.2:

[debug] Other repositories:
[debug]     xxx http:/xxx
[debug] Default repositories:
[debug]     Raw(ProjectResolver(inter-project, mapped: ))
[debug]     FileRepository(local,FileConfiguration(true,None),sbt.Patterns@3c8d785e)
[debug]     scct repository: http://mtkopone.github.com/scct/maven-repo
[debug]     snapshots: http://scala-tools.org/repo-snapshots
[debug]     releases: http://scala-tools.org/repo-releases
[debug]     releases: https://oss.sonatype.org/content/repositories/releases/
[debug]     snapshots: https://oss.sonatype.org/content/repositories/snapshots/
[debug]     releases: http://guice-maven.googlecode.com/svn/trunk
[debug]     releases: http://akka.io/repository
[debug]     snapshots: http://repository.apache.org/snapshots/
[debug]     SourceforgeReleases: https://oss.sonatype.org/content/repositories/sourceforge-releases/
[debug]     SourceforgeSnapshots: https://oss.sonatype.org/content/repositories/sourceforge-snapshots/
[debug]     Terracotta Snapshots: http://snapshots.terracotta.org/
[debug]     public: http://repo1.maven.org/maven2/
[debug]     Scala-Tools Maven2 Repository: http://scala-tools.org/repo-releases
[debug] Using inline dependencies specified in Scala.
[debug] post 1.3 ivy file: using exact as default matcher
[debug] Running task... Cancelable: true, max worker threads: 4, check cycles: false
java.lang.RuntimeException: Nonzero exit value: 1
    at scala.sys.package$.error(package.scala:27)
    at scala.Predef$.error(Predef.scala:66)
    at sbt.AbstractProcessBuilder.getString(ProcessImpl.scala:140)
    at sbt.AbstractProcessBuilder.$bang$bang(ProcessImpl.scala:143)
    at sbtrelease.ReleaseStateTransformations$$anonfun$sbtrelease$ReleaseStateTransformations$$commitVersion$1.apply(ReleaseExtra.scala:105)
    at sbtrelease.ReleaseStateTransformations$$anonfun$sbtrelease$ReleaseStateTransformations$$commitVersion$1.apply(ReleaseExtra.scala:101)
    at sbtrelease.ReleaseStateTransformations$$anonfun$commitReleaseVersion$1.apply(ReleaseExtra.scala:93)
    at sbtrelease.ReleaseStateTransformations$$anonfun$commitReleaseVersion$1.apply(ReleaseExtra.scala:92)
    at scala.Function$$anonfun$chain$1$$anonfun$apply$1.apply(Function.scala:26)
    at scala.Function$$anonfun$chain$1$$anonfun$apply$1.apply(Function.scala:26)
    at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:111)
    at scala.collection.immutable.List.foldLeft(List.scala:45)
    at scala.collection.TraversableOnce$class.$div$colon(TraversableOnce.scala:137)
    at scala.collection.immutable.List.$div$colon(List.scala:45)
    at scala.Function$$anonfun$chain$1.apply(Function.scala:26)
    at sbtrelease.ReleaseKeys$$anonfun$2.apply(ReleasePlugin.scala:31)
    at sbtrelease.ReleaseKeys$$anonfun$2.apply(ReleasePlugin.scala:23)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:62)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:62)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:64)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:64)
    at sbt.Command$.process(Command.scala:92)
    at sbt.MainLoop$$anonfun$next$1$$anonfun$apply$1.apply(Main.scala:121)
    at sbt.MainLoop$$anonfun$next$1$$anonfun$apply$1.apply(Main.scala:121)
    at sbt.State$$anon$1.process(State.scala:154)
    at sbt.MainLoop$$anonfun$next$1.apply(Main.scala:121)
    at sbt.MainLoop$$anonfun$next$1.apply(Main.scala:121)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
    at sbt.MainLoop$.next(Main.scala:121)
    at sbt.MainLoop$.run(Main.scala:114)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(Main.scala:103)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(Main.scala:100)
    at sbt.Using.apply(Using.scala:25)
    at sbt.MainLoop$.runWithNewLog(Main.scala:100)
    at sbt.MainLoop$.runAndClearLast(Main.scala:83)
    at sbt.MainLoop$.runLoggedLoop(Main.scala:67)
    at sbt.MainLoop$.runLogged(Main.scala:60)
    at sbt.xMain.run(Main.scala:33)
    at xsbt.boot.Launch$.run(Launch.scala:54)
    at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:43)
    at xsbt.boot.Launch$.launch(Launch.scala:68)
    at xsbt.boot.Launch$.apply(Launch.scala:14)
    at xsbt.boot.Boot$.runImpl(Boot.scala:25)
    at xsbt.boot.Boot$.main(Boot.scala:15)
    at xsbt.boot.Boot.main(Boot.scala)

Does sbt release merge to master?

I just released from a non-master branch and am trying to determine if the plugin or Jenkins was responsible for merging to master as part of it. Is that expected or perhaps it was a nuance with my Jenkins job?

feature request: default to "cross"

I'll get to this before too long and happy to send a pull request. If someone else wants to get to it first, all the better. :)

Basically I want a project to be able to configure that running "release" automatically does "release cross". Otherwise it's too error prone -- we have a bunch of projects, some are "release cross" and some are just "release".

I'd love if we could settle on the right configuration name in advance?

releaseCrossByDefault := true

or something like that?

Problems with releaseTask due to Extracted.runAggregated

I filed an issue to main SBT project that should probably have been filed to sbt-release. To summarize, the issue is that Project.extract(st).runAggregated(key, st) does not seem to actually execute the task, making the releaseTask shortcut invalid... any ideas? Is it a bug?

Full issue description including some snippets is here under the main SBT project : sbt/sbt#1210

interactive commit

Allow the user to commit from the SBT shell:

> release with-defaults
[info] Working directory is dirty:
[info] 
[info]  ?? project-a/

Enter a message to add everything and commit: bla bla bla

Customize the git tag

I'd like to be able to customize the git tag.

For example, I'd like to write SPECS2-1.2.3 instead of v1.2.3 to keep my history consistent.

tag-already-exists failure condition is not obvious in with-defaults logs

In https://github.com/sbt/sbt-release/blob/v0.8.1/src/main/scala/ReleaseExtra.scala#L149

When using with-defaults, if this particular error condition is triggered due to a tag already existing in the repository, the output message is not clear that that is the cause. This makes it difficult to quickly diagnose and fix the problem, when looking solely at log output.

It would be sufficient to amend the line to read similarly to the interactive output, like: "Tag [%s] exists. Aborting release!"

Can't use "+release" to do a cross release.

On my project I normally use "sbt +publish" it appears I can't do the same with the release command, I'm not sure if this means I need to tweak the release steps to handle this correctly.

release with subprojects

hi,

it's possible to do release process for project with submodules which have their own version?

for example:

root - ver 0.1

  • api - ver 0.3
  • common - ver 0.2
  • core - ver 0.4
  • integration - ver 0.2

root aggregate api, common, core and integration

when in root'll do command 'release' i want to bump version for each submodules:

  • root 0.2
    • api 0.4
    • common -0.3
    • core 0.5
    • integration 0.3

how to configure release process? and big question is what about git tags.

Test failure doesn't stop release

I might be wrong, but I think in the latest release, if the test step fails, the release isn't terminated. I think this was previously the case.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.