forked from facebook/yoga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
set-version.py
executable file
·45 lines (37 loc) · 1.16 KB
/
set-version.py
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
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import os
import re
import sys
os.chdir(os.path.dirname(__file__))
if len(sys.argv) != 2:
print("usage: ./set-version <version>", file=sys.stderr)
sys.exit(1)
version = sys.argv[1]
with open("gradle.properties", "r+") as f:
new_contents = re.sub(r"VERSION_NAME=.*", f"VERSION_NAME={version}", f.read())
f.seek(0)
f.truncate()
f.write(new_contents)
with open("javascript/package.json", "r+") as f:
new_contents = re.sub(r'"version": ".*",', f'"version": "{version}",', f.read())
f.seek(0)
f.truncate()
f.write(new_contents)
with open("website-next/package.json", "r+") as f:
new_contents = re.sub(
r'"yoga-layout": ".*"', f'"yoga-layout": "{version}"', f.read()
)
f.seek(0)
f.truncate()
f.write(new_contents)
with open("Yoga.podspec", "r+") as f:
new_contents = re.sub(
r"spec\.version = '.*'", f"spec.version = '{version}'", f.read()
)
f.seek(0)
f.truncate()
f.write(new_contents)