Default publish script to dry run

This commit is contained in:
Mark McCaskey
2020-08-17 16:04:24 -07:00
parent 4be92f37f3
commit cf5601cff7

View File

@@ -1,7 +1,8 @@
#! /usr/bin/env python3 #! /usr/bin/env python3
# This is a script for publishing the wasmer crates to crates.io. # This is a script for publishing the wasmer crates to crates.io.
# It should be run in the root of wasmer like `python3 scripts/publish.py`. # It should be run in the root of wasmer like `python3 scripts/publish.py --no-dry-run`.
# By default the script executes a test run and does not publish the crates to crates.io.
# install dependencies: # install dependencies:
# pip3 install toposort # pip3 install toposort
@@ -65,7 +66,7 @@ location = {
"wasmer-wasi-experimental-io-devices": "wasi-experimental-io-devices", "wasmer-wasi-experimental-io-devices": "wasi-experimental-io-devices",
} }
dry_run = False no_dry_run = False
def get_latest_version_for_crate(crate_name: str) -> Optional[str]: def get_latest_version_for_crate(crate_name: str) -> Optional[str]:
output = subprocess.run(["cargo", "search", crate_name], capture_output=True) output = subprocess.run(["cargo", "search", crate_name], capture_output=True)
@@ -88,22 +89,22 @@ def publish_crate(crate: str):
starting_dir = os.getcwd() starting_dir = os.getcwd()
os.chdir("lib/{}".format(location[crate])) os.chdir("lib/{}".format(location[crate]))
global dry_run global no_dry_run
if dry_run: if no_dry_run:
print("In dry-run: not publishing crate `{}`".format(crate))
else:
output = subprocess.run(["cargo", "publish"]) output = subprocess.run(["cargo", "publish"])
else:
print("In dry-run: not publishing crate `{}`".format(crate))
os.chdir(starting_dir) os.chdir(starting_dir)
def main(): def main():
parser = argparse.ArgumentParser(description='Publish the Wasmer crates to crates.io') parser = argparse.ArgumentParser(description='Publish the Wasmer crates to crates.io')
parser.add_argument('--dry-run', default=False, action='store_true', parser.add_argument('--no-dry-run', default=False, action='store_true',
help='Run the script without actually publishing anything to crates.io') help='Run the script without actually publishing anything to crates.io')
args = vars(parser.parse_args()) args = vars(parser.parse_args())
global dry_run global no_dry_run
dry_run = args['dry_run'] no_dry_run = args['no_dry_run']
# get the order to publish the crates in # get the order to publish the crates in
order = list(toposort_flatten(dep_graph, sort=True)) order = list(toposort_flatten(dep_graph, sort=True))