Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////////////////////////////////////////////
- // VERSIONING - automatically infers version name and code based on the git tag which following //
- // the naming schema "release-v{major}.{minor}.{patch}" //
- // //
- // - Minor and Patch version should NOT exceed 99. //
- // - Maximum version code Google allow is 2100000000. This is equivalent to release-v210.0.0. //
- // //
- // Assuming your tag is: //
- // - release-v1.2.3 the code will be 10203000 //
- // - release-v11.22.33 the code will be 112233000 //
- // - release-v1.20.30 the code will be 12030000 //
- // - release-v1.99.99 the code will be 19999000 //
- // - release-v2.0.0 the code will be 20000000 //
- // - release-v209.99.99 the code will be 2099999000 //
- // //
- ////////////////////////////////////////////////////////////////////////////////////////////////////
- def tag = "git describe --tags ${"git rev-list --tags --max-count=1".execute().text}".execute().text.trim()
- def name = tag.replace("release-v", "")
- def major = (name.substring(0, name.indexOf("."))).toInteger()
- def minor = (name.substring(name.indexOf(".") + 1, name.lastIndexOf("."))).toInteger()
- def patch = (name.substring(name.lastIndexOf(".") + 1, name.length())).toInteger()
- def code = major * 10000000 + minor * 100000 + patch * 1000
- android { defaultConfig { versionCode code; versionName name } }
Add Comment
Please, Sign In to add comment