diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6bd1a55..e758f3f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,8 @@ name: CI on: push: pull_request: + release: + types: [published] workflow_dispatch: permissions: @@ -77,3 +79,30 @@ jobs: name: corpus-report path: ${{ runner.temp }}/corpus-report/ if-no-files-found: error + + publish: + name: Publish to PyPI + needs: [test, corpus-regression] + runs-on: ubuntu-latest + if: github.event_name == 'release' + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.14" + - name: Install build tools + run: python -m pip install --upgrade pip build twine + - name: Verify release version + run: | + package_version="$(python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')" + test "v${package_version}" = "${GITHUB_REF_NAME}" + - name: Build distributions + run: python -m build + - name: Check distributions + run: twine check dist/* + - name: Publish to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: twine upload dist/* --verbose