This is an automated email from the ASF dual-hosted git repository.

wilfreds pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-release.git


The following commit(s) were added to refs/heads/master by this push:
     new 9f1d683  [YUNIKORN-1789]: Release tool to auto-update versions (#145)
9f1d683 is described below

commit 9f1d6834ca5b7d2c55c2cd24d56415acb3b58679
Author: Frank Yang <[email protected]>
AuthorDate: Tue Jun 13 14:26:40 2023 +1000

    [YUNIKORN-1789]: Release tool to auto-update versions (#145)
    
    Add updating of required versions to the release tool for the following
    dependencies:
    * golang
    * nodejs
    * angular
    
    Closes: #145
    
    Signed-off-by: Wilfred Spiegelenburg <[email protected]>
---
 release-top-level-artifacts/README.md | 16 +++++-----
 tools/build-release.py                | 59 +++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 8 deletions(-)

diff --git a/release-top-level-artifacts/README.md 
b/release-top-level-artifacts/README.md
index c36bf86..b25fa27 100644
--- a/release-top-level-artifacts/README.md
+++ b/release-top-level-artifacts/README.md
@@ -27,7 +27,7 @@ Details on how to set up a full development environment can 
be found in [Buildin
 
 General requirement for building YuniKorn images from this release:
 * Make
-* Docker 
+* Docker
 
 ### Yunikorn Scheduler
 The scheduler and shim are build as one set of artifacts and have one 
requirement:
@@ -61,7 +61,7 @@ Note: the naming of the images assumes a processor 
architecture that maps to the
 ## Verifying the release
 A script and configuration to create a simple cluster using the locally built 
images is provided in this release archive.
 Follow the instructions in [Building](#building) to create the local docker 
images.
-The script for validating the release and the build use the same defaults. 
+The script for validating the release and the build use the same defaults.
 
 After the images have been created run the script for more instructions and to 
list the tools required for validating
 the release:
@@ -71,8 +71,8 @@ the release:
 The `kind` cluster created using the included config is a small, but fully 
functional Kubernetes cluster, with
 Apache YuniKorn deployed.
 
-## Deploying YuniKorn 
-The simplest way to run Apache YuniKorn is to use the provided helm charts, 
you can find the templates in the release 
+## Deploying YuniKorn
+The simplest way to run Apache YuniKorn is to use the provided helm charts, 
you can find the templates in the release
 package `helm-charts`.
 There are a few prerequisites:
 1. An existing K8s cluster is up and running.
@@ -88,14 +88,14 @@ The `make` command will pass on the following variables:
 * VERSION
 * REGISTRY
 * HOST_ARCH
-These variables can be used to generate customised build: 
+These variables can be used to generate customised build:
 ```shell script
 HOST_ARCH="arm64" VERSION="1.1.0" REGISTRY="internal" make
 ```
 
-These same variables can be set and will be picked up by the validate_cluster 
script. 
+These same variables can be set and will be picked up by the validate_cluster 
script.
 
-The values defined in the helm charts assume a default build without changes 
to the variables. 
+The values defined in the helm charts assume a default build without changes 
to the variables.
 Once you have built your own docker images, you will need to replace the 
docker image name in the helm chart templates.
 Open `helm-charts/yunikorn/values.yaml` and replace the docker image 
information with ones you built.
 
@@ -103,7 +103,7 @@ For more instructions, please refer to [User 
Guide](https://yunikorn.apache.org/
 
 ## Deploying a convenience build
 Apache YuniKorn provides a convenience release with pre-build docker images 
and helm charts.
-These can be accessed via the [downloads 
page](https://yunikorn.apache.org/community/download) and instructions are 
+These can be accessed via the [downloads 
page](https://yunikorn.apache.org/community/download) and instructions are
 located in the [User Guide](https://yunikorn.apache.org/docs/).
 
 The convenience build images are multi architecture images. Supported 
architectures are  `amd64` and `arm64v8`.
diff --git a/tools/build-release.py b/tools/build-release.py
index 0755564..fba52aa 100755
--- a/tools/build-release.py
+++ b/tools/build-release.py
@@ -83,6 +83,9 @@ def build_release(email_address):
         sha[name] = download_sourcecode(release_base, repo_meta)
         update_make_version(name, os.path.join(release_base, alias), version)
 
+    # update required Golang, NodeJS and Angular versions
+    update_required_versions(release_base, repo_list)
+
     # update the sha for all repos in the build scripts
     # must be run after all repos have been checked out
     update_sha(release_base, repo_list, sha)
@@ -278,6 +281,62 @@ def update_sha(release_base, repo_list, sha):
             switcher.get(repo_name)(repo_name, os.path.join(release_base, 
repo_meta["alias"]), sha)
 
 
+# update required Golang version in the README.md
+def update_required_go_version(base_path, local_repo_path):
+    print("updating required go version")
+    go_version_file = os.path.join(local_repo_path, ".go_version")
+    if not os.path.isfile(go_version_file):
+        fail("k8shim repo .go_version does not exist")
+    with open(go_version_file) as f:
+        go_version = f.readline().strip()
+    if not go_version:
+        fail("k8shim repo .go_version is empty")
+    print(f" - go version:  {go_version}")
+    replace(os.path.join(base_path, "README.md"), 'Go 1.16', 'Go ' + 
go_version)
+
+
+# update required Node.js and angular versions in the README.md
+def update_required_node_and_angular_versions(base_path, local_repo_path):
+    print("updating required Node.js version")
+    nvmrc_file = os.path.join(local_repo_path, ".nvmrc")
+    if not os.path.isfile(nvmrc_file):
+        fail("web repo .nvmrc does not exist")
+    with open(nvmrc_file) as f:
+        node_version = f.readline().strip()
+    if not node_version:
+        fail("web repo .nvmrc is empty")
+    print(f" - node version:  {node_version}")
+    replace(os.path.join(base_path, "README.md"), 'Node.js 16.14.2', 'Node ' + 
node_version)
+
+    print("updating required Angular version")
+    package_json_file = os.path.join(local_repo_path, "package.json")
+    if not os.path.isfile(package_json_file):
+        fail("web repo package.json does not exist")
+    with open(package_json_file) as f:
+        try:
+            data = json.load(f)
+        except json.JSONDecodeError:
+            fail("load web package.json: unexpected json decode failure")
+    angular_version_match = re.search("\d+\.\d+\.\d+", 
data.get("dependencies", {}).get("@angular/core", ""))
+    if not angular_version_match:
+        fail("web repo package.json: unexpected @angular/core version")
+    angular_version = angular_version_match.group()
+    print(f" - angular version:  {angular_version}")
+    replace(os.path.join(base_path, "README.md"), 'Angular CLI 13.3.0', 
'Angular CLI ' + angular_version)
+
+
+# update required versions in the README.md
+def update_required_versions(release_base, repo_list):
+    switcher = {
+        "yunikorn-k8shim": update_required_go_version,
+        "yunikorn-web": update_required_node_and_angular_versions,
+    }
+    for repo_meta in repo_list:
+        repo_name = repo_meta["name"]
+        if switcher.get(repo_name) is not None:
+            switcher.get(repo_name)(release_base, os.path.join(release_base, 
repo_meta["alias"]))
+
+
 # Write the checksum for the source code tarball to file
 def write_checksum(tarball_file, tarball_name):
     print("generating sha512 checksum file for tar")


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to