Merge pull request #36 from sonilo-ai/release/0.15.3-cli-0.14.3 #22
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: | |
| workflow_dispatch: | |
| push: | |
| tags: ["v*"] | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| # PyPI Trusted Publishing (OIDC). No PYPI_TOKEN secret needed. | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - run: pip install -e ".[dev]" build | |
| - run: pytest | |
| - name: Verify tag matches pyproject version | |
| if: github.ref_type == 'tag' | |
| run: | | |
| TAG_VERSION="${GITHUB_REF_NAME#v}" | |
| PKG_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])") | |
| if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then | |
| echo "Tag version ($TAG_VERSION) does not match pyproject version ($PKG_VERSION)" | |
| exit 1 | |
| fi | |
| - run: python -m build | |
| - name: Publish to PyPI | |
| # Authenticates via OIDC Trusted Publishing — configured as a pending | |
| # publisher for project `sonilo` (repo sonilo-python, workflow publish.yml). | |
| # Tag refs only: a workflow_dispatch on a branch runs tests/build but | |
| # never publishes. To retry a failed publish, dispatch on the tag: | |
| # gh workflow run publish.yml --ref vX.Y.Z | |
| if: github.ref_type == 'tag' | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| skip-existing: true |