Skip to content

Commit 2dfcae0

Browse files
committed
prepare release workflow
1 parent 7502743 commit 2dfcae0

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

.github/workflows/bump_version.py

+31-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import argparse
22
from pathlib import Path
3-
import sys
3+
import subprocess
44
import re
55

66
VER_PATTERN = re.compile(
@@ -12,6 +12,7 @@
1212

1313
class Updater:
1414
component: str = "patch"
15+
new_version: str = "0.0.0"
1516

1617
@staticmethod
1718
def replace(match: re.Match[str]) -> str:
@@ -35,6 +36,7 @@ def replace(match: re.Match[str]) -> str:
3536
rc_str = f"-rc{ver[3]}" if ver[3] > 0 else ""
3637
new_version += rc_str
3738
print("new version:", new_version)
39+
Updater.new_version = new_version
3840
return VER_REPLACE % (tuple(ver[:3]) + (rc_str,))
3941

4042

@@ -46,9 +48,35 @@ def main():
4648
doc = cargo_path.read_text(encoding="utf-8")
4749
doc = VER_PATTERN.sub(Updater.replace, doc)
4850
cargo_path.write_text(doc, encoding="utf-8", newline="\n")
51+
subprocess.run(["cargo", "update", "--workspace"], check=True)
4952
print("Updated version in Cargo.toml")
50-
return 0
53+
subprocess.run(
54+
[
55+
"yarn",
56+
"version",
57+
"--new-version",
58+
Updater.new_version,
59+
"--no-git-tag-version",
60+
],
61+
cwd="node-binding",
62+
check=True,
63+
)
64+
print("Updated version in node-binding/**package.json")
65+
tag = "v" + Updater.new_version
66+
subprocess.run(["git", "add", "--all"], check=True)
67+
subprocess.run(["git", "commit", "-m", f"bump version to {tag}"], check=True)
68+
try:
69+
subprocess.run(["git", "push"], check=True)
70+
except subprocess.CalledProcessError as exc:
71+
raise RuntimeError("Failed to push commit for version bump") from exc
72+
print("Pushed commit to 'bump version to", tag, "'")
73+
try:
74+
subprocess.run(["git", "tag", tag], check=True)
75+
except subprocess.CalledProcessError as exc:
76+
raise RuntimeError("Failed to create tag for commit") from exc
77+
print("Created tag", tag)
78+
print(f"Use 'git push origin refs/tags/{tag}' to publish a release")
5179

5280

5381
if __name__ == "__main__":
54-
sys.exit(main())
82+
main()

node-binding/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@
3535
"url": "https://github.com/cpp-linter/cpp_linter_rs/issues"
3636
},
3737
"homepage": "https://github.com/cpp-linter/cpp_linter_rs#readme"
38-
}
38+
}

0 commit comments

Comments
 (0)