add dry run and more careful package*.json updates
import argparse
+import json
from os.path import join
import re
from subprocess import CalledProcessError, check_output, STDOUT
@@ -306,15 +307,18 @@ def commit(filename, version):
def update_bokehjs_versions():
- filenames = [
+ regex_filenames = [
'bokehjs/src/lib/version.ts',
+ ]
+
+ json_filenames = [
'bokehjs/package.json',
'bokehjs/package-lock.json',
]
pat = r"(release|version)([\" ][:=] [\"\'])" + CONFIG.last_any_version + "([\"\'])"
- for filename in filenames:
+ for filename in regex_filenames:
path = join(CONFIG.top_dir, filename)
with open(path) as f:
text = f.read()
@@ -335,6 +339,20 @@ def update_bokehjs_versions():
passed("Updated version from %r to %r in file %r" % (CONFIG.last_any_version, CONFIG.new_version, filename))
commit(filename, CONFIG.new_version)
+ for filename in json_filenames:
+ path = join(CONFIG.top_dir, filename)
+ content = json.load(open(path))
+ try:
+ content['version'] = CONFIG.new_version
+ with open(path, "w") as f:
+ json.dump(content, f, indent=2)
+ f.write("\n")
+ except Exception as e:
+ failed("Unable to write new version to file %r" % filename, str(e).split("\n"))
+ else:
+ passed("Updated version from %r to %r in file %r" % (CONFIG.last_any_version, CONFIG.new_version, filename))
+ commit(filename, CONFIG.new_version)
+
def update_docs_versions():
# Update all_versions.txt
@@ -438,6 +456,10 @@ if __name__ == '__main__':
type=str,
nargs=1,
help='The new version number for this release')
+ parser.add_argument('--dry-run',
+ action="store_true",
+ help='Set to perform a dry-run (no commits)')
+
args = parser.parse_args()
new_version = args.version[0]
@@ -451,8 +473,12 @@ if __name__ == '__main__':
check_py3()
check_git()
check_maintainers()
+ if not args.dry_run:
check_repo()
check_checkout()
+ else:
+ print(blue("[SKIP] ") + "Skipping repo and checkout checks for dry run")
+
try:
CONFIG.new_version = args.version[0]
@@ -509,6 +535,10 @@ if __name__ == '__main__':
show_updates()
+ if args.dry_run:
+ banner(yellow, "{:^80}".format("Bokeh %r release deployment: DRY RUN (local checkout may be dirty)" % CONFIG.new_version))
+ sys.exit(1)
+
confirm("Merge release branch and push these changes? [LAST CHANCE TO ABORT]")
success = merge_and_push()
