diff --git a/scripts/update-version.py b/scripts/update-version.py new file mode 100644 index 000000000..79c5146de --- /dev/null +++ b/scripts/update-version.py @@ -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") \ No newline at end of file diff --git a/scripts/update-version.sh b/scripts/update-version.sh deleted file mode 100755 index 0724b54d5..000000000 --- a/scripts/update-version.sh +++ /dev/null @@ -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)