From a456b51480c4f0266d917cb741942d9e0fecfb84 Mon Sep 17 00:00:00 2001 From: Wazzabeee Date: Wed, 24 Apr 2024 22:02:27 +0200 Subject: [PATCH] fix: ci & setup insh --- .github/workflows/ci.yml | 9 +++++---- setup.py | 19 ++++++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 724461a..622e315 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,13 +57,14 @@ jobs: - name: Show latest tag run: git describe --tags --abbrev=0 - name: Bump version and push tag - uses: anothrNick/github-tag-action@1.26.0 + uses: anothrNick/github-tag-action@1.67.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + WITH_V: true DEFAULT_BUMP: auto - MAJOR_PATTERN: '^BREAKING CHANGE:' - MINOR_PATTERN: '^feat:' - PATCH_PATTERN: '^fix:' + MAJOR_STRING_TOKEN: '^BREAKING CHANGE:' + MINOR_STRING_TOKEN: '^feat:' + PATCH_STRING_TOKEN: '^fix:' - name: Set up Python uses: actions/setup-python@v2 with: diff --git a/setup.py b/setup.py index f871980..a3d8a19 100644 --- a/setup.py +++ b/setup.py @@ -9,14 +9,23 @@ def get_version(default="0.1.0"): try: - # Get the latest tag from Git version = subprocess.check_output(["git", "describe", "--tags", "--long"]).strip().decode("utf-8") logging.info(f"Original version from git: {version}") - # Convert to PEP 440 compliant version - if "-" in version: # Checking if the description is a post-release + + if "-" in version: + # Example output: v0.1.0-3-gaf8ca44 + # Convert to PEP 440 compliant version without local version identifiers parts = version.split("-") - version = parts[0] + ".post" + parts[1] + "+" + parts[2].replace("g", "") - logging.info(f"Normalized version: {version}") + base_version = parts[0] # 'v0.1.0' + commit_count = parts[1] # '3' + + # Remove leading 'v' and split version components + major, minor, patch = map(int, base_version.lstrip("v").split(".")) + + # Increment patch version by commit count + patch += int(commit_count) + version = f"{major}.{minor}.{patch}" + logging.info(f"Normalized version for PyPI: {version}") except Exception: logging.error("Failed to get version from git, using default version.", exc_info=True) version = default