I'm a newbie for scala.
I used sbt-release to control release process and sbt-docker to build/publish a docker image.
I can release a specific version via sbt release
and build/publish a docker image via sbt docker
or `sbt dockerBuildAndPush'
If I wanna release a specific version, I need to
- execute
sbt release
- remember the release version and modify docker image tag with the release version
- execute
sbt dockerBuildAndPush
But it's so tedious...
I wanna add build/publish docker image into release process.
For example:
I define my release process in build.sbt
val publishDocker = ReleaseStep(action = st => {
// 1. get release version from sbt-release
// 2. add release version to docker image tag
// 3. push docker image to aws ecr
})
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
publishDocker,
setNextVersion,
commitNextVersion,
pushChanges
)
But I have no idea how to implement publishDocker function.
Thanks for your help~
@ed Thanks for your advice and I solved it by myself :>
This is my sbt: https://gist.github.com/pandaforme/e378dc3f1f32aa252b14e40937491e9c
I just execute sbt release
and it'll automatically compile, generate release version, build and push docker image, etc.
I'm not familiar with sbt-docker
but you can get the version
from the st: State
parameter:
val publishDocker = ReleaseStep(action = st => {
// 1. get version from sbt
// (it was set by sbt-release in setReleaseVersion)
val extracted = Project.extract(st)
val version:String = extracted.get(sbt.Keys.version)
})
来源:https://stackoverflow.com/questions/37418201/how-to-push-build-a-docker-image-in-release-process-via-sbt-release