|
| 1 | +name: Build and Publish Wheels |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + tags: ["v*"] |
| 8 | + release: |
| 9 | + types: [published] |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + build_wheels: |
| 14 | + name: Build wheels on ${{ matrix.os }} |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + include: |
| 20 | + - os: ubuntu-latest |
| 21 | + - os: windows-latest |
| 22 | + - os: macos-14 |
| 23 | + - os: macos-15 |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout repository |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + submodules: recursive |
| 30 | + |
| 31 | + - name: Set up Python |
| 32 | + uses: actions/setup-python@v5 |
| 33 | + with: |
| 34 | + python-version: "3.12" |
| 35 | + |
| 36 | + - name: Build wheels |
| 37 | + uses: pypa/cibuildwheel@v2.22.0 |
| 38 | + env: |
| 39 | + CIBW_BUILD_VERBOSITY: "1" |
| 40 | + CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-* cp313-*" |
| 41 | + CIBW_SKIP: "*-musllinux_* pp* cp38-macosx_arm64" |
| 42 | + CIBW_ARCHS_LINUX: "x86_64" |
| 43 | + CIBW_ARCHS_WINDOWS: "AMD64" |
| 44 | + CIBW_ARCHS_MACOS: "auto64" |
| 45 | + CIBW_TEST_COMMAND: "python -c \"import seal; print(seal.__version__)\"" |
| 46 | + CIBW_BEFORE_BUILD: > |
| 47 | + python -m pip install --upgrade pip cmake && |
| 48 | + cmake -S SEAL -B SEAL/build -DSEAL_USE_MSGSL=OFF -DSEAL_USE_ZLIB=OFF -DSEAL_USE_ZSTD=OFF && |
| 49 | + cmake --build SEAL/build --config Release && |
| 50 | + python -c "import glob; print('SEAL libs:', glob.glob('SEAL/build/**/*.lib', recursive=True)[:50])" |
| 51 | +
|
| 52 | + - name: Upload wheel artifacts |
| 53 | + uses: actions/upload-artifact@v4 |
| 54 | + with: |
| 55 | + name: wheels-${{ matrix.os }} |
| 56 | + path: wheelhouse/*.whl |
| 57 | + |
| 58 | + build_sdist: |
| 59 | + name: Build sdist |
| 60 | + runs-on: ubuntu-latest |
| 61 | + steps: |
| 62 | + - name: Checkout repository |
| 63 | + uses: actions/checkout@v4 |
| 64 | + with: |
| 65 | + submodules: recursive |
| 66 | + |
| 67 | + - name: Set up Python |
| 68 | + uses: actions/setup-python@v5 |
| 69 | + with: |
| 70 | + python-version: "3.12" |
| 71 | + |
| 72 | + - name: Install build tools |
| 73 | + run: python -m pip install --upgrade pip build cmake |
| 74 | + |
| 75 | + - name: Build SEAL static libs |
| 76 | + run: | |
| 77 | + cmake -S SEAL -B SEAL/build -DSEAL_USE_MSGSL=OFF -DSEAL_USE_ZLIB=OFF -DSEAL_USE_ZSTD=OFF |
| 78 | + cmake --build SEAL/build --config Release |
| 79 | +
|
| 80 | + - name: Build source distribution |
| 81 | + run: python -m build --sdist |
| 82 | + |
| 83 | + - name: Upload sdist artifact |
| 84 | + uses: actions/upload-artifact@v4 |
| 85 | + with: |
| 86 | + name: sdist |
| 87 | + path: dist/*.tar.gz |
| 88 | + |
| 89 | + publish_pypi: |
| 90 | + name: Publish to PyPI |
| 91 | + needs: [build_wheels, build_sdist] |
| 92 | + runs-on: ubuntu-latest |
| 93 | + if: github.event_name == 'release' && github.event.action == 'published' |
| 94 | + permissions: |
| 95 | + id-token: write |
| 96 | + steps: |
| 97 | + - name: Download wheel artifacts |
| 98 | + uses: actions/download-artifact@v4 |
| 99 | + with: |
| 100 | + path: dist |
| 101 | + pattern: wheels-* |
| 102 | + merge-multiple: true |
| 103 | + |
| 104 | + - name: Download sdist artifact |
| 105 | + uses: actions/download-artifact@v4 |
| 106 | + with: |
| 107 | + path: dist |
| 108 | + name: sdist |
| 109 | + |
| 110 | + - name: Publish package distributions to PyPI |
| 111 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments