Publish to PyPI #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish to PyPI | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version_bump: | |
| description: 'Version bump type' | |
| required: true | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| - name: Get current version | |
| id: current_version | |
| run: | | |
| CURRENT_VERSION=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])") | |
| echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| echo "Current version: $CURRENT_VERSION" | |
| - name: Bump version | |
| id: bump_version | |
| run: | | |
| CURRENT="${{ steps.current_version.outputs.version }}" | |
| IFS='.' read -r major minor patch <<< "$CURRENT" | |
| case "${{ github.event.inputs.version_bump }}" in | |
| major) | |
| NEW_VERSION="$((major + 1)).0.0" | |
| ;; | |
| minor) | |
| NEW_VERSION="${major}.$((minor + 1)).0" | |
| ;; | |
| patch) | |
| NEW_VERSION="${major}.${minor}.$((patch + 1))" | |
| ;; | |
| esac | |
| echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| echo "Bumping version: $CURRENT -> $NEW_VERSION" | |
| - name: Update version in pyproject.toml | |
| run: | | |
| sed -i 's/^version = ".*"/version = "${{ steps.bump_version.outputs.new_version }}"/' pyproject.toml | |
| cat pyproject.toml | grep "^version" | |
| - name: Build package | |
| run: | | |
| uv build | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_TOKEN }} | |
| print-hash: true | |
| skip-existing: true | |
| - name: Commit version bump | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add pyproject.toml | |
| git commit -m "Bump version to ${{ steps.bump_version.outputs.new_version }}" | |
| git push | |
| - name: Create GitHub Release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ steps.bump_version.outputs.new_version }} | |
| release_name: v${{ steps.bump_version.outputs.new_version }} | |
| body: | | |
| Release version ${{ steps.bump_version.outputs.new_version }} | |
| Published to PyPI: https://pypi.org/project/sqlmesh-openlineage/${{ steps.bump_version.outputs.new_version }}/ | |
| draft: false | |
| prerelease: false |