From 6230802e1642cf85fe459fd893283d0e771522c3 Mon Sep 17 00:00:00 2001 From: Hyungtae Lim <35317311+LimHyungTae@users.noreply.github.com> Date: Tue, 28 Jan 2025 09:47:22 -0500 Subject: [PATCH] Create pypi.yml --- .github/workflows/pypi.yml | 68 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/pypi.yml diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 0000000..26cd86a --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,68 @@ +name: Publish to PyPI.org + +on: + workflow_dispatch: + release: + types: [published] + push: + branches: ["master"] + pull_request: + branches: ["master"] + +jobs: + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Build sdist + run: pipx run build --sdist ${{github.workspace}}/python/ + - name: Move sdist to dist + run: mkdir -p dist && mv ${{github.workspace}}/python/dist/*.tar.gz dist/ + + - uses: actions/upload-artifact@v4 + with: + path: dist/*.tar.gz + + cibuildwheel: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-24.04, windows-2022, macos-15] + + steps: + - uses: actions/checkout@v3 + + - name: Build test wheels (only PRs) + if: github.event_name != 'release' + uses: pypa/cibuildwheel@v2.22.0 + env: # build 1 build per platform just to make sure we can do it later when releasing + CIBW_BUILD: "cp310-*" + with: + package-dir: ${{github.workspace}}/python/ + + - name: Build all wheels + if: github.event_name == 'release' + uses: pypa/cibuildwheel@v2.22.0 + with: + package-dir: ${{github.workspace}}/python/ + + - uses: actions/upload-artifact@v4 + with: + path: ./wheelhouse/*.whl + + pypi: + if: github.event_name == 'release' + needs: [cibuildwheel, build_sdist] + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v4 + with: + name: artifact + path: dist + + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }}