diff --git a/.versionrc.json b/.versionrc.json index 8f9e8eb..24c910b 100644 --- a/.versionrc.json +++ b/.versionrc.json @@ -3,5 +3,11 @@ "skip": { "commit": true, "tag": true - } -} \ No newline at end of file + }, + "bumpFiles": [ + { + "filename": "Cargo.toml", + "updater": "./scripts/cargo-version-updater.js" + } + ] +} diff --git a/scripts/bump-version b/scripts/bump-version new file mode 100755 index 0000000..50b8dff --- /dev/null +++ b/scripts/bump-version @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +pushd `git rev-parse --show-toplevel` > /dev/null +# See https://github.com/conventional-changelog/standard-version#cli-usage for usage +npx standard-version "$@" +popd > /dev/null diff --git a/scripts/cargo-version-updater.js b/scripts/cargo-version-updater.js new file mode 100644 index 0000000..6490411 --- /dev/null +++ b/scripts/cargo-version-updater.js @@ -0,0 +1,15 @@ +const VERSION_REGEXP = /^version\s*=\s*"([^"]+)"/m; + +const readVersion = function (contents) { + const matches = contents.match(VERSION_REGEXP); + if (!matches) { + throw new Error("Version key not found!"); + } + return matches[1]; +} + +const writeVersion = function (contents, version) { + return contents.replace(VERSION_REGEXP, `version = "${version}"`); +} + +module.exports = {readVersion, writeVersion};