{"id":15288345,"url":"https://github.com/rockerhieu/versionberg","last_synced_at":"2025-05-01T02:25:04.164Z","repository":{"id":57734651,"uuid":"67982478","full_name":"rockerhieu/Versionberg","owner":"rockerhieu","description":"Gradle plugin for versioning your library/application on every git commit","archived":false,"fork":false,"pushed_at":"2019-10-03T17:29:55.000Z","size":134,"stargazers_count":78,"open_issues_count":1,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-30T21:01:43.025Z","etag":null,"topics":["android","gradle","gradle-plugin","java","versioning","versioning-semantics"],"latest_commit_sha":null,"homepage":"","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rockerhieu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-12T06:36:03.000Z","updated_at":"2024-05-29T18:29:15.000Z","dependencies_parsed_at":"2022-09-13T17:51:15.258Z","dependency_job_id":null,"html_url":"https://github.com/rockerhieu/Versionberg","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rockerhieu%2FVersionberg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rockerhieu%2FVersionberg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rockerhieu%2FVersionberg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rockerhieu%2FVersionberg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rockerhieu","download_url":"https://codeload.github.com/rockerhieu/Versionberg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251811673,"owners_count":21647749,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","gradle","gradle-plugin","java","versioning","versioning-semantics"],"created_at":"2024-09-30T15:47:48.366Z","updated_at":"2025-05-01T02:25:04.131Z","avatar_url":"https://github.com/rockerhieu.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/rockerhieu/Versionberg.svg?style=svg)](https://circleci.com/gh/rockerhieu/Versionberg)\n![Versionberg on Maven Central](https://img.shields.io/maven-central/v/io.github.rockerhieu/versionberg.svg)\n\n# Versionberg\n\nGradle plugin for versioning your library/application on every git commit.\n\n![image](https://github.com/rockerhieu/Versionberg/raw/master/assets/poster.jpg)\n\n(Generated by [Breaking Bad Generator](https://web.archive.org/web/20190325041317/http://sbll.org/breakingbad/))\n\n# Usage\nYou can use the new plugin syntax for gradle `2.1+`:\n```groovy\nplugins {\n  id \"io.github.rockerhieu.versionberg\" version \"\u003clatest-version\u003e\"\n}\n```\n\nOr the legacy way:\n ```groovy\nbuildscript {\n    repositories {\n        maven { url \"https://plugins.gradle.org/m2/\" } // or jcenter()\n    }\n    dependencies {\n        classpath 'io.github.rockerhieu:versionberg:\u003clatest-version\u003e'\n    }\n}\n\napply plugin: 'io.github.rockerhieu.versionberg'\n```\n\n## Gradle tasks\n\n`versionbergInfo`: print version info into the console, e.g:\n\n```\n$ ./gradlew versionbergInfo\n$ Versionberg: \n          major: 1\n          minor: 0\n          patch: 10\n          build: 25\n          commitSha: d48434f\n          commitCount: 25\n          code: 1000000025\n          name: 1.0.d48434f-SNAPSHOT\n          gitDir: null\n```\n\n## Java\n```groovy\nbuildscript {\n    repositories {\n        maven { url \"https://plugins.gradle.org/m2/\" } // or jcenter()\n    }\n    dependencies {\n        classpath 'io.github.rockerhieu:versionberg:\u003clatest-version\u003e'\n    }\n}\n\napply plugin: 'io.github.rockerhieu.versionberg'\napply plugin: 'java'\n\nversionberg {\n    major 1\n    minor 0\n    patch 0\n}\n\nversion = versionberg.name\n```\n\n## Android\n```groovy\nbuildscript {\n    repositories {\n        maven { url \"https://plugins.gradle.org/m2/\" } // or jcenter()\n    }\n    dependencies {\n        classpath 'io.github.rockerhieu:versionberg:\u003clatest-version\u003e'\n    }\n}\n\napply plugin: 'io.github.rockerhieu.versionberg'\napply plugin: 'com.android.application'\n\nversionberg {\n    major 1\n    minor 0\n    patch 0\n}\n\nandroid {\n    defaultConfig {\n        versionCode versionberg.code\n        versionName versionberg.name\n    }\n}\n```\n\n## Advanced usage\n\n### Custom git repo\nBy default the plugin will try to find the git repo in the root project directory. But you can change it to any git repo that you want by setting `gitDir`:\n```\nversionberg {\n    major 1\n    minor 0\n    gitDir new File(\"path/to/git/repo/.git\")\n}\n```\n\n\n### Template\n\nYou can define template for version name and version code if you don't want to use the default settings provided by `Versionberg`\n\n```groovy\nversionberg {\n    // Increase when you make incompatible API changes (default value is 0)\n    major 1\n\n    // Increase when you add functionality in a backwards-compatible manner (default value is 0)\n    minor 0\n\n    // Increase when you make backwards-compatible bug fixes (default value is 0)\n    patch 0\n\n    // default is ${commitCount}, uncomment to use a custom build number\n    // build 2\n\n    // Default version name template is '${major}.${minor}.${patch}.${build}'\n    nameTemplate '${major}.${minor}.${new Date().format(\"ddMMyyyy\")}-SNAPSHOT'\n    \n    // Default version code template is '${build}'\n    codeTemplate '(((${major} * 100) + ${minor}) * 100) * 100000 + ${build}'\n}\n```\n\nYou can put date into the template, i.e `${new Date().format(\"ddMMyyyy\")}`, see more at [SimpleDateFormat](https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html).\n\nSee [Advanced Usage](https://github.com/rockerhieu/Versionberg/wiki/Advanced-Usage#template-variables) for the list of all available variables can be used in `nameTemplate` and `codeTemplate`.\n\n## My config\nThis is the config that I been using for some years:\n```groovy\nversionberg {\n    major 1\n    minor 0\n    nameTemplate '${major}.${minor}.${commitCount}.${commitSha}'\n    codeTemplate '(((${major} * 100) + ${minor}) * 100) * 100000 + ${build}'\n}\n```\n\nExample value:\n```\nmajor: 1\nminor: 0\npatch: 0\nbuild: 12\ncommitSha: 9a35eb9\ncommitCount: 12\ncode: 1000000012\nname: 1.0.12.9a35eb9\n```\n\nMain advantages:\n* `${commitCount}`: easy to reference to a version when communicating\n* `${commitSha}`: easy to identify the git revision of a given build\n\n# Contributing\n\nPlease fork this repository and contribute back using\n[pull requests](https://github.com/rockerhieu/Versionberg/pulls).\n\nAny contributions, large or small, major features, bug fixes, additional\nlanguage translations, unit/integration tests are welcomed and appreciated\nbut will be thoroughly reviewed and discussed.\n\n# License\n\n* [The MIT License](https://opensource.org/licenses/MIT)\n\n```\nCopyright (c) 2016 Hieu Rocker\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the \"Software\"),\nto deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, sublicense,\nand/or sell copies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\nTHE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\nDEALINGS IN THE SOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frockerhieu%2Fversionberg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frockerhieu%2Fversionberg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frockerhieu%2Fversionberg/lists"}