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:
Felix Schütt
2022-11-18 19:49:12 +01:00
parent 0d2b4d5507
commit 8fca83fc8c
2 changed files with 51 additions and 33 deletions

51
scripts/update-version.py Normal file
View 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")

View File

@@ -1,33 +0,0 @@
#! /bin/sh
# How to install `fd`: https://github.com/sharkdp/fd#installation
: "${FD:=fd}"
# A script to update the version of all the crates at the same time
PREVIOUS_VERSION='3.0.0-rc.1'
NEXT_VERSION='3.0.0-rc.2'
# quick hack
${FD} Cargo.toml --exec sed -i '{}' -e "s/version = \"$PREVIOUS_VERSION\"/version = \"$NEXT_VERSION\"/"
${FD} Cargo.toml --exec sed -i '{}' -e "s/version = \"=$PREVIOUS_VERSION\"/version = \"=$NEXT_VERSION\"/"
echo "manually check changes to Cargo.toml"
${FD} wasmer.iss --exec sed -i '{}' -e "s/AppVersion=$PREVIOUS_VERSION/AppVersion=$NEXT_VERSION/"
echo "manually check changes to wasmer.iss"
${FD} publish.py --exec sed -i '{}' -e "s/target_version = \"$PREVIOUS_VERSION\"/target_version = \"$NEXT_VERSION\"/"
echo "manually check changes to publish.py"
# Re-generate lock files
cargo generate-lockfile
# Order to upload packages in
## wasmer-types
## win-exception-handler
## compiler
## compiler-cranelift
## compiler-llvm
## compiler-singlepass
## emscripten
## wasi
## wasmer (api)