1
1
import argparse
2
2
from pathlib import Path
3
+ import subprocess
3
4
import sys
4
5
import re
5
6
12
13
13
14
class Updater :
14
15
component : str = "patch"
16
+ new_version : str = "0.0.0"
15
17
16
18
@staticmethod
17
19
def replace (match : re .Match [str ]) -> str :
@@ -35,6 +37,7 @@ def replace(match: re.Match[str]) -> str:
35
37
rc_str = f"-rc{ ver [3 ]} " if ver [3 ] > 0 else ""
36
38
new_version += rc_str
37
39
print ("new version:" , new_version )
40
+ Updater .new_version = new_version
38
41
return VER_REPLACE % (tuple (ver [:3 ]) + (rc_str ,))
39
42
40
43
@@ -47,6 +50,28 @@ def main():
47
50
doc = VER_PATTERN .sub (Updater .replace , doc )
48
51
cargo_path .write_text (doc , encoding = "utf-8" , newline = "\n " )
49
52
print ("Updated version in Cargo.toml" )
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
+ subprocess .run (["napi" , "prepublish" ], cwd = "node-binding" , check = True )
65
+ print ("Updated version in node-binding/**package.json" )
66
+ subprocess .run (["git" , "add" , "--all" ], check = True )
67
+ tag = "v" + Updater .new_version
68
+ subprocess .run (["git" , "commit" , "-m" , f"bump version to { tag } " ], check = True )
69
+ subprocess .run (["git" , "push" ], check = True )
70
+ print ("Pushed commit to 'bump version to" , tag , "'" )
71
+ subprocess .run (["git" , "tag" , tag ], check = True )
72
+ print ("Created tag" , tag )
73
+ print ("Use 'git push --tag" , tag , "' to publish a release" )
74
+
50
75
return 0
51
76
52
77
0 commit comments