diff --git a/.versionrc.json b/.versionrc.json new file mode 100644 index 0000000..9eb7ced --- /dev/null +++ b/.versionrc.json @@ -0,0 +1,15 @@ +{ + "host": "github.com", + "owner": "deschler", + "repository": "django-modeltranslation", + "bumpFiles": [ + { + "filename": "PKG-INFO", + "updater": "pkg-info-updater.js" + }, + { + "filename": "modeltranslation/__init__.py", + "updater": "modeltranslation-version-updater.js" + } + ] +} diff --git a/CHANGELOG.md b/CHANGELOG.md index e4571fe..1757eb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. -## 0.14-0 (2019-11-14) +## 0.14.0 (2019-11-14) ### Bug Fixes diff --git a/modeltranslation-version-updater.js b/modeltranslation-version-updater.js new file mode 100644 index 0000000..3c5bc6c --- /dev/null +++ b/modeltranslation-version-updater.js @@ -0,0 +1,15 @@ +const VERSION_REGEX = /^VERSION = \((?\d+), (?\d+), (?\d+), '(?\w+)', (?\d+)\)$/m; +const NEW_VERSION_REGEX = /(?\d+).(?\d+).(?\d+)(-(?\w+).(?\d+))?/; + +module.exports.readVersion = function (contents) { + let v = contents.match(VERSION_REGEX).groups; + let version = `${v.major}.${v.minor}.${v.patch}`; + if (v.tag == "final") + return version; + return version + `-${v.tag}.${v.tagVer}`; +} + +module.exports.writeVersion = function (contents, version) { + let v = version.match(NEW_VERSION_REGEX).groups; + return contents.replace(VERSION_REGEX, `VERSION = (${v.major}, ${v.minor}, ${v.patch}, '${v.tag || 'final'}', ${v.tagVer || 0})`); +} diff --git a/pkg-info-updater.js b/pkg-info-updater.js new file mode 100644 index 0000000..a13508a --- /dev/null +++ b/pkg-info-updater.js @@ -0,0 +1,9 @@ +const VERSION_REGEX = /^Version: (.*)$/m; + +module.exports.readVersion = function (contents) { + return contents.match(VERSION_REGEX)[1]; +} + +module.exports.writeVersion = function (contents, version) { + return contents.replace(VERSION_REGEX, `Version: ${version}`); +}