Simplify version_check script (#3152)

* Simplify version_check script

- Allow 'x.x.x' or 'x.x.x dev' on master branch (because we need to be able to tag releases from master)
- Remove duplicate regex checks
- Fix docstrings

* Run version check on all branches

- Will ensure we cannot merge in duplicate tags

* Add requests package

* Add requests package
This commit is contained in:
Oliver 2022-06-07 08:57:51 +10:00 committed by GitHub
parent 6b038d85b6
commit 5870b21a91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 15 deletions

View File

@ -35,6 +35,7 @@ jobs:
uses: actions/checkout@v2
- name: Version Check
run: |
pip install requests
python3 ci/version_check.py
echo "git_commit_hash=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "git_commit_date=$(git show -s --format=%ci)" >> $GITHUB_ENV

View File

@ -91,6 +91,10 @@ jobs:
cache: 'pip'
- name: Run pre-commit Checks
uses: pre-commit/action@v2.0.3
- name: Check Version
run: |
pip install requests
python3 ci/version_check.py
python:
name: Tests - inventree-python

View File

@ -114,7 +114,7 @@ if __name__ == '__main__':
docker_tags = None
if GITHUB_REF_TYPE == 'tag':
# GITHUB_REF should be of th eform /refs/heads/<tag>
# GITHUB_REF should be of the form /refs/heads/<tag>
version_tag = GITHUB_REF.split('/')[-1]
print(f"Checking requirements for tagged release - '{version_tag}':")
@ -122,8 +122,6 @@ if __name__ == '__main__':
print(f"Version number '{version}' does not match tag '{version_tag}'")
sys.exit
# TODO: Check if there is already a release with this tag!
if highest_release:
docker_tags = [version_tag, 'stable']
else:
@ -131,17 +129,6 @@ if __name__ == '__main__':
elif GITHUB_REF_TYPE == 'branch':
# Otherwise we know we are targetting the 'master' branch
print("Checking requirements for 'master' development branch:")
pattern = r"^\d+(\.\d+)+ dev$"
result = re.match(pattern, version)
if result is None:
print(f"Version number '{version}' does not match required pattern for development branch")
sys.exit(1)
else:
print(f"Version number '{version}' matches development branch")
docker_tags = ['latest']
else:
@ -153,7 +140,7 @@ if __name__ == '__main__':
sys.exit(1)
if docker_tags is None:
print("Docker tag could not be determined")
print("Docker tags could not be determined")
sys.exit(1)
print(f"Version check passed for '{version}'!")