Files
yoga/set-version.py
Nick Gerleman bb892af3a4 Make trunk builds "0.0.0" (#1466)
Summary:
X-link: https://github.com/facebook/react-native/pull/41423

Pull Request resolved: https://github.com/facebook/yoga/pull/1466

Right now Yoga's main branch says it's 2.0.0, and RN's dirsync says its 1.14.0, but the code is really closer to what will be Yoga 3.0.0.

This changes trunk builds to "0.0.0" for clarity, which will be assigned a real version number the first time publishing a new Yoga branch.

This is separately a good practice to prevent the chance of accidental publishes causing damage.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D51236778

fbshipit-source-id: 06cac89bcca1c707ce5c00f9c346f627eef6b4bc
2023-11-13 22:09:35 -08:00

46 lines
1.2 KiB
Python
Executable File

#!/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)