From c326810939c06181015eb3b300c630bc4034875d Mon Sep 17 00:00:00 2001 From: kumarashit Date: Sat, 27 Mar 2021 13:34:23 +0530 Subject: [PATCH] Adding script for create multicloud release and images and upload --- release_multicloud | 75 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100755 release_multicloud diff --git a/release_multicloud b/release_multicloud new file mode 100755 index 000000000..b79d3e719 --- /dev/null +++ b/release_multicloud @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 + +# Copyright 2021 The SODA Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys, os, argparse + +image_name = "sodafoundation/multi-cloud-" +service_list = ["api", "block", "file", "s3", "datamover", "dataflow", "backend"] +valid_input = ["y", "Y", "Yes", "YES"] +helper = ["-h" "--help"] + +#Make changes in the Makefile +def make_makefile_changes(tag): + with open("Makefile", "rt") as inp: + data = inp.read() + data = data.replace('latest', tag) + inp.close() + with open("Makefile", "wt") as inp: + inp.write(data) + inp.close() + +#revert changes in the Makefile +def revert_makefile_changes(tag): + with open("Makefile", "rt") as inp: + data = inp.read() + data = data.replace(tag, 'latest') + inp.close() + with open("Makefile", "wt") as inp: + inp.write(data) + inp.close() + +# make docker +def make_docker_image(): + os.system('make docker') + +# push the image to dockerhub +def push_image(tag): + for name in service_list: + image = image_name + name + ':' + tag + print("Pushing image %s" % image) + cmd = "docker push %s" % image + os.system(cmd) + +# Create release binary +def make_release_binary(): + os.system("make dist") + + +#Change the release version as per the input +if __name__ == "__main__": + value = input("Enter the release version: ") + os.environ["VERSION"] = value + os.system('echo $VERSION') + test_run = input("Do you want to run test coverage before build and release? ") + if test_run in valid_input: + cmd = "./install/CI/coverage" + os.system(cmd) + + make_makefile_changes(value) + make_docker_image() + push_image(value) + make_release_binary() + revert_makefile_changes(value)