Merge pull request #8 from escoffier-labs/chore/brigade-release-metadata #8
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 | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| environment: pypi | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Verify tag matches package version | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: | | |
| set -e | |
| tag_version="${GITHUB_REF_NAME#v}" | |
| pkg_version=$(python -c "import tomllib,sys; print(tomllib.loads(open('pyproject.toml','rb').read().decode())['project']['version'])") | |
| echo "tag=$tag_version pkg=$pkg_version" | |
| if [ "$tag_version" != "$pkg_version" ]; then | |
| echo "::error::tag $tag_version does not match pyproject.toml version $pkg_version" | |
| exit 1 | |
| fi | |
| - name: Install build tooling | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install build twine | |
| - name: Build sdist + wheel | |
| run: python -m build | |
| - name: Check distributions | |
| run: python -m twine check dist/* | |
| - name: Publish to PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| run: python -m twine upload dist/* |