Skip to content

Instantly share code, notes, and snippets.

@nioe
Last active March 28, 2023 20:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nioe/3346bc5000fc90657cc0895f3a29ee69 to your computer and use it in GitHub Desktop.
Save nioe/3346bc5000fc90657cc0895f3a29ee69 to your computer and use it in GitHub Desktop.
standard-version configuration file to bump version in gradle projects (build.gradle)
const versionRegex = /version = '(\d+\.\d+\.\d+)'/;
const gradleFile = 'build.gradle';
const gradleFileUpdater = {
filename: gradleFile,
updater: {
readVersion: contents => {
const match = contents.match(versionRegex);
if (match && match[1]) {
return match[1];
}
throw Error(`Could not read version from ${gradleFile}`);
},
writeVersion: (contents, version) => contents.replace(versionRegex, `version = '${version}'`)
}
};
module.exports = {
header: '# Changelog',
types: [
{
type: 'feat',
section: 'πŸš€ Features'
},
{
type: 'fix',
section: 'πŸ› Bug Fixes'
},
{
type: 'ci',
section: 'πŸ”„ CI/CD'
},
{
type: 'build',
section: 'πŸ“¦ Build'
},
{
type: 'chore',
hidden: true
},
{
type: 'docs',
section: 'πŸ“– Documentation'
},
{
type: 'style',
section: 'πŸ’…πŸΌ Style'
},
{
type: 'refactor',
section: 'πŸ›  Refactorings'
},
{
type: 'perf',
section: '↗️ Performance'
},
{
type: 'test',
section: 'βœ… Tests'
}
],
packageFiles: [gradleFileUpdater],
bumpFiles: [gradleFileUpdater]
};
@nioe
Copy link
Author

nioe commented Dec 21, 2021

Usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment