ncnn / .github /workflows /release-python.yml
camenduru's picture
thanks to ncnn ❤
be903e2
name: release-python
# on: [push, pull_request]
on:
push:
tags:
- '*'
jobs:
build_sdist:
name: Build SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install deps
run: python -m pip install twine build
- name: Build SDist
run: python -m build -s
- name: Check metadata
run: twine check dist/*
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
build_wheels:
name: ${{ matrix.arch }} ${{ matrix.build }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-20.04, arch: x86_64, build: 'cp*-manylinux*' }
- { os: ubuntu-20.04, arch: x86_64, build: 'cp*-musllinux*' }
- { os: ubuntu-20.04, arch: x86_64, build: 'pp*' }
- { os: ubuntu-20.04, arch: i686, build: 'cp*-manylinux*' }
- { os: ubuntu-20.04, arch: i686, build: 'cp*-musllinux*' }
- { os: ubuntu-20.04, arch: i686, build: 'pp*' }
- { os: windows-2019, arch: x86, build: 'cp*' }
- { os: windows-2019, arch: AMD64, build: 'cp*' }
- { os: windows-2019, arch: AMD64, build: 'pp*' }
- { os: windows-2019, arch: ARM64, build: 'cp*' }
- { os: macos-latest, arch: x86_64, build: 'cp*' }
- { os: macos-latest, arch: x86_64, build: 'pp*' }
- { os: macos-latest, arch: arm64, build: 'cp*' }
- { os: macos-latest, arch: universal2, build: 'cp*' }
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: brew uninstall libomp
if: matrix.os == 'macos-latest'
run: |
brew uninstall --ignore-dependencies libomp
- name: Build wheels
uses: pypa/cibuildwheel@v2.15.0
env:
CIBW_ARCHS_MACOS: ${{ matrix.arch }}
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
CIBW_ARCHS_WINDOWS: ${{ matrix.arch }}
CIBW_BUILD: ${{ matrix.build }}
CIBW_BUILD_VERBOSITY: 1
CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=2
- name: Show files
run: ls -lh wheelhouse
shell: bash
- name: Verify clean directory
run: git diff --exit-code
shell: bash
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
path: wheelhouse/*.whl
build_wheels_qemu:
name: ${{ matrix.arch }} ${{ matrix.build }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
arch: [aarch64, ppc64le, s390x]
build: ['cp36-*', 'cp37-*', 'cp38-*', 'cp39-*', 'cp310-*', 'cp311-*', 'cp312-*']
include:
- arch: aarch64
build: 'pp37-*'
- arch: aarch64
build: 'pp38-*'
- arch: aarch64
build: 'pp39-*'
- arch: aarch64
build: 'pp310-*'
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Build wheels
uses: pypa/cibuildwheel@v2.15.0
env:
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
CIBW_BUILD: ${{ matrix.build }}
CIBW_BUILD_VERBOSITY: 1
CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=2
- name: Show files
run: ls -lh wheelhouse
shell: bash
- name: Verify clean directory
run: git diff --exit-code
shell: bash
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
path: wheelhouse/*.whl
upload_all:
permissions:
contents: none
name: Upload
needs: [build_wheels, build_wheels_qemu, build_sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}