Giter VIP home page Giter VIP logo

mill-git's Introduction

mill-git

Maven Central

A git version plugin for Mill build tool.

Requirements

  • Mill
  • An initialized git project (git init)

Usage

With PublishModule

build.sc:

import $ivy.`com.goyeau::mill-git::<latest version>`
import com.goyeau.mill.git.GitVersionedPublishModule
import mill.scalalib.JavaModule
import mill.scalalib.publish.{Developer, License, PomSettings, VersionControl}

object `jvm-project` extends JavaModule with GitVersionedPublishModule {
  override def pomSettings = 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.sc:

import $ivy.`com.goyeau::mill-git::<latest version>`
import com.goyeau.mill.git.GitTaggedDockerModule
import mill.scalalib.JavaModule

object `docker-project` extends JavaModule with GitTaggedDockerModule {
  object docker extends DockerConfig with GitTaggedDocker {
    def tagLatest = 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.sc:

import $ivy.`com.goyeau::mill-git::<latest version>`
import com.goyeau.mill.git.GitVersionModule
import mill.scalalib.JavaModule

object `job-project` extends JavaModule {
  def jobVersion = 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

Tag Tag distance HEAD hash Uncommitted changes Uncommitted hash gitVersion
v1.0.0 0 c85ec8a false 1.0.0
v1.0.0 0 c85ec8a true 303eee4 1.0.0-1-303eee4
v1.0.0 123 c85ec8a false 1.0.0-123-c85ec8a
v1.0.0 123 c85ec8a true 303eee4 1.0.0-124-303eee4
none c85ec8a false c85ec8a
none c85ec8a true 303eee4 303eee4
none none true 303eee4 303eee4

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.

mill-git's People

Contributors

joan38 avatar scala-steward avatar

Watchers

 avatar

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.