2019-03-21 20:44:13 +00:00
|
|
|
import os
|
|
|
|
|
|
2020-05-14 21:15:06 +00:00
|
|
|
|
2019-03-21 20:44:13 +00:00
|
|
|
def update_version():
|
2022-04-26 16:35:16 +00:00
|
|
|
version = ""
|
2020-05-14 21:15:06 +00:00
|
|
|
cwd = os.path.dirname(os.path.realpath(__file__))
|
2022-04-26 16:35:16 +00:00
|
|
|
with open(os.path.join(cwd, "..", "..", "VERSION_NUMBER")) as f:
|
2019-03-21 20:44:13 +00:00
|
|
|
version = f.readline().strip()
|
|
|
|
|
lines = []
|
2022-04-26 16:35:16 +00:00
|
|
|
current_version = ""
|
|
|
|
|
file_path = os.path.join(cwd, "..", "..", "docs", "Versioning.md")
|
2019-03-21 20:44:13 +00:00
|
|
|
with open(file_path) as f:
|
|
|
|
|
lines = f.readlines()
|
|
|
|
|
for line in lines:
|
2022-04-26 16:35:16 +00:00
|
|
|
if line.startswith("|"):
|
|
|
|
|
sections = line.split("|")
|
2020-05-14 21:15:06 +00:00
|
|
|
if len(sections) == 8 and sections[1].strip()[0].isdigit():
|
2019-03-21 20:44:13 +00:00
|
|
|
current_version = sections[1].strip()
|
|
|
|
|
break
|
2022-04-26 16:35:16 +00:00
|
|
|
print("Current version of ORT seems to be: " + current_version)
|
2019-03-21 20:44:13 +00:00
|
|
|
if version != current_version:
|
2022-04-26 16:35:16 +00:00
|
|
|
with open(file_path, "w") as f:
|
2020-05-14 21:15:06 +00:00
|
|
|
for i, line in enumerate(lines):
|
2019-03-21 20:44:13 +00:00
|
|
|
f.write(line)
|
2022-04-26 16:35:16 +00:00
|
|
|
if line.startswith("|--"):
|
|
|
|
|
sections = lines[i + 1].split("|")
|
2019-07-23 23:33:06 +00:00
|
|
|
# Make sure there are no 'False Positive' version additions
|
|
|
|
|
# by making sure the line we are building a new line from
|
|
|
|
|
# contains the current_version
|
|
|
|
|
if len(sections) > 1 and sections[1].strip() == current_version:
|
2022-04-26 16:35:16 +00:00
|
|
|
sections[1] = " " + version + " "
|
|
|
|
|
new_line = "|".join(sections)
|
2019-07-23 23:33:06 +00:00
|
|
|
f.write(new_line)
|
2019-03-21 20:44:13 +00:00
|
|
|
lines = []
|
2022-04-26 16:35:16 +00:00
|
|
|
current_version = ""
|
|
|
|
|
file_path = os.path.join(cwd, "..", "..", "docs", "python", "README.rst")
|
2019-03-21 20:44:13 +00:00
|
|
|
with open(file_path) as f:
|
|
|
|
|
lines = f.readlines()
|
|
|
|
|
for line in lines:
|
2022-04-26 16:35:16 +00:00
|
|
|
sections = line.strip().split(".")
|
2019-03-21 20:44:13 +00:00
|
|
|
if len(sections) == 3 and sections[0].isdigit() and sections[1].isdigit() and sections[2].isdigit():
|
|
|
|
|
current_version = line.strip()
|
|
|
|
|
break
|
|
|
|
|
if version != current_version:
|
|
|
|
|
inserted = False
|
2022-04-26 16:35:16 +00:00
|
|
|
with open(file_path, "w") as f:
|
2019-03-21 20:44:13 +00:00
|
|
|
for line in lines:
|
2022-04-26 16:35:16 +00:00
|
|
|
sections = line.strip().split(".")
|
|
|
|
|
if (
|
|
|
|
|
inserted is False
|
|
|
|
|
and len(sections) == 3
|
|
|
|
|
and sections[0].isdigit()
|
|
|
|
|
and sections[1].isdigit()
|
|
|
|
|
and sections[2].isdigit()
|
|
|
|
|
):
|
|
|
|
|
f.write(version + "\n")
|
|
|
|
|
f.write("^" * len(version) + "\n\n")
|
|
|
|
|
f.write(
|
|
|
|
|
"Release Notes : https://github.com/Microsoft/onnxruntime/releases/tag/v"
|
|
|
|
|
+ version.strip()
|
|
|
|
|
+ "\n\n"
|
|
|
|
|
)
|
2019-03-21 20:44:13 +00:00
|
|
|
inserted = True
|
|
|
|
|
f.write(line)
|
|
|
|
|
lines = []
|
2022-04-26 16:35:16 +00:00
|
|
|
current_version = ""
|
|
|
|
|
file_path = os.path.join(cwd, "..", "..", "onnxruntime", "__init__.py")
|
2019-03-21 20:44:13 +00:00
|
|
|
with open(file_path) as f:
|
|
|
|
|
lines = f.readlines()
|
|
|
|
|
for line in lines:
|
2022-04-26 16:35:16 +00:00
|
|
|
if line.startswith("__version__"):
|
|
|
|
|
current_version = line.split("=")[1].strip()[1:-1]
|
2019-03-21 20:44:13 +00:00
|
|
|
break
|
|
|
|
|
if version != current_version:
|
2022-04-26 16:35:16 +00:00
|
|
|
with open(file_path, "w") as f:
|
2019-03-21 20:44:13 +00:00
|
|
|
for line in lines:
|
2022-04-26 16:35:16 +00:00
|
|
|
if line.startswith("__version__"):
|
2019-03-21 20:44:13 +00:00
|
|
|
f.write('__version__ = "' + version + '"\n')
|
|
|
|
|
continue
|
|
|
|
|
f.write(line)
|
|
|
|
|
|
2021-04-16 08:33:10 +00:00
|
|
|
# update version for NPM packages
|
2022-04-26 16:35:16 +00:00
|
|
|
current_version = ""
|
|
|
|
|
js_root = os.path.join(cwd, "..", "..", "js")
|
2022-04-19 19:28:13 +00:00
|
|
|
|
|
|
|
|
def run(args, cwd):
|
2022-04-26 16:35:16 +00:00
|
|
|
from util import is_windows, run
|
|
|
|
|
|
2022-04-19 19:28:13 +00:00
|
|
|
if is_windows():
|
2023-03-24 22:29:03 +00:00
|
|
|
args = ["cmd", "/c", *args]
|
2022-04-19 19:28:13 +00:00
|
|
|
run(*args, cwd=cwd)
|
|
|
|
|
|
|
|
|
|
# check if node, npm and yarn are installed
|
2022-04-26 16:35:16 +00:00
|
|
|
run(["node", "--version"], cwd=js_root)
|
|
|
|
|
run(["npm", "--version"], cwd=js_root)
|
|
|
|
|
run(["yarn", "--version"], cwd=js_root)
|
2022-04-19 19:28:13 +00:00
|
|
|
|
|
|
|
|
# upgrade version for onnxruntime-common
|
2022-04-26 16:35:16 +00:00
|
|
|
run(["npm", "version", version], cwd=os.path.join(js_root, "common"))
|
|
|
|
|
run(["npm", "install", "--package-lock-only", "--ignore-scripts"], cwd=os.path.join(js_root, "common"))
|
2022-04-19 19:28:13 +00:00
|
|
|
|
|
|
|
|
# upgrade version for onnxruntime-node
|
2022-04-26 16:35:16 +00:00
|
|
|
run(["npm", "version", version], cwd=os.path.join(js_root, "node"))
|
|
|
|
|
run(["npm", "install", "--package-lock-only", "--ignore-scripts"], cwd=os.path.join(js_root, "node"))
|
2022-04-19 19:28:13 +00:00
|
|
|
|
|
|
|
|
# upgrade version for onnxruntime-web
|
2022-04-26 16:35:16 +00:00
|
|
|
run(["npm", "version", version], cwd=os.path.join(js_root, "web"))
|
|
|
|
|
run(["npm", "install", "--package-lock-only", "--ignore-scripts"], cwd=os.path.join(js_root, "web"))
|
2022-04-19 19:28:13 +00:00
|
|
|
|
|
|
|
|
# upgrade version for onnxruntime-react-native
|
2022-04-26 16:35:16 +00:00
|
|
|
run(["npm", "version", version], cwd=os.path.join(js_root, "react_native"))
|
|
|
|
|
run(["yarn", "upgrade", "onnxruntime-common"], cwd=os.path.join(js_root, "react_native"))
|
2020-06-09 20:12:55 +00:00
|
|
|
|
2023-06-09 23:18:53 +00:00
|
|
|
# upgrade version.ts in each package
|
|
|
|
|
run(["npm", "ci"], cwd=js_root)
|
|
|
|
|
run(["npm", "run", "update-version", "common"], cwd=js_root)
|
|
|
|
|
run(["npm", "run", "update-version", "node"], cwd=js_root)
|
|
|
|
|
run(["npm", "run", "update-version", "web"], cwd=js_root)
|
|
|
|
|
run(["npm", "run", "update-version", "react_native"], cwd=js_root)
|
|
|
|
|
run(["npm", "run", "format"], cwd=js_root)
|
|
|
|
|
|
2020-05-14 21:15:06 +00:00
|
|
|
|
2019-03-21 20:44:13 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
|
update_version()
|