Publish Dev Build #30
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 Dev Build | |
| on: | |
| workflow_run: | |
| workflows: ["CI"] | |
| types: | |
| - completed | |
| branches: [ main ] | |
| workflow_dispatch: # Allow manual triggering for testing | |
| jobs: | |
| build-and-publish: | |
| name: Build and publish dev build to PyPI | |
| runs-on: ubuntu-latest | |
| # Only run if CI succeeded (or manual trigger) | |
| if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Calculate and set dev version | |
| run: | | |
| # Read base version from pyproject.toml | |
| BASE_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/') | |
| # Create dev version using GitHub run number | |
| DEV_VERSION="${BASE_VERSION}.dev${{ github.run_number }}" | |
| echo "Base version: $BASE_VERSION" | |
| echo "Dev version: $DEV_VERSION" | |
| # Update pyproject.toml with dev version (temporary, not committed) | |
| sed -i "s/^version = \".*\"/version = \"$DEV_VERSION\"/" pyproject.toml | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| - name: Build package | |
| run: | | |
| python -m build | |
| - name: Publish to PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| run: | | |
| twine upload --skip-existing dist/* |