From ea98fd3215f55f81818897181a0dd09a4ac51547 Mon Sep 17 00:00:00 2001 From: Petro Tiurin Date: Fri, 14 Jan 2022 09:44:28 +0000 Subject: [PATCH 1/2] refactor: Remove release from setup.cfg --- setup.cfg | 5 ----- 1 file changed, 5 deletions(-) diff --git a/setup.cfg b/setup.cfg index 22ee377d27a..1dd26d0e821 100755 --- a/setup.cfg +++ b/setup.cfg @@ -48,11 +48,6 @@ dev = pytest-cov==3.0.0 pytest-httpx==0.13.0 pytest-mock==3.6.1 -release = - argparse - build - semver - twine [options.package_data] firebolt = py.typed From b60cddbc1acbf62ca635c91eadd9547bdb8fdbe3 Mon Sep 17 00:00:00 2001 From: Petro Tiurin Date: Mon, 17 Jan 2022 15:59:16 +0000 Subject: [PATCH 2/2] Removing version tag script --- ci/generate_version_tag.py | 76 -------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 ci/generate_version_tag.py diff --git a/ci/generate_version_tag.py b/ci/generate_version_tag.py deleted file mode 100644 index 741b1ea8798..00000000000 --- a/ci/generate_version_tag.py +++ /dev/null @@ -1,76 +0,0 @@ -"""Version Tag Generator - -This script is designed to parse a list of commits written according to the -conventional commit guidelines https://www.conventionalcommits.org/en/v1.0.0/. -Based on the type of each commit either a patch or a minor version is updated -from the original tag provided with respect to semantic versioning -https://semver.org/. - -If a script encounters a breaking change in the changelog it will throw an error -in order to make sure major releases are expected and explicit. There is a parameter -passed to the script to explicitly trigger a major version increase. - -Prerelease tags (e.g. -alpha) are passed manually, if required by the build state. -They will be appended to the next incremented version. A run when the previous version -provided was a pre-release would finalize it e.g. (1.0.1-alpha -> 1.0.1) -""" - -import argparse -from typing import Tuple - -import semver - - -def main(changes: str, old_tag: str, prerelease_tag: str, major_release: bool): - """ - Generate new version tag. - - Args: - changes: list of newline-separated change titles - old_tag: previous version tag e.g. 1.0.1 - prerelease_tag: add a pre-relrease tag to the next version e.g -alpha - major_release: boolean to override and trigger a major release - """ - ver = semver.VersionInfo.parse(old_tag) - if major_release: - new_ver = ver.bump_major() - else: - if not changes: - raise Exception("No changes since the last release!") - # Breaking changes are of form !: - # To avoid automatically publishing major version they need to be - # explicitly specified - breaking = [c for c in changes.split("\n") if c.split(":", 1)[0].endswith("!")] - if breaking: - raise Exception( - "Breaking changes detected, please make sure " - "to provide an override for this." - ) - - # If previous version contained a pre-release tag - if ver.prerelease: - new_ver = ver.finalize_version() - else: - # Enhancements bump minor version while anything else is considered a patch - enhancements = [c for c in changes.split("\n") if c.startswith("feat:")] - new_ver = ver.bump_minor() if enhancements else ver.bump_patch() - if prerelease_tag: - new_ver = new_ver.bump_prerelease(prerelease_tag) - print(new_ver) - - -def parse_arguments() -> Tuple[str, str, str, bool]: - parser = argparse.ArgumentParser( - description="Determine the next package version based on conventional commits." - ) - parser.add_argument("changes", help="Output of git log -pretty=format:%s") - parser.add_argument("old_tag", help="Previous semantic version tag") - parser.add_argument("--prerelease_tag", help="For alpha and pre-releases") - parser.add_argument("--major_release", help="Override and bump the major version") - args = parser.parse_args() - return args.changes, args.old_tag, args.prerelease_tag, bool(args.major_release) - - -if __name__ == "__main__": - changes, old_tag, prerelease_tag, major_release = parse_arguments() - main(changes, old_tag, prerelease_tag, major_release)