mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-07 21:28:21 +00:00
Migrate from update-version.sh to update-version.py
The dependency on "sed" causes issues when releasing on MacOS due to differences in GNU sed / BSD sed. Now we only run python.
This commit is contained in:
51
scripts/update-version.py
Normal file
51
scripts/update-version.py
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
PREVIOUS_VERSION='3.0.0-rc.2'
|
||||
NEXT_VERSION='3.0.0-rc.3'
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
def replace(file, pattern, subst):
|
||||
# Read contents from file as a single string
|
||||
file_handle = open(file, 'r')
|
||||
file_string = file_handle.read()
|
||||
file_handle.close()
|
||||
|
||||
# Use RE package to allow for replacement (also allowing for (multiline) REGEX)
|
||||
file_string = (re.sub(pattern, subst, file_string))
|
||||
|
||||
# Write contents to file.
|
||||
# Using mode 'w' truncates the file.
|
||||
file_handle = open(file, 'w')
|
||||
file_handle.write(file_string)
|
||||
file_handle.close()
|
||||
|
||||
def replace_version(path):
|
||||
print(PREVIOUS_VERSION + " -> " + NEXT_VERSION + " (" + path + ")")
|
||||
replace(path, "version = \"" + PREVIOUS_VERSION +"\"", "version = \"" + NEXT_VERSION +"\"")
|
||||
replace(path, "version = \"=" + PREVIOUS_VERSION +"\"", "version = \"=" + NEXT_VERSION +"\"")
|
||||
pass
|
||||
|
||||
def replace_version_py(path):
|
||||
print(PREVIOUS_VERSION + " -> " + NEXT_VERSION + " (" + path + ")")
|
||||
replace(path, "target_version = \"" + PREVIOUS_VERSION +"\"", "target_version = \"" + NEXT_VERSION +"\"")
|
||||
pass
|
||||
|
||||
def replace_version_iss(path):
|
||||
print(PREVIOUS_VERSION + " -> " + NEXT_VERSION + " (" + path + ")")
|
||||
replace(path, "AppVersion=" + PREVIOUS_VERSION, "AppVersion=" + NEXT_VERSION)
|
||||
pass
|
||||
|
||||
for root, dirs, files in os.walk("."):
|
||||
path = root.split(os.sep)
|
||||
# print((len(path) - 1) * '---', os.path.basename(root))
|
||||
for file in files:
|
||||
if "Cargo.toml" in file:
|
||||
replace_version(root + "/" + file)
|
||||
elif "wasmer.iss" in file:
|
||||
replace_version_iss(root + "/" + file)
|
||||
elif "publish.py" in file:
|
||||
replace_version_py(root + "/" + file)
|
||||
|
||||
os.system("cargo generate-lockfile")
|
||||
Reference in New Issue
Block a user