|
| 1 | +name: Publish to PyPI |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version_bump: |
| 7 | + description: 'Version bump type' |
| 8 | + required: true |
| 9 | + type: choice |
| 10 | + options: |
| 11 | + - patch |
| 12 | + - minor |
| 13 | + - major |
| 14 | + |
| 15 | +jobs: |
| 16 | + publish: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + permissions: |
| 19 | + contents: write |
| 20 | + id-token: write # For PyPI trusted publishing |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 27 | + |
| 28 | + - name: Set up Python |
| 29 | + uses: actions/setup-python@v5 |
| 30 | + with: |
| 31 | + python-version: '3.11' |
| 32 | + |
| 33 | + - name: Install uv |
| 34 | + uses: astral-sh/setup-uv@v4 |
| 35 | + |
| 36 | + - name: Get current version |
| 37 | + id: current_version |
| 38 | + run: | |
| 39 | + CURRENT_VERSION=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])") |
| 40 | + echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT |
| 41 | + echo "Current version: $CURRENT_VERSION" |
| 42 | +
|
| 43 | + - name: Bump version |
| 44 | + id: bump_version |
| 45 | + run: | |
| 46 | + CURRENT="${{ steps.current_version.outputs.version }}" |
| 47 | + IFS='.' read -r major minor patch <<< "$CURRENT" |
| 48 | +
|
| 49 | + case "${{ github.event.inputs.version_bump }}" in |
| 50 | + major) |
| 51 | + NEW_VERSION="$((major + 1)).0.0" |
| 52 | + ;; |
| 53 | + minor) |
| 54 | + NEW_VERSION="${major}.$((minor + 1)).0" |
| 55 | + ;; |
| 56 | + patch) |
| 57 | + NEW_VERSION="${major}.${minor}.$((patch + 1))" |
| 58 | + ;; |
| 59 | + esac |
| 60 | +
|
| 61 | + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT |
| 62 | + echo "Bumping version: $CURRENT -> $NEW_VERSION" |
| 63 | +
|
| 64 | + - name: Update version in pyproject.toml |
| 65 | + run: | |
| 66 | + sed -i 's/^version = ".*"/version = "${{ steps.bump_version.outputs.new_version }}"/' pyproject.toml |
| 67 | + cat pyproject.toml | grep "^version" |
| 68 | +
|
| 69 | + - name: Build package |
| 70 | + run: | |
| 71 | + uv build |
| 72 | +
|
| 73 | + - name: Publish to PyPI |
| 74 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 75 | + with: |
| 76 | + password: ${{ secrets.PYPI_TOKEN }} |
| 77 | + print-hash: true |
| 78 | + |
| 79 | + - name: Commit version bump |
| 80 | + run: | |
| 81 | + git config user.name "github-actions[bot]" |
| 82 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 83 | + git add pyproject.toml |
| 84 | + git commit -m "Bump version to ${{ steps.bump_version.outputs.new_version }}" |
| 85 | + git push |
| 86 | +
|
| 87 | + - name: Create GitHub Release |
| 88 | + uses: actions/create-release@v1 |
| 89 | + env: |
| 90 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 91 | + with: |
| 92 | + tag_name: v${{ steps.bump_version.outputs.new_version }} |
| 93 | + release_name: v${{ steps.bump_version.outputs.new_version }} |
| 94 | + body: | |
| 95 | + Release version ${{ steps.bump_version.outputs.new_version }} |
| 96 | +
|
| 97 | + Published to PyPI: https://pypi.org/project/sqlmesh-openlineage/${{ steps.bump_version.outputs.new_version }}/ |
| 98 | + draft: false |
| 99 | + prerelease: false |
0 commit comments