From 3792d724621e723ca6ec2c82e17543d3b909edbd Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Mon, 12 Jun 2023 15:53:16 -0700 Subject: [PATCH] Quick and dirty versioning script (#1305) Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1305 Made a quick script to set versions in manifests that currently exist. This should probably be stamped in more places, like the binary as well, but we don't do that right now. This does not update lockfiles for CocoaPods or JS, so those will need to be updated via an install after running this script. A note on language: This repo already has too many toolchains, but I chose Python for this since it corresponds with the enum script, and we can run it with no dependencies on macOS/Linux distros. Reviewed By: cortinico Differential Revision: D46662378 fbshipit-source-id: 74ab99eef137511f8ed2fd7d81335a0fa633caf5 --- Yoga.podspec | 2 +- YogaKit.podspec | 3 +-- gradle.properties | 2 +- javascript/package.json | 2 +- set-version.py | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 5 deletions(-) create mode 100755 set-version.py diff --git a/Yoga.podspec b/Yoga.podspec index 1c01089c..74b3971e 100644 --- a/Yoga.podspec +++ b/Yoga.podspec @@ -6,7 +6,7 @@ Pod::Spec.new do |spec| spec.name = 'Yoga' - spec.version = '2.0.0-beta.1' + spec.version = '2.0.0' spec.license = { :type => 'MIT', :file => "LICENSE" } spec.homepage = 'https://yogalayout.com/' spec.documentation_url = 'https://yogalayout.com/docs' diff --git a/YogaKit.podspec b/YogaKit.podspec index 07b24480..da288909 100644 --- a/YogaKit.podspec +++ b/YogaKit.podspec @@ -5,7 +5,7 @@ podspec = Pod::Spec.new do |spec| spec.name = 'YogaKit' - spec.version = '2.0.0-beta.1' + spec.version = '2.0.0' spec.license = { :type => 'MIT', :file => "LICENSE" } spec.homepage = 'https://facebook.github.io/yoga/' spec.documentation_url = 'https://facebook.github.io/yoga/docs/' @@ -31,4 +31,3 @@ end # See https://github.com/facebook/yoga/pull/366 podspec.attributes_hash["readme"] = "YogaKit/README.md" -podspec diff --git a/gradle.properties b/gradle.properties index bf5e62b7..e205cdeb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,4 +11,4 @@ android.useAndroidX=true org.gradle.jvmargs=-Xmx1536M -VERSION_NAME=1.19.0 \ No newline at end of file +VERSION_NAME=2.0.0 diff --git a/javascript/package.json b/javascript/package.json index bbb7d45c..6aa15ab3 100644 --- a/javascript/package.json +++ b/javascript/package.json @@ -1,6 +1,6 @@ { "name": "yoga-layout", - "version": "2.0.0-beta.1", + "version": "2.0.0", "description": "JavaScript bindings for the Yoga layout engine", "license": "MIT", "repository": { diff --git a/set-version.py b/set-version.py new file mode 100755 index 00000000..37ea57b7 --- /dev/null +++ b/set-version.py @@ -0,0 +1,37 @@ +#!/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 ", 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.write(new_contents) + + +with open("javascript/package.json", "r+") as f: + new_contents = re.sub(r'"version": ".*",', f'"version": "{version}",', f.read()) + print(new_contents) + f.seek(0) + f.write(new_contents) + +for podspec in ["Yoga.podspec", "YogaKit.podspec"]: + with open(podspec, "r+") as f: + new_contents = re.sub( + r"spec\.version = '.*'", f"spec.version = '{version}'", f.read() + ) + f.seek(0) + f.write(new_contents)