Skip to content

Commit

Permalink
Retrieve the latest git tag in GitHub Actions workflow and update ver…
Browse files Browse the repository at this point in the history
…sioning logic in setup.py for improved tag handling
  • Loading branch information
royshil committed Nov 14, 2024
1 parent c764a7f commit 48d455c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ jobs:
python -m pip install --upgrade pip
pip install numpy cmake wheel setuptools build cibuildwheel
- name: Get latest tag
id: get_tag
run: |
echo "tag=$(git describe --tags --abbrev=1)" >> $GITHUB_OUTPUT
shell: bash

- name: Build wheel
env:
CIBW_ENVIRONMENT: "SIMPLER_WHISPER_ACCELERATION='${{ matrix.acceleration }}' MAOSX_DEPLOYMENT_TARGET=10.13"
Expand All @@ -44,7 +50,7 @@ jobs:
CIBW_ARCHS_LINUX: "x86_64"
CIBW_SKIP: "*-musllinux_*"
CIBW_BUILD_VERBOSITY: 1
SIMPLER_WHISPER_VERSION: ${{ github.ref_name }}
SIMPLER_WHISPER_VERSION: ${{ steps.get_tag.outputs.tag }}
run: |
python -m cibuildwheel --output-dir wheelhouse
Expand Down
23 changes: 11 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,17 @@ def build_extension(self, ext):

def get_latest_git_tag():
tag = os.environ.get("SIMPLER_WHISPER_VERSION")
if tag:
return tag
try:
tag = subprocess.check_output(
["git", "describe", "--tags"], encoding="utf-8"
).strip()
parts = tag.split("-")
if len(parts) == 3:
return f"{parts[0]}-dev{parts[1]}"
return tag
except subprocess.CalledProcessError:
return "0.0.0-dev"
if not tag:
try:
tag = subprocess.check_output(
["git", "describe", "--tags"], encoding="utf-8"
).strip()
except subprocess.CalledProcessError:
return "0.0.0-dev"
parts = tag.split("-")
if len(parts) == 3:
return f"{parts[0]}-dev{parts[1]}"
return tag


setup(
Expand Down

0 comments on commit 48d455c

Please sign in to comment.