Skip to content

Commit

Permalink
Fix: handle difference releases alfa vs master
Browse files Browse the repository at this point in the history
  • Loading branch information
Caparrini committed Oct 27, 2024
1 parent f769901 commit e43d76e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install build
- name: Set Version Suffix Based on Branch
run: |
if [ "${GITHUB_REF_NAME}" == "master" ] || [ "${GITHUB_REF_NAME}" == "main" ]; then
echo "VERSION_SUFFIX=" >> $GITHUB_ENV
else
echo "VERSION_SUFFIX=-${GITHUB_REF_NAME}" >> $GITHUB_ENV
fi
- name: Build a binary wheel and a source tarball
run: |
python -m build --sdist --wheel --outdir dist/
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.0
0.9.0.0
13 changes: 12 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@

# Path to the VERSION file
version_file = pathlib.Path(__file__).parent.parent / "VERSION"
version = version_file.read_text().strip()
base_version = version_file.read_text().strip()
# Check if we are on Read the Docs
on_rtd = os.getenv("READTHEDOCS") == "True"
# Determine suffix based on the branch
suffix = ""
if on_rtd:
branch = os.getenv("READTHEDOCS_VERSION", "main")
if branch in ["main", "master"]:
suffix = ""
else:
suffix = f"-{branch}"
version = f'{base_version}{suffix}'

sys.path.insert(0, os.path.abspath('..'))

Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Always prefer setuptools over distutils
from setuptools import setup, find_packages
import pathlib
import os

here = pathlib.Path(__file__).parent.resolve()
long_description = (here / "README.md").read_text(encoding="utf-8")
version = (here / "VERSION").read_text().strip()
base_version = (here / "VERSION").read_text().strip()
suffix = os.getenv("VERSION_SUFFIX", "")
version = f"{base_version}{suffix}"



Expand Down

0 comments on commit e43d76e

Please sign in to comment.