* Add release version checking

* Format

* Formatting, line endings were messed up
This commit is contained in:
Logan Adams 2023-09-14 10:28:25 -07:00 коммит произвёл GitHub
Родитель 11aa880efe
Коммит b5977d4158
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 36 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,29 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0
# DeepSpeed Team
import argparse
from packaging import version as pkg_version
parser = argparse.ArgumentParser()
parser.add_argument("--new_version", type=str, help="The new version being published.")
args = parser.parse_args()
new_version = pkg_version.parse(args.new_version)
with open('./version.txt') as fd:
current_version = pkg_version.parse(fd.read())
# Valid version are those where the major/minor/micro are incremented by no more than one from the existing release, and the less significant values are reset to 0.
valid_major_update = pkg_version.Version(f'{current_version.major + 1}.0.0')
valid_minor_update = pkg_version.Version(f'{current_version.major}.{current_version.minor + 1}.0')
valid_micro_update = pkg_version.Version(
f'{current_version.major}.{current_version.minor}.{current_version.micro + 1}')
valid_versions = [valid_major_update, valid_minor_update, valid_micro_update]
if new_version not in valid_versions:
raise Exception(f'{new_version} is an invalid version. Valid versions are {valid_versions}.\n')

Просмотреть файл

@ -25,6 +25,13 @@ if [ "${version}" != `cat version.txt` ]; then
exit 1
fi
echo "checking that the version is valid"
python release/check_release_version.py --new_version ${version}
if [ $? != 0 ]; then
echo 'please check the version number selected'
exit 1
fi
python -c "import twine"
if [ $? != 0 ]; then
echo 'please install twine via pip'