mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-09 14:48:08 -05:00
contrib: Add script to sync all toml package versions to the root lib.
This commit is contained in:
42
contrib/update_pkg_versions.py
Executable file
42
contrib/update_pkg_versions.py
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python3
|
||||
import subprocess
|
||||
|
||||
from os import chdir
|
||||
from subprocess import PIPE
|
||||
|
||||
import tomlkit
|
||||
|
||||
|
||||
def update_package_version(filename, version):
|
||||
with open(filename) as f:
|
||||
content = f.read()
|
||||
|
||||
p = tomlkit.parse(content)
|
||||
p["package"]["version"] = version
|
||||
|
||||
with open(filename, "w") as f:
|
||||
f.write(tomlkit.dumps(p))
|
||||
|
||||
|
||||
def main():
|
||||
toplevel = subprocess.run(["git", "rev-parse", "--show-toplevel"],
|
||||
capture_output=True)
|
||||
toplevel = toplevel.stdout.decode().strip()
|
||||
chdir(toplevel)
|
||||
|
||||
with open("Cargo.toml") as f:
|
||||
content = f.read()
|
||||
|
||||
p = tomlkit.parse(content)
|
||||
version = p["package"]["version"]
|
||||
|
||||
find_output = subprocess.run(
|
||||
["find", ".", "-type", "f", "-name", "Cargo.toml"], stdout=PIPE)
|
||||
files = [i.strip() for i in find_output.stdout.decode().split("\n")][:-1]
|
||||
|
||||
for filename in files:
|
||||
update_package_version(filename, version)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user