Skip to content

fix: ci

fix: ci #3

Workflow file for this run

name: Publish to PyPI
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_PAT }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Install dependencies
run: uv sync --all-extras
- name: Run tests
run: uv run pytest
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Determine version bump type
id: version
run: |
COMMIT_MSG=$(git log -1 --pretty=%B)
if echo "$COMMIT_MSG" | grep -iq "^feat!:\|BREAKING CHANGE"; then
echo "bump=major" >> $GITHUB_OUTPUT
elif echo "$COMMIT_MSG" | grep -iq "^feat:"; then
echo "bump=minor" >> $GITHUB_OUTPUT
else
echo "bump=patch" >> $GITHUB_OUTPUT
fi
- name: Bump version
run: |
# Get current version from pyproject.toml
CURRENT_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
if [ -z "$CURRENT_VERSION" ]; then
echo "Error: Could not extract current version from pyproject.toml"
exit 1
fi
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
BUMP_TYPE="${{ steps.version.outputs.bump }}"
if [ "$BUMP_TYPE" = "major" ]; then
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
elif [ "$BUMP_TYPE" = "minor" ]; then
MINOR=$((MINOR + 1))
PATCH=0
else
PATCH=$((PATCH + 1))
fi
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
# Update version in pyproject.toml - use a pattern that matches any version
sed -i 's/^version = ".*"/version = "'"$NEW_VERSION"'"/' pyproject.toml
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
echo "Bumped version from $CURRENT_VERSION to $NEW_VERSION"
- name: Commit and push version bump
run: |
git add pyproject.toml
git commit -m "chore: bump version to ${{ env.NEW_VERSION }} [skip ci]"
git push
- name: Build package
run: uv build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}