|
| 1 | +name: Publish to PyPI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v[0-9]*' |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: pypi-publish-${{ github.ref_name }} |
| 10 | + cancel-in-progress: false |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + name: Build distribution |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 21 | + |
| 22 | + - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 |
| 23 | + with: |
| 24 | + python-version: '3.12' |
| 25 | + |
| 26 | + - name: Install build tooling |
| 27 | + run: python -m pip install --upgrade build twine |
| 28 | + |
| 29 | + - name: Verify tag matches pyproject version |
| 30 | + run: | |
| 31 | + # Release tags must start with `v` followed by a PEP 440 version (e.g. v1.2.3, v1.2.3a1). |
| 32 | + if [[ ! "$GITHUB_REF_NAME" =~ ^v[0-9] ]]; then |
| 33 | + echo "Release tag '$GITHUB_REF_NAME' must start with 'v' followed by a digit (e.g. v1.0.0)" >&2 |
| 34 | + exit 1 |
| 35 | + fi |
| 36 | + tag="${GITHUB_REF_NAME#v}" |
| 37 | + pkg_version=$(python -c "import tomllib,pathlib; print(tomllib.loads(pathlib.Path('pyproject.toml').read_text())['project']['version'])") |
| 38 | + if [ "$tag" != "$pkg_version" ]; then |
| 39 | + echo "Release tag ($tag) does not match pyproject.toml version ($pkg_version)" >&2 |
| 40 | + exit 1 |
| 41 | + fi |
| 42 | +
|
| 43 | + - name: Build sdist and wheel |
| 44 | + run: python -m build |
| 45 | + |
| 46 | + - name: Check distribution metadata |
| 47 | + run: python -m twine check --strict dist/* |
| 48 | + |
| 49 | + - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5 |
| 50 | + with: |
| 51 | + name: dist |
| 52 | + path: dist/ |
| 53 | + |
| 54 | + publish: |
| 55 | + name: Publish to PyPI |
| 56 | + needs: build |
| 57 | + runs-on: ubuntu-latest |
| 58 | + environment: |
| 59 | + name: pypi |
| 60 | + url: https://pypi.org/p/hotdata-marimo |
| 61 | + permissions: |
| 62 | + id-token: write |
| 63 | + steps: |
| 64 | + - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5 |
| 65 | + with: |
| 66 | + name: dist |
| 67 | + path: dist/ |
| 68 | + |
| 69 | + - name: Publish via Trusted Publishing |
| 70 | + uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 |
0 commit comments