File: set-version.py

package info (click to toggle)
yoga 3.2.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 984 kB
  • sloc: cpp: 12,985; python: 260; sh: 32; makefile: 6
file content (45 lines) | stat: -rwxr-xr-x 1,182 bytes parent folder | download | duplicates (2)
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/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)