generated from RyotaUshio/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
release
executable file
·48 lines (35 loc) · 1.22 KB
/
release
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
import json
import argparse
import subprocess
def run(cmd):
comp = subprocess.run(cmd)
if comp.returncode != 0:
exit(1)
if __name__ == '__main__':
run(['git', 'switch', 'main'])
parser = argparse.ArgumentParser()
parser.add_argument('version')
args = parser.parse_args()
args.version = args.version.strip()
with open('./manifest.json') as f:
manifest = json.load(f)
with open('./package.json') as f:
package = json.load(f)
assert manifest['version'] == package['version']
ans = input(f'Update version from {manifest["version"]} to {args.version}? ([y]/n):').strip()
if ans not in ('', 'y'):
exit(1)
manifest['version'] = args.version
package['version'] = args.version
with open('./manifest.json', 'w') as f:
json.dump(manifest, f, indent=4)
with open('./package.json', 'w') as f:
json.dump(package, f, indent=4)
run(['npm', 'i'])
run(['git', 'add', '.'])
run(['git', 'commit', '-m', f'release: {args.version}'])
run(['git', 'pull', '--rebase'])
run(['git', 'push'])
run(['git', 'tag', '-a', args.version, '-m', args.version])
run(['git', 'push', 'origin', args.version])