|
1 |
| -// import { URL } from "url"; |
2 |
| -// import { readFileSync, writeFileSync } from "fs"; |
| 1 | +import { URL } from "url"; |
| 2 | +import { readFileSync, writeFileSync } from "fs"; |
3 | 3 |
|
4 |
| -// const versionFilePath = new URL( |
5 |
| -// "../../common/version/version.go", |
6 |
| -// import.meta.url |
7 |
| -// ).pathname; |
| 4 | +const versionFilePath = new URL( |
| 5 | + "../../params/version.go", |
| 6 | + import.meta.url |
| 7 | +).pathname; |
8 | 8 |
|
9 |
| -// const versionFileContent = readFileSync(versionFilePath, { encoding: "utf-8" }); |
| 9 | +const versionFileContent = readFileSync(versionFilePath, { encoding: "utf-8" }); |
10 | 10 |
|
11 |
| -// const currentVersion = versionFileContent.match( |
12 |
| -// /var tag = "(?<version>v(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+))"/ |
13 |
| -// ); |
| 11 | +const currentVersionPatch = versionFileContent.match( |
| 12 | + /VersionPatch = (?<patch>\d+)/ |
| 13 | +).groups.patch; |
14 | 14 |
|
15 |
| -// try { |
16 |
| -// parseInt(currentVersion.groups.major); |
17 |
| -// parseInt(currentVersion.groups.minor); |
18 |
| -// parseInt(currentVersion.groups.patch); |
19 |
| -// } catch (err) { |
20 |
| -// console.error(new Error("Failed to parse version in version.go file")); |
21 |
| -// throw err; |
22 |
| -// } |
| 15 | +try { |
| 16 | + parseInt(currentVersionPatch); |
| 17 | +} catch (err) { |
| 18 | + console.error(new Error("Failed to parse version in version.go file")); |
| 19 | + throw err; |
| 20 | +} |
23 | 21 |
|
24 |
| -// // prettier-ignore |
25 |
| -// const newVersion = `v${currentVersion.groups.major}.${currentVersion.groups.minor}.${parseInt(currentVersion.groups.patch) + 1}`; |
| 22 | +// prettier-ignore |
| 23 | +const newVersionPatch = `${parseInt(currentVersionPatch) + 1}`; |
26 | 24 |
|
27 |
| -// console.log( |
28 |
| -// `Bump version from ${currentVersion.groups.version} to ${newVersion}` |
29 |
| -// ); |
| 25 | +console.log( |
| 26 | + `Bump version from ${currentVersionPatch} to ${newVersionPatch}` |
| 27 | +); |
30 | 28 |
|
31 |
| -// writeFileSync( |
32 |
| -// versionFilePath, |
33 |
| -// versionFileContent.replace( |
34 |
| -// `var tag = "${currentVersion.groups.version}"`, |
35 |
| -// `var tag = "${newVersion}"` |
36 |
| -// ) |
37 |
| -// ); |
| 29 | +writeFileSync( |
| 30 | + versionFilePath, |
| 31 | + versionFileContent.replace( |
| 32 | + `VersionPatch = ${currentVersionPatch}`, |
| 33 | + `VersionPatch = ${newVersionPatch}` |
| 34 | + ) |
| 35 | +); |
0 commit comments