10
10
from .version_utils import get_version
11
11
12
12
13
- def get_npm_package_name (root_path : Path ):
13
+ def get_package_name (root_path : Path ):
14
14
with open (root_path / 'package.json' , 'r' ) as file :
15
15
package_data = json .load (file )
16
- return package_data ['name' ]
16
+
17
+ return package_data ['name' ]
18
+
19
+
20
+ def set_package_version (root_path : Path , version : int ):
21
+ with open (root_path / 'package.json' , 'r' ) as file :
22
+ package_data = json .load (file )
23
+
24
+ package_data ['version' ] = f'{ version } .0.0'
25
+
26
+ with open ('package.json' , 'w' ) as file :
27
+ json .dump (package_data , file , indent = 2 )
17
28
18
29
19
30
def authenticate (src : Path , npm_access_token : str ):
@@ -32,7 +43,6 @@ def publish_npm_package(
32
43
github_access_token : str ,
33
44
ignore : List [str ] = [],
34
45
):
35
- package_name = get_npm_package_name (src )
36
46
37
47
if not npm_access_token :
38
48
print ('NPM access token is missing' , flush = True , file = sys .stderr )
@@ -48,8 +58,12 @@ def publish_npm_package(
48
58
if not changed :
49
59
return
50
60
61
+ package_name = get_package_name (src )
62
+
51
63
authenticate (src , npm_access_token )
52
64
65
+ set_package_version (src , version )
66
+
53
67
run (['npm' , 'publish' , '--access=public' ], cwd = src , check = True )
54
68
55
69
create_release (
0 commit comments