Python building #228
This file contains 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: Build Python | |
run-name: Python building | |
on: [push, pull_request] | |
permissions: | |
contents: write | |
pull-requests: read | |
jobs: | |
builds_linux: | |
strategy: | |
fail-fast: false | |
matrix: | |
archit: [x86_64, arm, aarch64] | |
include: | |
- archit: x86_64 | |
target: x86_64-unknown-linux-gnu | |
- archit: arm | |
target: armv7-unknown-linux-gnueabihf | |
- archit: aarch64 | |
target: aarch64-unknown-linux-gnu | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
target: ${{ matrix.target }} | |
- uses: Swatinem/rust-cache@v2 | |
continue-on-error: true | |
- name: Install Cross Compiler | |
if: ${{ matrix.archit == 'arm'}} | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y --no-install-recommends gcc-arm-linux-gnueabihf libc6-dev-armhf-cross | |
- name: Install Cross Compiler | |
if: ${{ matrix.archit == 'aarch64'}} | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y --no-install-recommends gcc-aarch64-linux-gnu libc6-dev-arm64-cross | |
- name: Build | |
uses: PyO3/[email protected] | |
with: | |
container: registry.cn-shanghai.aliyuncs.com/lebai/util:14.04 | |
manylinux: 2_17 | |
command: build | |
args: --release --features ffi_py,module,mdns --target ${{matrix.target}} --skip-auditwheel | |
- name: Upload | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Lebai_Python_SDK_Linux_${{matrix.archit}} | |
path: ./target/wheels/*.whl | |
builds_macos: | |
strategy: | |
fail-fast: false | |
matrix: | |
archit: [x86_64, aarch64] | |
include: | |
- archit: x86_64 | |
target: x86_64-apple-darwin | |
- archit: aarch64 | |
target: aarch64-apple-darwin | |
runs-on: macos-13 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
target: ${{ matrix.target }} | |
- uses: Swatinem/rust-cache@v2 | |
continue-on-error: true | |
- name: Build | |
uses: PyO3/[email protected] | |
with: | |
container: off | |
command: build | |
args: --release --features ffi_py,module,mdns --target ${{matrix.target}} | |
- name: Upload | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Lebai_Python_SDK_MacOS_${{matrix.archit}} | |
path: ./target/wheels/*.whl | |
builds_windows: | |
strategy: | |
fail-fast: false | |
matrix: | |
archit: [x86_64] | |
include: | |
- archit: x86_64 | |
target: x86_64-pc-windows-msvc | |
runs-on: windows-2022 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v1 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
target: ${{ matrix.target }} | |
- uses: Swatinem/rust-cache@v2 | |
continue-on-error: true | |
- name: Build | |
uses: PyO3/[email protected] | |
with: | |
container: off | |
command: build | |
args: --release --features ffi_py,module,mdns --target ${{matrix.target}} | |
- name: Upload | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Lebai_Python_SDK_Windows_${{matrix.archit}} | |
path: ./target/wheels/*.whl | |
release: | |
if: ${{ contains(github.ref, 'tags/v') }} | |
needs: [builds_linux, builds_macos, builds_windows] | |
strategy: | |
fail-fast: false | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- uses: actions/download-artifact@v3 | |
- name: Release | |
env: | |
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | |
uses: PyO3/[email protected] | |
with: | |
container: off | |
command: upload | |
args: --skip-existing */*.whl | |
- name: Zip Artifact | |
run: for dir in `ls`; do zip -r ${dir}.zip ${dir}; done | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
draft: false | |
prerelease: false | |
files: | | |
* |