ci(workflows): update commands to use unified bml CLI #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 | |
| on: | |
| workflow_dispatch: | |
| push: | |
| tags: | |
| - 'v*' | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check tag matches pyproject.toml version | |
| id: check-version | |
| run: | | |
| TAG_VERSION="${GITHUB_REF##*/}" | |
| FILE_VERSION=$(grep -E '^version\s*=\s*' pyproject.toml | head -n1 | sed -E 's/version\s*=\s*"([^"]+)"/\1/') | |
| if [[ "$TAG_VERSION" =~ ^v ]]; then | |
| TAG_VERSION="${TAG_VERSION:1}" | |
| fi | |
| echo "Tag version: $TAG_VERSION" | |
| echo "File version: $FILE_VERSION" | |
| if [ "$TAG_VERSION" != "$FILE_VERSION" ]; then | |
| echo "::error::Tag version ($TAG_VERSION) does not match pyproject.toml version ($FILE_VERSION)" | |
| exit 1 | |
| fi | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| - name: Build package | |
| run: | | |
| python -m build | |
| - name: Publish to PyPI | |
| env: | |
| TWINE_API_KEY: ${{ secrets.PYPI_API_TOKEN }} | |
| run: | | |
| twine upload --non-interactive -u __token__ -p "$TWINE_API_KEY" dist/* |