Skip to content

Repository files navigation

mill-git

Maven Central

A git version plugin for Mill build tool.

Requirements

  • Mill
  • An initialized git project (git init)

Usage

With PublishModule

build.mill:

//| mill-version: 1.0.6-native//| mvnDeps://| - com.goyeau::mill-git::<latest version>importcom.goyeau.mill.git.GitVersionedPublishModuleimportmill.scalalib.JavaModuleimportmill.scalalib.publish.{Developer, License, PomSettings, VersionControl}
object`jvm-project`extendsJavaModulewithGitVersionedPublishModule:overridedefpomSettings=PomSettings(
description ="JVM Project",
organization ="com.goyeau",
url ="https://github.com/joan38/mill-git",
licenses =Seq(License.MIT),
versionControl =VersionControl.github("joan38", "mill-git"),
developers =Seq(Developer("joan38", "Joan Goyeau", "https://github.com/joan38"))
)
> mill show jvm-project.publishVersion
[1/1] show [2/2] com.goyeau.mill.git.GitVersionModule.version "0.0.0-470-6d0b3d9"

With DockerModule

build.mill:

//| mill-version: 1.0.6-native//| mvnDeps://| - com.goyeau::mill-git::<latest version>importcom.goyeau.mill.git.GitTaggedDockerModuleimportmill.scalalib.JavaModuleobject`docker-project`extendsJavaModulewithGitTaggedDockerModule {
objectdockerextendsDockerConfigwithGitTaggedDocker {
deftagLatest=true// Default is false
}
}
> mill show docker-project.docker.tags
[1/1] show [6/6] docker-project.docker.tags [
"docker-project:0.0.0-470-6d0b3d9",
"docker-project:latest"
]

Custom options

Here is a custom configuration with the default option: build.mill:

//| mill-version: 1.0.6-native//| mvnDeps://| - com.goyeau::mill-git::<latest version>importcom.goyeau.mill.git.GitVersionModuleimportmill.scalalib.JavaModuleobject`job-project`extendsJavaModule {
defjobVersion=GitVersionModule.version(
hashLength =7, // Sets the length of the commit hash to use as a version.
withSnapshotSuffix =false// Add the -SNAPSHOT suffix so that versions gets pushed to the snapshot sonatype.
)()
}
> mill show job-project.jobVersion
[1/1] show [2/2] com.goyeau.mill.git.GitVersionModule.version "0.0.0-470-6d0b3d9"

Versioning strategy

TagTag distanceHEAD hashUncommitted changesUncommitted hashgitVersion
v1.0.00c85ec8afalse1.0.0
v1.0.00c85ec8atrue303eee41.0.0-1-303eee4
v1.0.0123c85ec8afalse1.0.0-123-c85ec8a
v1.0.0123c85ec8atrue303eee41.0.0-124-303eee4
nonec85ec8afalsec85ec8a
nonec85ec8atrue303eee4303eee4
nonenonetrue303eee4303eee4

Note that we are generating a git hash for the uncommitted changes (even if they are not committed yet).

Related projects

Contributing

Contributions are more than welcome!
See CONTRIBUTING.md for all the information and getting help.

About

A git version plugin for Mill build tool

Topics

Resources

Contributing

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages