forked from AcademySoftwareFoundation/OpenTimelineIO
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Script-assisted release process proposal (AcademySoftwareFoundation#1421
) * clean up verify license * fix licenses in place * add license to examples * freeze ci version script * lint pass * add make targets for making a release and starting a new dev cycle * update fetch_contributors so that it updates the CONTRIBUTORS.md * adding in bump version number script * dev1 stripping/appending script * add confirmation to makefile * omit the otio-version json from the packages * rename bump version target to be specific to minor version bumps * add shuffle verison map * add dev-suffix target * add test-core Co-authored-by: ssteinbach <[email protected]> Signed-off-by: Michele Spina <[email protected]>
- Loading branch information
1 parent
b0420a1
commit ff718cf
Showing
11 changed files
with
655 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"version": ["0", "15", "0"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
#!/usr/bin/env python | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright Contributors to the OpenTimelineIO project | ||
|
||
__doc__ = """Manage and apply the version in the OTIO_VERSION.json file""" | ||
|
||
import argparse | ||
import sys | ||
import json | ||
|
||
OTIO_VERSION_JSON_PATH = "OTIO_VERSION.json" | ||
|
||
|
||
def version(): | ||
with open(OTIO_VERSION_JSON_PATH, 'r') as fi: | ||
return json.load(fi)['version'] | ||
|
||
|
||
def _parsed_args(): | ||
parser = argparse.ArgumentParser( | ||
description='Fetch a list of contributors for a given GitHub repo.' | ||
) | ||
|
||
op_grp = parser.add_mutually_exclusive_group(required=True) | ||
op_grp.add_argument( | ||
"-i", | ||
"--increment", | ||
type=str, | ||
default=None, | ||
choices=("major", "minor", "patch"), | ||
help="Increment either the major or minor version number." | ||
) | ||
op_grp.add_argument( | ||
"-s", | ||
"--set", | ||
type=str, | ||
default=None, | ||
nargs=3, | ||
help="Set the version string, in the form of MAJOR MINOR PATCH" | ||
) | ||
op_grp.add_argument( | ||
"-q", | ||
"--query", | ||
default=False, | ||
action="store_true", | ||
help="Query/print the current version without changing it" | ||
) | ||
parser.add_argument( | ||
"-d", | ||
"--dryrun", | ||
default=False, | ||
action="store_true", | ||
help="Perform actions but modify no files on disk." | ||
) | ||
return parser.parse_args() | ||
|
||
|
||
def main(): | ||
args = _parsed_args() | ||
|
||
major, minor, patch = (int(v) for v in version()) | ||
|
||
if args.increment == "major": | ||
major += 1 | ||
minor = 0 | ||
patch = 0 | ||
elif args.increment == "minor": | ||
minor += 1 | ||
patch = 0 | ||
elif args.increment == "patch": | ||
patch += 1 | ||
elif args.set: | ||
major, minor, patch = args.set | ||
elif args.query: | ||
print(".".join(str(v) for v in (major, minor, patch))) | ||
return | ||
|
||
print("Setting version to: {}.{}.{}".format(major, minor, patch)) | ||
|
||
# update the OTIO_VERSION file | ||
with open(OTIO_VERSION_JSON_PATH, "w") as fo: | ||
fo.write( | ||
json.dumps({"version": [str(v) for v in (major, minor, patch)]}) | ||
) | ||
print("Updated {}".format(OTIO_VERSION_JSON_PATH)) | ||
|
||
# update the CMakeLists.txt | ||
with open("CMakeLists.txt", 'r') as fi: | ||
cmake_input = fi.read() | ||
|
||
cmake_output = [] | ||
key_map = {"MAJOR": major, "MINOR": minor, "PATCH": patch} | ||
for ln in cmake_input.split("\n"): | ||
for label, new_value in key_map.items(): | ||
if "set(OTIO_VERSION_{} \"".format(label) in ln: | ||
cmake_output.append( | ||
"set(OTIO_VERSION_{} \"{}\")".format(label, new_value) | ||
) | ||
break | ||
else: | ||
cmake_output.append(ln) | ||
|
||
with open("CMakeLists.txt", 'w') as fo: | ||
fo.write("\n".join(cmake_output)) | ||
print("Updated {}".format("CMakeLists.txt")) | ||
|
||
# update the setup.py | ||
with open("setup.py", 'r') as fi: | ||
setup_input = fi.read() | ||
|
||
setup_output = [] | ||
for ln in setup_input.split("\n"): | ||
if "\"version\": " in ln: | ||
|
||
setup_output.append( | ||
" \"version\": \"{}.{}.{}{}\",".format( | ||
major, | ||
minor, | ||
patch, | ||
(".dev1" in ln) and ".dev1" or "" | ||
) | ||
) | ||
else: | ||
setup_output.append(ln) | ||
|
||
with open("setup.py", 'w') as fo: | ||
fo.write("\n".join(setup_output)) | ||
print("Updated {}".format("setup.py")) | ||
|
||
|
||
def add_suffix(content, version): | ||
if version not in content: | ||
sys.stderr.write( | ||
"Version {} not found, suffix may have already been " | ||
"added.\n".format(version) | ||
) | ||
return False | ||
|
||
print("adding suffix, version will be: {}".format(version + ".dev1")) | ||
content.replace(version, version + ".dev1") | ||
return True | ||
|
||
|
||
def remove_suffix(content, version): | ||
if version + '.dev1' not in content: | ||
sys.stderr.write( | ||
"Version+Suffix {} not found, suffix may have already been " | ||
"removed.\n".format(version + '.dev1') | ||
) | ||
return False | ||
|
||
content.replace(version + ' .dev1', version) | ||
return True | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.