Skip to content

Automatic framework detection #9

Automatic framework detection

Automatic framework detection #9

Workflow file for this run

name: Bump Version, Build and Publish Python
on:
push:
branches:
- main
paths:
- 'fastapi_agents/**'
- 'pyproject.toml'
- 'uv.lock'
- '.github/workflows/build-python.yml'
workflow_dispatch:
jobs:
version_bump_and_publish:
permissions:
contents: write
actions: write
runs-on: ubuntu-latest
environment:
name: pypi
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python version from file
uses: actions/setup-python@v4
with:
python-version-file: .python-version
- name: Install uv
run: |
python3 -m pip install --upgrade pip
python3 -m pip install uv
- name: Install all dependencies for testing
run: |
uv sync --all-packages --dev --all-extras
- name: Run tests with pytest
run: |
uv run pytest
- name: Run code coverage
run: |
uv run pytest --cov=fastapi_agents tests
- name: Bump version and tag
run: |
uv run bump-version
NEW_VERSION=$(uv run get-version)
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add pyproject.toml uv.lock
git commit -m "Bump version to $NEW_VERSION"
git tag v$NEW_VERSION
- name: Push changes and tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git push origin main --tags
- name: Build and publish
env:
UV_PUBLISH_TOKEN: ${{ secrets.UV_PUBLISH_TOKEN }}
run: |
uv build
uv publish
- name: Get previous version tag
id: get_previous_version_tag
run: |
PREVIOUS_TAG=$(git describe --tags $(git rev-list --tags --skip=1 --max-count=1))
echo "PREVIOUS_TAG=$PREVIOUS_TAG" >> $GITHUB_ENV
- name: Generate release notes
id: generate_release_notes
run: |
echo "Changes in this release:" > release_notes.md
git log $(git describe --tags --abbrev=0 $(git describe --tags --abbrev=0)^)..HEAD --pretty=format:"- %s ([%h](https://github.com/${{ github.repository }}/commit/%H))" >> release_notes.md
echo "" >> release_notes.md
echo "" >> release_notes.md
echo "[View details on PyPI](https://pypi.org/project/fastapi-agents/${{ env.NEW_VERSION }}/)" >> release_notes.md
echo "" >> release_notes.md
echo "To upgrade via pip:" >> release_notes.md
echo "\`\`\`" >> release_notes.md
echo "pip install --upgrade fastapi-agents" >> release_notes.md
echo "\`\`\`" >> release_notes.md
echo "" >> release_notes.md
- name: Output release notes for debugging
run: cat release_notes.md
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.NEW_VERSION }}
release_name: Release v${{ env.NEW_VERSION }}
body_path: release_notes.md
- name: Prevent publish trigger
run: echo "Skipped publish" > skip_publish.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}