Skip to content

python-rust-build

python-rust-build #49

name: python-rust-build
on:
release:
types: [published, released, prereleased]
branches:
- main
workflow_dispatch:
defaults:
run:
working-directory: ./rust/keyboard
jobs:
Linux:
strategy:
fail-fast: false
matrix:
python-version:
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- '3.10'
include:
- os: ubuntu
platform: linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools setuptools-rust
- name: Build .so
run: |
python setup.py build
- name: list files
run: |
ls -lh build/
ls -lh build/**/
- name: upload .so
uses: actions/upload-artifact@v3
with:
name: linux
path: rust/keyboard/build/lib.linux-x86_64-${{ matrix.python-version }}/keyboard.cpython-*-x86_64-linux-gnu.so
- name: upload to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: rust/keyboard/build/lib.linux-x86_64-${{ matrix.python-version }}/keyboard.cpython-*-x86_64-linux-gnu.so
tag: ${{ github.ref }}
file_glob: true
macOS:
# something about code signing because github action binaries not working on mac because of code signing
# search for setup.py macos code signing
strategy:
fail-fast: false
matrix:
python-version:
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- '3.10'
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools setuptools-rust
- name: Build .so
run: |
python setup.py build
- name: list files
run: |
ls -lh build/**/
ls -lh build/
- name: upload .so
uses: actions/upload-artifact@v3
with:
name: macos
path: rust/keyboard/build/lib.macosx-*.*-x86_64-${{ matrix.python-version }}/keyboard.cpython-*-darwin.so
- name: upload to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: rust/keyboard/build/lib.macosx-*.*-x86_64-${{ matrix.python-version }}/keyboard.cpython-*-darwin.so
tag: ${{ github.ref }}
file_glob: true
Windows:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version:
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- '3.10'
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: install rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools setuptools-rust
- name: Build .pyd
run: |
python setup.py build
- name: list files
run: |
dir build
dir build\lib.win-amd64-${{ matrix.python-version }}\
- name: upload .pyd
uses: actions/upload-artifact@v3
with:
name: windows
path: rust\keyboard\build\lib.win-amd64-${{ matrix.python-version }}\keyboard.cp*-win_amd64.pyd
- name: upload to release
if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: rust/keyboard/build/lib.win-amd64-${{ matrix.python-version }}/*.pyd
tag: ${{ github.ref }}
overwrite: true
file_glob: true