合并到 master 与 sbt release-plugin
merge to master with sbt release-plugin
我正在尝试使用 sbt-release 插件发布我的 sbt 项目。
当我在 develop brunch 上执行 'sbt release ' 任务时,它会基于这个分支创建一个新标签,但不会将当前 develop 分支的更改合并到 master。
是否可以在发布时将 develop 分支中所做的所有更改合并到 master 中?
我需要这样的东西:
- 将项目版本更改为发布版本并将这些更改推送到远程开发分支。
- 将最新的开发提交合并到 master 分支并标记它。
- 将版本号更改为下一个快照并将这些更改推送回远程开发。
那么我怎样才能实现这种行为呢?
您可以通过使用您自己的自定义步骤更改发布过程来实现。
基本上我只是复制了 sbt-release
代码中的步骤,并添加了一些我自己的
lazy val deploySettings: Seq[Def.Setting[_]] = {
import ReleaseTransformations._
import ReleasePlugin.autoImport._
import sbtrelease.{Git, Utilities, ExtraReleaseCommands}
import Utilities._
val deployBranch = "master"
def merge: (State) => State = { st: State =>
val git = st.extract.get(releaseVcs).get.asInstanceOf[Git]
val curBranch = (git.cmd("rev-parse", "--abbrev-ref", "HEAD") !!).trim
st.log.info(s"####### current branch: $curBranch")
git.cmd("checkout", deployBranch) ! st.log
st.log.info(s"####### pull $deployBranch")
git.cmd("pull") ! st.log
st.log.info(s"####### merge")
git.cmd("merge", curBranch, "--no-ff", "--no-edit") ! st.log
st.log.info(s"####### push")
git.cmd("push", "origin", s"$deployBranch:$deployBranch") ! st.log
st.log.info(s"####### checkout $curBranch")
git.cmd("checkout", curBranch) ! st.log
st
}
lazy val mergeReleaseVersionAction = { st: State =>
val newState = merge(st)
newState
}
val mergeReleaseVersion = ReleaseStep(mergeReleaseVersionAction)
publishingSettings ++
Seq(
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
pushChanges, //to make sure develop branch is pulled
mergeReleaseVersion, //will merge into master and push
tagRelease,
setNextVersion,
commitNextVersion,
pushChanges
)
)
}
假设您使用的是git
不是很漂亮,但是很管用。
lev 的建议或多或少是正确的,尽管在使用 sbt 1.2.8 时我发现 API 已经改变并且事情没有按预期工作。我必须将所有内容都放在顶层,删除 deploySettings
封闭块,还必须更改发布步骤分配。这是我的版本:
import ReleaseTransformations._
import ReleasePlugin.autoImport._
import sbtrelease.{Git, Utilities}
import Utilities._
val deployBranch = "master"
def merge: (State) => State = { st: State =>
val git = st.extract.get(releaseVcs).get.asInstanceOf[Git]
val curBranch = (git.cmd("rev-parse", "--abbrev-ref", "HEAD") !!).trim
st.log.info(s"####### current branch: $curBranch")
git.cmd("checkout", deployBranch) ! st.log
st.log.info(s"####### pull $deployBranch")
git.cmd("pull") ! st.log
st.log.info(s"####### merge")
git.cmd("merge", curBranch, "--no-ff", "--no-edit") ! st.log
st.log.info(s"####### push")
git.cmd("push", "origin", s"$deployBranch:$deployBranch") ! st.log
st.log.info(s"####### checkout $curBranch")
git.cmd("checkout", curBranch) ! st.log
st
}
lazy val mergeReleaseVersionAction = { st: State =>
val newState = merge(st)
newState
}
val mergeReleaseVersion = ReleaseStep(mergeReleaseVersionAction)
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
pushChanges, //to make sure develop branch is pulled
tagRelease,
mergeReleaseVersion, //will merge into master and push
setNextVersion,
commitNextVersion,
pushChanges
)
HTH!
我正在尝试使用 sbt-release 插件发布我的 sbt 项目。 当我在 develop brunch 上执行 'sbt release ' 任务时,它会基于这个分支创建一个新标签,但不会将当前 develop 分支的更改合并到 master。 是否可以在发布时将 develop 分支中所做的所有更改合并到 master 中?
我需要这样的东西:
- 将项目版本更改为发布版本并将这些更改推送到远程开发分支。
- 将最新的开发提交合并到 master 分支并标记它。
- 将版本号更改为下一个快照并将这些更改推送回远程开发。
那么我怎样才能实现这种行为呢?
您可以通过使用您自己的自定义步骤更改发布过程来实现。
基本上我只是复制了 sbt-release
代码中的步骤,并添加了一些我自己的
lazy val deploySettings: Seq[Def.Setting[_]] = {
import ReleaseTransformations._
import ReleasePlugin.autoImport._
import sbtrelease.{Git, Utilities, ExtraReleaseCommands}
import Utilities._
val deployBranch = "master"
def merge: (State) => State = { st: State =>
val git = st.extract.get(releaseVcs).get.asInstanceOf[Git]
val curBranch = (git.cmd("rev-parse", "--abbrev-ref", "HEAD") !!).trim
st.log.info(s"####### current branch: $curBranch")
git.cmd("checkout", deployBranch) ! st.log
st.log.info(s"####### pull $deployBranch")
git.cmd("pull") ! st.log
st.log.info(s"####### merge")
git.cmd("merge", curBranch, "--no-ff", "--no-edit") ! st.log
st.log.info(s"####### push")
git.cmd("push", "origin", s"$deployBranch:$deployBranch") ! st.log
st.log.info(s"####### checkout $curBranch")
git.cmd("checkout", curBranch) ! st.log
st
}
lazy val mergeReleaseVersionAction = { st: State =>
val newState = merge(st)
newState
}
val mergeReleaseVersion = ReleaseStep(mergeReleaseVersionAction)
publishingSettings ++
Seq(
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
pushChanges, //to make sure develop branch is pulled
mergeReleaseVersion, //will merge into master and push
tagRelease,
setNextVersion,
commitNextVersion,
pushChanges
)
)
}
假设您使用的是git
不是很漂亮,但是很管用。
lev 的建议或多或少是正确的,尽管在使用 sbt 1.2.8 时我发现 API 已经改变并且事情没有按预期工作。我必须将所有内容都放在顶层,删除 deploySettings
封闭块,还必须更改发布步骤分配。这是我的版本:
import ReleaseTransformations._
import ReleasePlugin.autoImport._
import sbtrelease.{Git, Utilities}
import Utilities._
val deployBranch = "master"
def merge: (State) => State = { st: State =>
val git = st.extract.get(releaseVcs).get.asInstanceOf[Git]
val curBranch = (git.cmd("rev-parse", "--abbrev-ref", "HEAD") !!).trim
st.log.info(s"####### current branch: $curBranch")
git.cmd("checkout", deployBranch) ! st.log
st.log.info(s"####### pull $deployBranch")
git.cmd("pull") ! st.log
st.log.info(s"####### merge")
git.cmd("merge", curBranch, "--no-ff", "--no-edit") ! st.log
st.log.info(s"####### push")
git.cmd("push", "origin", s"$deployBranch:$deployBranch") ! st.log
st.log.info(s"####### checkout $curBranch")
git.cmd("checkout", curBranch) ! st.log
st
}
lazy val mergeReleaseVersionAction = { st: State =>
val newState = merge(st)
newState
}
val mergeReleaseVersion = ReleaseStep(mergeReleaseVersionAction)
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
pushChanges, //to make sure develop branch is pulled
tagRelease,
mergeReleaseVersion, //will merge into master and push
setNextVersion,
commitNextVersion,
pushChanges
)
HTH!