Skip to content

Commit

Permalink
fix: ci & setup insh
Browse files Browse the repository at this point in the history
  • Loading branch information
Wazzabeee committed Apr 24, 2024
1 parent af8ca44 commit a456b51
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 14 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a456b51

Please sign in to comment.