mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge branch 'CI/determine_release_type_from_labels' into develop
This commit is contained in:
commit
ac1d68dcf2
2 changed files with 37 additions and 7 deletions
4
.github/workflows/prerelease.yml
vendored
4
.github/workflows/prerelease.yml
vendored
|
|
@ -20,12 +20,12 @@ jobs:
|
|||
python-version: 3.7
|
||||
|
||||
- name: Install Python requirements
|
||||
run: pip install gitpython semver
|
||||
run: pip install gitpython semver PyGithub
|
||||
|
||||
- name: 🔎 Determine next version type
|
||||
id: version_type
|
||||
run: |
|
||||
TYPE=$(python ./tools/ci_tools.py --bump)
|
||||
TYPE=$(python ./tools/ci_tools.py --bump --github_token ${{ secrets.GITHUB_TOKEN }})
|
||||
|
||||
echo ::set-output name=type::$TYPE
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,31 @@ import sys
|
|||
from semver import VersionInfo
|
||||
from git import Repo
|
||||
from optparse import OptionParser
|
||||
from github import Github
|
||||
import os
|
||||
|
||||
def get_release_type_github(Log, github_token):
|
||||
# print(Log)
|
||||
minor_labels = ["type: feature", "type: deprecated"]
|
||||
patch_labels = ["type: enhancement", "type: bug"]
|
||||
|
||||
g = Github(github_token)
|
||||
repo = g.get_repo("pypeclub/OpenPype")
|
||||
|
||||
for line in Log.splitlines():
|
||||
print(line)
|
||||
match = re.search("pull request #(\d+)", line)
|
||||
if match:
|
||||
pr_number = match.group(1)
|
||||
pr = repo.get_pull(int(pr_number))
|
||||
for label in pr.labels:
|
||||
print(label.name)
|
||||
if label.name in minor_labels:
|
||||
return ("minor")
|
||||
elif label.name in patch_labels:
|
||||
return("patch")
|
||||
return None
|
||||
|
||||
|
||||
def remove_prefix(text, prefix):
|
||||
return text[text.startswith(prefix) and len(prefix):]
|
||||
|
|
@ -36,7 +60,7 @@ def get_log_since_tag(version):
|
|||
|
||||
def release_type(log):
|
||||
regex_minor = ["feature/", "(feat)"]
|
||||
regex_patch = ["bugfix/", "fix/", "(fix)", "enhancement/"]
|
||||
regex_patch = ["bugfix/", "fix/", "(fix)", "enhancement/", "update"]
|
||||
for reg in regex_minor:
|
||||
if re.search(reg, log):
|
||||
return "minor"
|
||||
|
|
@ -135,17 +159,23 @@ def main():
|
|||
parser.add_option("-l", "--lastversion",
|
||||
dest="lastversion", action="store",
|
||||
help="work with explicit version")
|
||||
parser.add_option("-g", "--github_token",
|
||||
dest="github_token", action="store",
|
||||
help="github token")
|
||||
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if options.bump:
|
||||
last_CI, last_CI_tag = get_last_version("CI")
|
||||
last_release, last_release_tag = get_last_version("release")
|
||||
bump_type_CI = release_type(get_log_since_tag(last_CI_tag))
|
||||
bump_type_release = release_type(get_log_since_tag(last_release_tag))
|
||||
if bump_type_CI is None or bump_type_release is None:
|
||||
bump_type_release = get_release_type_github(
|
||||
get_log_since_tag(last_release_tag),
|
||||
options.github_token
|
||||
)
|
||||
if bump_type_release is None:
|
||||
print("skip")
|
||||
else:
|
||||
print(bump_type_release)
|
||||
|
||||
if options.nightly:
|
||||
next_tag_v = calculate_next_nightly()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue