Commit f747c98f authored by Boris Glimcher's avatar Boris Glimcher Committed by Jim Harris
Browse files

ci: publish spdk python to pypi

As agreed on TSC meeting we will start publishing
the python package to PYPI registry.

This patch by design is not touching anything else
except the github action workflow.
See what's Next below.

The version of the package is following SPDK version
for example, 24.09, 24.05 or 24.01 as example.

See examples from https://github.com/spdk/spdk/tags



The publish is using latest modern PYPI guidlines
using "Trusted Publisher" configurations.

The installation post publishing will look like this:

```
pip install --user spdk==24.05
```

For managing multiple version, as usual in python,
continue using virtual environments and containers.

In the following patches we will:
- fix metadata via pyproject toml
- introduce optional dependencies `pip install spdk[sma]`

Change-Id: Ib4547b586ee4fe2f77145153b31ed32ad86b2884
Signed-off-by: default avatarBoris Glimcher <Boris.Glimcher@emc.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/25754


Reviewed-by: default avatarTomasz Zawadzki <tomasz@tzawadzki.com>
Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
Reviewed-by: default avatarKonrad Sztyber <ksztyber@nvidia.com>
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
parent 9ce189c4
Loading
Loading
Loading
Loading
+63 −0
Original line number Diff line number Diff line
# This workflow will upload a Python Package to PyPI when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

name: Upload Python Package

on:
  release:
    types: [published]

permissions:
  contents: read

jobs:
  release-build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true

      - uses: actions/setup-python@v5
        with:
          python-version: "3.x"

      - name: Build release distributions
        run: |
          # cuse is not needed for make version target and installing it just takes time and bring no value
          ./configure --without-nvme-cuse
          make -C python spdk/version.py
          python -m pip install build
          python -m build python/

      - name: Upload distributions
        uses: actions/upload-artifact@v4
        with:
          name: release-dists
          path: python/dist/

  pypi-publish:
    runs-on: ubuntu-latest
    needs:
      - release-build
    permissions:
      # IMPORTANT: this permission is mandatory for trusted publishing
      id-token: write

    # Dedicated environments with protections for publishing are strongly recommended.
    # For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
    environment:
      name: pypi

    steps:
      - name: Retrieve release distributions
        uses: actions/download-artifact@v4
        with:
          name: release-dists
          path: dist/

      - name: Publish release distributions to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          packages-dir: dist/