DevOopsGitReleasePlugin - Config and Run
Enable DevOopsGitReleasePlugin
To use DevOopsGitReleasePlugin
, add the following line to build.sbt
.
enablePlugins(DevOopsGitReleasePlugin)
e.g.) This is an example of the minimal settings.
ThisBuild / organization := "com.example"
ThisBuild / scalaVersion := "2.12.7"
ThisBuild / version := "0.1.0"
ThisBuild / crossScalaVersions := Seq("2.11.12", "2.12.8")
lazy val root = (project in file("."))
.enablePlugins(DevOopsGitReleasePlugin)
.settings(
name := "test-project",
libraryDependencies += "some" %% "lib" % "1.0.0"
)
Tag
gitTagFrom
The name of the branch from which it tags. So if the current branch is not the same as the gitTagFrom
value, gitTag
does not tag but throws an exception.
Default:
gitTagFrom := "master"
gitTagDescription
(Optional)
gitTagDescription
is the setting to specify the tag description. If not set, it tags without any tag description.
Default:
gitTagDescription := None
Wihtout the description, it's equivalent to
git tag ${gitTagFrom.value}
With the description, it's equivalent to
git tag -a ${gitTagFrom.value}, -m ${gitTagDescription.value}
gitTagName
This setting decides how to name the tag. It uses the project's version (i.e. version.value
) with the suffix 'v'
e.g.) If version := "1.0.0"
, the tag name is v1.0.0
.
Default:
import just.semver.SemVer
// ...
gitTagName := s"v${SemVer.render(SemVer.parseUnsafe(version.value))}"
gitTagPushRepo
This tells which remote repository to push. It's usually origin
. If there are multiple repositories, you can change it to the one you want.
e.g.)
gitTagPushRepo := "github"
Default:
gitTagPushRepo := "origin"
gitTag
It is an sbt task to create a git tag from the branch set in gitTagFrom
. It may fail if the project version is no GA.
e.g.)
Success Case
sbt:test-project> gitTag
task success>
>> non sbt task success> The semantic version from the project version has been parsed. version: 0.1.0
>> git rev-parse --abbrev-ref HEAD => master
>> git fetch --tags
>> git tag v0.1.0
>> git push origin v0.1.0
| To github.com:Kevin-Lee/test-project.git
| * [new tag] v0.1.0 -> v0.1.0
[success] Total time: 7 s, completed 16 Oct. 2019, 5:19:31 pm
Failure Case
sbt:test-project> gitTag
Failure]
>> sbt task failed after finishing the following tasks
task success>
>> non sbt task success> The semantic version from the project version has been parsed. version: 0.1.0-SNAPSHOT
This version is not eligible for tagging. [version: 0.1.0-SNAPSHOT]
It should be GA version with any pre-release or meta-info suffix
e.g.)
* 1.0.0 (⭕️)
* 1.0.0-SNAPSHOT (❌)
* 1.0.0-beta (❌)
* 1.0.0+123 (❌)
* 1.0.0-beta+123 (❌)
or
sbt:test-project> gitTag
Failure]
>> sbt task failed after finishing the following tasks
task success>
>> non sbt task success> The semantic version from the project version has been parsed. version: 0.1.0
>> git rev-parse --abbrev-ref HEAD => master
>> git fetch --tags
| => root / gitTag 2s
>> [cmd: git tag v0.1.0], [code: 128], [errors: fatal: tag 'v0.1.0' already exists]
Artifacts
devOopsCiDir
devOopsCiDir
is the ci directory which contains the files created in build to upload to GitHub release (e.g. packaged jar files) It can be either an absolute or relative path. When running devOopsCopyReleasePackages
, all the jar files with prefixed with the project name (devOopsPackagedArtifacts.value
) are copied to ${devOopsCiDir.value}/dist
.
Default:
devOopsCiDir := "ci"
// so the artifactsare copied to ci/dist
devOopsPackagedArtifacts
A List
of packaged artifacts to be copied to PROJECT_HOME/${devOopsCiDir.value}/dist
.
Default:
devOopsPackagedArtifacts := List(s"target/scala-*/${name.value}*.jar")
So for Java projects, change it to
devOopsPackagedArtifacts := List(s"target/${name.value}*.jar")
devOopsCopyReleasePackages
It is an sbt task to copy packaged artifacts to the location specified (default: devOopsPackagedArtifacts.value
to PROJECT_HOME/${devOopsCiDir.value}/dist
).
e.g.)
sbt:test-project> devOopsCopyReleasePackages
>> copyPackages - Files copied from:
- /user/home/test-project/target/scala-2.12/test-project_2.12-0.1.0.jar
- /user/home/test-project/target/scala-2.12/test-project_2.12-0.1.0-sources.jar
- /user/home/test-project/target/scala-2.12/test-project_2.12-0.1.0-javadoc.jar
to
- ci/dist/test-project_2.12-0.1.0-javadoc.jar
- ci/dist/test-project_2.12-0.1.0-sources.jar
- ci/dist/test-project_2.12-0.1.0.jar
[success] Total time: 0 s, completed 6 Apr. 2019, 11:32:21 pm
Changelog
changelogLocation
The location of changelog file. The change log filename should be the project version with the extension of .md
.
e.g.) version.value := "1.0.0"
then the changelog file should be 1.0.0.md
at the location set in changelogLocation
.
Default:
changelogLocation := "changelogs"
GitHub Release
gitHubAuthTokenEnvVar
The name of environment variable to get the GitHub auth token. It is required to do GitHub release. If the envvar is not found, it will try to read the auth token file set in gitHubAuthTokenFile
.
Default:
gitHubAuthTokenEnvVar := "GITHUB_TOKEN"