11import argparse
22from pathlib import Path
3+ import subprocess
34import sys
45import re
56
1213
1314class Updater :
1415 component : str = "patch"
16+ new_version : str = "0.0.0"
1517
1618 @staticmethod
1719 def replace (match : re .Match [str ]) -> str :
@@ -35,6 +37,7 @@ def replace(match: re.Match[str]) -> str:
3537 rc_str = f"-rc{ ver [3 ]} " if ver [3 ] > 0 else ""
3638 new_version += rc_str
3739 print ("new version:" , new_version )
40+ Updater .new_version = new_version
3841 return VER_REPLACE % (tuple (ver [:3 ]) + (rc_str ,))
3942
4043
@@ -47,6 +50,28 @@ def main():
4750 doc = VER_PATTERN .sub (Updater .replace , doc )
4851 cargo_path .write_text (doc , encoding = "utf-8" , newline = "\n " )
4952 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+
5075 return 0
5176
5277
0 commit comments