fix(ci): read pyproject version with tomllib; normalize *.toml to LF #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: Release | |
| on: | |
| push: | |
| tags: ["v*"] | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install build tooling | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| - name: Verify tag matches pyproject version | |
| run: | | |
| set -euo pipefail | |
| TAG="${GITHUB_REF#refs/tags/v}" | |
| TAG="${TAG//$'\r'/}" | |
| # Read [project].version with tomllib (stdlib on 3.11+). Avoids CRLF / grep picking the wrong line. | |
| VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])") | |
| if [ "$TAG" != "$VERSION" ]; then | |
| echo "Tag v$TAG does not match pyproject.toml [project] version $VERSION" | |
| exit 1 | |
| fi | |
| - name: Build | |
| run: python -m build | |
| - name: Check with twine | |
| run: twine check dist/* | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |