tweaking the README #19
Workflow file for this run
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: | |
| push: | |
| tags: | |
| - 'v*.*.*' # Triggers on version tags like v0.1.0, v1.2.3, etc. | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch all history for poetry-dynamic-versioning | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install poetry | |
| poetry install | |
| - name: Run Ruff linter | |
| uses: astral-sh/ruff-action@v3 | |
| with: | |
| args: check . | |
| - name: Run tests | |
| run: | | |
| poetry run pytest | |
| publish: | |
| needs: test # Only publish if tests pass | |
| runs-on: ubuntu-latest | |
| environment: main # Uses the "main" environment for deployment protection | |
| permissions: | |
| id-token: write # Required for trusted publishing | |
| contents: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch all history for poetry-dynamic-versioning | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install build tools | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build | |
| - name: Verify version from git tags | |
| run: | | |
| git describe --tags --long | |
| echo "Git tag detected above ^" | |
| - name: Build package | |
| run: | | |
| # Build using PEP 517 with poetry-dynamic-versioning backend | |
| python -m build --sdist --wheel | |
| - name: Display built packages | |
| run: | | |
| ls -lh dist/ | |
| echo "Verifying version in wheel metadata:" | |
| unzip -p dist/*.whl */METADATA | grep "^Version:" | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| verbose: true | |
| # Uses PyPI Trusted Publishers (no token needed if configured) | |
| # See: https://docs.pypi.org/trusted-publishers/ |