Skip to content

Commit

Permalink
chore: Add standard-version and changelog generator
Browse files Browse the repository at this point in the history
  • Loading branch information
driskell committed Oct 15, 2022
1 parent a2dc5e4 commit 11648b9
Show file tree
Hide file tree
Showing 10 changed files with 5,637 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ tab_width = 2
[{*.rb,*.gemspec,Rakefile,Gemfile,Gemfile.lock}]
indent_style = space
tab_width = 2

[*.js]
indent_style = space
tab_width = 2
29 changes: 29 additions & 0 deletions .versionrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
tagPrefix: '',
infile: 'CHANGELOG.md',
preset: {
name: 'conventionalcommits'
},
bumpFiles: [
{
filename: 'lc-lib/core/version.go',
updater: 'contrib/version-updaters/version.go.js'
},
{
filename: 'ruby/log-courier/lib/log-courier/version.rb',
updater: 'contrib/version-updaters/version.rb.js'
},
{
filename: 'ruby/log-courier/log-courier.gemspec',
updater: 'contrib/version-updaters/gemspec.js'
},
{
filename: 'ruby/logstash-input-courier/logstash-input-courier.gemspec',
updater: 'contrib/version-updaters/gemspec.js'
},
{
filename: 'ruby/logstash-output-courier/logstash-output-courier.gemspec',
updater: 'contrib/version-updaters/gemspec.js'
}
]
};
16 changes: 16 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
// Disable subject-case
'subject-case': [
0,
'never',
['sentence-case', 'start-case', 'pascal-case', 'upper-case'],
],
// Dependabot and others exceed body and body line length so just disable it
'body-max-length': [0, 'always', 100],
'body-max-line-length': [0, 'always', 100],
// Allow longer header length
'header-max-length': [2, 'always', 150]
}
};
14 changes: 14 additions & 0 deletions contrib/version-updaters/gemspec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
readVersion(contents) {
const match = contents.match(/gem.version\s+= '([^']+)'/)
if (!match) {
throw new Error('Could not parse gemspec');
}
return match[1];
},
writeVersion(contents, version) {
return contents
.replace(/(gem.version\s+=) '[^']+'/, `$1 '${version}'`)
.replace(/(gem.add_runtime_dependency 'log-courier',) '= [^']+'/, `$1 '= ${version}'`);
}
};
17 changes: 17 additions & 0 deletions contrib/version-updaters/version.go.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
readVersion(contents) {
const match = contents.match(/LogCourierVersion string = "([^"]+)"/)
if (!match) {
throw new Error('Could not parse version.go');
}
return match[1];
},
writeVersion(contents, version) {
const [major, minor, patch] = version.split('.');
return contents
.replace(/(LogCourierMajorVersion uint32 =) \d+/, `$1 ${major}`)
.replace(/(LogCourierMinorVersion uint32 =) \d+/, `$1 ${minor}`)
.replace(/(LogCourierPatchVersion uint32 =) \d+/, `$1 ${patch}`)
.replace(/(LogCourierVersion string =) "[^"]+"/, `$1 "${version}"`);
}
};
17 changes: 17 additions & 0 deletions contrib/version-updaters/version.rb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
readVersion(contents) {
const match = contents.match(/VERSION = '([^']+)'/)
if (!match) {
throw new Error('Could not parse version.rb');
}
return match[1];
},
writeVersion(contents, version) {
const [major, minor, patch] = version.split('.');
return contents
.replace(/(MAJOR_VERSION =) \d+/, `$1 ${major}`)
.replace(/(MINOR_VERSION =) \d+/, `$1 ${minor}`)
.replace(/(PATCH_VERSION =) \d+/, `$1 ${patch}`)
.replace(/(VERSION =) '[^']+'/, `$1 '${version}'`);
}
};
Loading

0 comments on commit 11648b9

Please sign in to comment.