build: Prepare project for standard-version releases.

This commit is contained in:
Sergey Tereschenko 2020-04-22 17:42:47 +03:00
parent 5d6d0038db
commit 313de70076
4 changed files with 40 additions and 1 deletions

15
.versionrc.json Normal file
View file

@ -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"
}
]
}

View file

@ -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

View file

@ -0,0 +1,15 @@
const VERSION_REGEX = /^VERSION = \((?<major>\d+), (?<minor>\d+), (?<patch>\d+), '(?<tag>\w+)', (?<tagVer>\d+)\)$/m;
const NEW_VERSION_REGEX = /(?<major>\d+).(?<minor>\d+).(?<patch>\d+)(-(?<tag>\w+).(?<tagVer>\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})`);
}

9
pkg-info-updater.js Normal file
View file

@ -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}`);
}