Skip to content

Commit

Permalink
deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
kerodekroma committed Aug 12, 2024
1 parent efe500c commit 2ccb6e6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,39 @@ jobs:
- name: Generate Git Tag
id: generate_tag
run: |
set -e # Exit immediately if a command exits with a non-zero status
VERSION_PREFIX="v"
VERSION_MAJOR_MINOR="1.0"
# Fetch all tags from the remote repository
git fetch --tags
# Get the latest patch version for the given major.minor version
VERSION_PATCH=$(git tag --list "${VERSION_PREFIX}${VERSION_MAJOR_MINOR}.*" --sort=-version:refname | head -n 1 | grep -oE '[0-9]+$')
if [ $? -ne 0 ]; then
echo "Failed to retrieve the latest patch version."
VERSION_PATCH=0
fi
# Increment the patch version or start at 0 if none exists
if [ -z "$VERSION_PATCH" ]; then
VERSION_PATCH=0
else
VERSION_PATCH=$((VERSION_PATCH + 1))
fi
PYPI_TAG="${VERSION_MAJOR_MINOR}.${VERSION_PATCH}"
NEW_TAG="${VERSION_PREFIX}${PYPI_TAG}"
echo "Generated new tag: $NEW_TAG"
echo "Generated new PYPI tag: $PYPI_TAG"
# Set environment variables for use in later steps
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV
echo "PYPI_TAG=$PYPI_TAG" >> $GITHUB_ENV
# Replace VERSION_PLACEHOLDER in setup.py with the new version
sed -i "s/{{VERSION_PLACEHOLDER}}/${PYPI_TAG}/g" setup.py
- name: Build package
Expand Down

0 comments on commit 2ccb6e6

Please sign in to comment.