-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7354ff1
commit b23797e
Showing
34 changed files
with
154 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Script to calculate the next version.""" | ||
import subprocess | ||
import sys | ||
|
||
from git import Repo | ||
from git_conventional_version.api import Api | ||
import semantic_version | ||
import semver | ||
|
||
|
||
def get_last_beta_tag(): | ||
"""Get the last beta tag from GIT.""" | ||
command = ["git", "describe", "--tags", "--abbrev=0", "--match", "*beta*"] | ||
output = subprocess.check_output(command).decode().strip() | ||
return output | ||
|
||
|
||
def get_version_without_prerelease(version): | ||
"""Get SemVer version without prerelease suffix.""" | ||
semver = semantic_version.Version(version) | ||
return str(semver.major) + "." + str(semver.minor) + "." + str(semver.patch) | ||
|
||
|
||
api = Api(repo=Repo(search_parent_directories=True)) | ||
last_beta_tag = get_last_beta_tag() | ||
new_tag = api.get_new_version(type="final") | ||
last_beta_tag_without_prerelease = get_version_without_prerelease(last_beta_tag) | ||
ver = semver.Version.parse(last_beta_tag) | ||
if new_tag != last_beta_tag_without_prerelease: | ||
new_version = f"{new_tag}-beta.1" | ||
else: | ||
new_version = ver.bump_prerelease() | ||
print(new_version) | ||
sys.exit(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"""Script to extract the labels for a PR.""" | ||
import os | ||
import re | ||
import sys | ||
|
||
|
||
def extract_semver_types(commit_messages): | ||
"""Extract SemVer types.""" | ||
types = [] | ||
for message in commit_messages: | ||
pattern = r"^(feat|fix|chore|docs|style|refactor|perf|test)(?:\(.+?\))?:\s(.+)$" | ||
match = re.match(pattern, message) | ||
if match and match.group(1) not in types: | ||
types.append(match.group(1)) | ||
return types | ||
|
||
|
||
def get_semver_level(commit_messages): | ||
"""Extract SemVer level.""" | ||
major_keywords = ["breaking change", "major"] | ||
minor_keywords = ["feat", "minor"] | ||
for message in commit_messages: | ||
if any(keyword in message for keyword in major_keywords): | ||
return "major" | ||
for message in commit_messages: | ||
if any(keyword in message for keyword in minor_keywords): | ||
return "minor" | ||
return "patch" | ||
|
||
|
||
file_path = "COMMIT_MESSAGES" | ||
if os.path.exists(file_path): | ||
with open(file_path) as file: | ||
messages = [] | ||
for line in file: | ||
messages.append(line.strip()) | ||
semver_level = get_semver_level(messages) | ||
types = extract_semver_types(messages) | ||
types.append(semver_level) | ||
print(types) | ||
sys.exit(0) | ||
else: | ||
sys.exit(f"ERROR: {file_path} does not exist") |
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.