Publish to PyPI #2
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 | |
| # Publishes smartthings-local to PyPI on a version tag (v1.2.3). | |
| # Uses PyPI Trusted Publishing (OIDC) — no API token is stored in the repo. | |
| # One-time setup on PyPI: add a trusted publisher for this repo pointing at | |
| # workflow `publish.yml` and environment `pypi`. | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| jobs: | |
| build: | |
| name: Build sdist + wheel | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 # hatch-vcs needs full history + tags to derive the version | |
| - uses: actions/setup-python@v7 | |
| with: | |
| python-version: "3.12" | |
| - run: python -m pip install --upgrade build | |
| - run: python -m build | |
| - name: Verify the built version matches the tag | |
| run: | | |
| ls -l dist/ | |
| version="${GITHUB_REF_NAME#v}" | |
| if ! ls dist/ | grep -q "smartthings_local-${version}"; then | |
| echo "Built artifacts do not match tag version ${version}"; exit 1 | |
| fi | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: dist | |
| path: dist/ | |
| publish: | |
| name: Publish to PyPI | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: pypi | |
| permissions: | |
| id-token: write # required for Trusted Publishing (OIDC) | |
| steps: | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - uses: pypa/gh-action-pypi-publish@release/v1 |