Python build Wheels and SDist #72
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Python build Wheels and SDist | |
| on: | |
| workflow_dispatch: | |
| # Inputs the workflow accepts. | |
| inputs: | |
| name: | |
| # Friendly description to be shown in the UI instead of 'name' | |
| description: 'making pysndlib' | |
| # Default value if no value is explicitly provided | |
| default: 'make' | |
| # Input has to be provided for the workflow to run | |
| required: true | |
| # The data type of the input | |
| type: string | |
| env: | |
| CIBW_BUILD_VERBOSITY: 2 | |
| CIBW_ENVIRONMENT: PIP_PREFER_BINARY=1 | |
| CIBW_TEST_SKIP: "*-macosx_arm64 *-macosx_universal2:arm64 *-macosx_universal2:x86_64" | |
| jobs: | |
| build_macos_wheels: | |
| name: Build python ${{ matrix.cibw_python }} ${{ matrix.cibw_arch }} wheels on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [macos-latest] | |
| cibw_python: ["cp310-*", "cp311-*", "cp312-*"] | |
| p_ver: ["3.10-3.12"] | |
| cibw_arch: ["universal2"] | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v3 | |
| with: | |
| python-version: '3.x' | |
| - name: Fetch asset | |
| run: gh release download --clobber --repo testcase/sndlib v1.0.0 --pattern libsndlib_macos_universal2.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.SUPERSECRET }} | |
| - name: See what we downloaded | |
| run: ls | |
| - name: unzip | |
| run: unzip libsndlib_macos_universal2.zip | |
| - name: Copy sndlib header files | |
| run: | | |
| cp ./sndlib/sndlib.h ./src/pysndlib/ | |
| cp ./sndlib/clm.h ./src/pysndlib/ | |
| - name: Build wheels | |
| uses: pypa/cibuildwheel@v2.14.1 | |
| env: | |
| CIBW_BUILD: ${{ matrix.cibw_python }} | |
| CIBW_ARCHS_MACOS: ${{ matrix.cibw_arch }} | |
| CIBW_MANYLINUX_X86_64_IMAGE: manylinux1 | |
| CIBW_MANYLINUX_I686_IMAGE: manylinux1 | |
| CIBW_TEST_SKIP: "*-macosx_arm64" | |
| - uses: actions/upload-artifact@v3 | |
| with: | |
| path: ./wheelhouse/*.whl | |
| make_sdist: | |
| name: Make SDist | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 # Optional, use if you use setuptools_scm | |
| submodules: true # Optional, use if you have submodules | |
| - name: Fetch asset | |
| run: gh release download --clobber --repo testcase/sndlib v1.0.0 --pattern libsndlib_linux_x86_64.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.SUPERSECRET }} | |
| - name: See what we downloaded | |
| run: ls | |
| - name: unzip | |
| run: unzip libsndlib_linux_x86_64.zip | |
| - name: Copy sndlib header files | |
| run: | | |
| cp ./sndlib/sndlib.h ./src/pysndlib/ | |
| cp ./sndlib/clm.h ./src/pysndlib/ | |
| - name: Build SDist | |
| run: pipx run build --sdist | |
| - uses: actions/upload-artifact@v3 | |
| with: | |
| path: dist/*.tar.gz | |
| build_linux_wheels: | |
| name: Build python ${{ matrix.cibw_python }} ${{ matrix.cibw_arch }} wheels on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest] | |
| cibw_arch: ["x86_64"] | |
| cibw_python: ["cp310-*", "cp311-*"] | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v3 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Fetch asset | |
| run: gh release download --clobber --repo testcase/sndlib v1.0.0 --pattern libsndlib_linux_x86_64.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.SUPERSECRET }} | |
| - name: See what we downloaded | |
| run: ls | |
| - name: unzip | |
| run: unzip libsndlib_linux_x86_64.zip | |
| - name: Copy sndlib header files | |
| run: | | |
| cp ./sndlib/sndlib.h ./src/pysndlib/ | |
| cp ./sndlib/clm.h ./src/pysndlib/ | |
| - name: Build wheels | |
| uses: pypa/cibuildwheel@v2.14.1 | |
| env: | |
| CIBW_BUILD: ${{ matrix.cibw_python }} | |
| CIBW_ARCHS: ${{ matrix.cibw_arch }} | |
| - uses: actions/upload-artifact@v3 | |
| with: | |
| path: ./wheelhouse/*.whl | |
| pypi-publish: | |
| name: Upload release to PyPI | |
| needs: [build_macos_wheels, build_linux_wheels, make_sdist] | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/pysndlib | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/download-artifact@v3 | |
| with: | |
| # unpacks default artifact into dist/ | |
| # if `name: artifact` is omitted, the action will create extra parent dir | |
| name: artifact | |
| path: dist | |
| - name: Publish package distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |