aboutsummaryrefslogtreecommitdiff
path: root/contrib/bump-taler-version.mjs
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-03-29 19:31:17 +0200
committerFlorian Dold <florian@dold.me>2023-03-29 19:31:17 +0200
commitbfb4e8c982019140b6514ad38640d791f92405da (patch)
treed8fe3dc253525f8dde6457e9e5050ff985722c76 /contrib/bump-taler-version.mjs
parenta17a08ae287a46e837c9a691caebdd029a07dc62 (diff)
repo: helper for bumping versions
Diffstat (limited to 'contrib/bump-taler-version.mjs')
-rwxr-xr-xcontrib/bump-taler-version.mjs80
1 files changed, 80 insertions, 0 deletions
diff --git a/contrib/bump-taler-version.mjs b/contrib/bump-taler-version.mjs
new file mode 100755
index 000000000..a51ed9ad6
--- /dev/null
+++ b/contrib/bump-taler-version.mjs
@@ -0,0 +1,80 @@
+#!/usr/bin/env node
+
+// Bump the package.json versions in Taler-related packagesin
+// this repository.
+// The version must be in one of the following formats:
+// - x.y.z
+// - x.y.z-dev.n
+
+import * as fs from "fs";
+
+let requestedVersion = process.argv[2];
+
+let dry = false;
+if (process.argv.includes("--dry")) {
+ dry = true;
+}
+
+let verMatched = false;
+let verMajor = 0;
+let verMinor = 0;
+let verPatch = 0;
+let verDev = undefined;
+
+// Parse the requested version
+const releaseVerRegex = /^(\d+)[.](\d+)[.](\d+)$/;
+const devVerRegex = /^(\d+)[.](\d+)[.](\d+)-dev[.](\d+)$/;
+
+const releaseMatch = requestedVersion.match(releaseVerRegex);
+if (releaseMatch) {
+ verMatched = true;
+ verMajor = releaseMatch[1];
+ verMinor = releaseMatch[2];
+ verPatch = releaseMatch[3];
+}
+
+if (!verMatched) {
+ const devMatch = requestedVersion.match(devVerRegex);
+ if (devMatch) {
+ verMatched = true;
+ verMajor = devMatch[1];
+ verMinor = devMatch[2];
+ verPatch = devMatch[3];
+ verDev = devMatch[4];
+ }
+}
+
+let packages = ["taler-util", "taler-wallet-core", "taler-harness", "taler-wallet-cli"];
+
+for (const pkg of packages) {
+ const p = `packages/${pkg}/package.json`;
+ const data = JSON.parse(fs.readFileSync(p));
+ console.log(p, data.version);
+ if (!dry) {
+ data.version = requestedVersion;
+ fs.writeFileSync(p, JSON.stringify(data));
+ }
+}
+
+
+{
+ const p = "packages/taler-wallet-webextension/manifest-common.json"
+ const data = JSON.parse(fs.readFileSync(p));
+ console.log("manifest version", data.version);
+ console.log("manifest version_name", data.version_name);
+ // In manifest.json, we transform x.y.z-dev.n info x.y.z.n.
+ // It's necessary because browsers only allow decimals and dots
+ // in that field.
+ let dottedVer = undefined;
+ if (verDev != null) {
+ dottedVer = `${verMajor}.${verMinor}.${verPatch}.${verDev}`;
+ } else {
+ dottedVer = `${verMajor}.${verMinor}.${verPatch}`;
+ }
+ console.log("new manifest version", dottedVer);
+ if (!dry) {
+ data.version = dottedVer;
+ data.version_name = requestedVersion;
+ fs.writeFileSync(p, JSON.stringify(data));
+ }
+}