Version 0.1.2 #5
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.org | |
| on: | |
| release: | |
| types: [published] | |
| # Allow manual runs if needed | |
| workflow_dispatch: | |
| # Grant minimal permissions; include id-token for OIDC if enabled on PyPI | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| pypi: | |
| name: Build and Publish | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.12' | |
| cache: 'pip' | |
| - name: Install build backend | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install build | |
| - name: Verify tag matches package version | |
| shell: bash | |
| run: | | |
| TAG="${{ github.event.release.tag_name }}" | |
| echo "Release tag: $TAG" | |
| PKG_VERSION=$(python - <<'PY' | |
| import re, pathlib | |
| init = pathlib.Path('braintrace/__init__.py').read_text(encoding='utf-8') | |
| m = re.search(r"__version__\s*=\s*\"([^\"]+)\"", init) | |
| print(m.group(1) if m else '') | |
| PY | |
| ) | |
| echo "Package version: ${PKG_VERSION}" | |
| TAG_STRIPPED=${TAG#v} | |
| if [[ -z "$PKG_VERSION" ]]; then | |
| echo "Could not determine package version from braintrace/__init__.py" >&2 | |
| exit 1 | |
| fi | |
| if [[ "$TAG_STRIPPED" != "$PKG_VERSION" ]]; then | |
| echo "Tag ($TAG) does not match package version ($PKG_VERSION)" >&2 | |
| exit 1 | |
| fi | |
| - name: Build sdist and wheel | |
| run: | | |
| python -m build | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: dist-artifacts | |
| path: dist/* | |
| - name: Publish package to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| # For API token auth: keep using PYPI_API_TOKEN secret | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| # If using OIDC Trusted Publishers on PyPI, omit password above. | |
| # You can also enable skip-existing to avoid failures on re-publish attempts | |
| skip-existing: true |