Code Monkey home page Code Monkey logo

versioning's Introduction

Build Status codecov

Versioning

A Grade plugin that makes versioning easier:

android {
  defaultConfig {
    versionCode versioning.versionCode() // e.g. 42
    versionName versioning.versionName() // e.g. 1.0.0
  }
}

The only prerequisite is using Git as your VCS.

How to use it

Build script snippet for plugins DSL for Gradle 2.1 and later:

plugins {
  id "me.tadej.versioning" version "0.2.0"
}

Build script snippet for use in older Gradle versions or where dynamic configuration is required:

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "gradle.plugin.me.tadej:versioning:0.2.0"
  }
}

apply plugin: "me.tadej.versioning"

How does it work?

The plugin assumes you use tags to mark your releases. The version name corresponds to the git command:

$ git describe --tags --dirty --always

The version code is simply the number of commits:

$ git rev-list --count HEAD

Examples

Assume you're executing the commands below in sequential order.

$ git commit -a -m "First commit."
Op Result
versioning.versionCode() 1
versioning.versionName() "3db5953"
$ git tag -a 0.1.0 -m "First tag."
Op Result
versioning.versionCode() 1
versioning.versionName() "0.1.0"
$ git commit -a -m "Second commit."
Op Result
versioning.versionCode() 2
versioning.versionName() "0.1.0-1-g3db5953"
$ echo "Hi, mom!" > hi.txt && git add hi.txt
Op Result
versioning.versionCode() 2
versioning.versionName() "0.1.0-1-g3db5953-dirty"
$ git commit -m "Third commit."
Op Result
versioning.versionCode() 3
versioning.versionName() "0.1.0-2-g3cbf60f"
$ git tag 0.1.1
Op Result
versioning.versionCode() 3
versioning.versionName() "0.1.1"

Decorators

You can tweak the version name and/or version code:

versioning {
  decorateVersionCode { code -> code * 1000 }
  decorateVersionName { name -> "$name-SNAPSHOT" }
}

License

Copyright 2018 Tadej Slamic

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

versioning's People

Contributors

tslamic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

versioning's Issues

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.