Update deps #90
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
# Derived from https://github.com/mre/hyperjson/blob/master/.github/workflows/ci.yml | |
name: CI | |
on: | |
release: | |
types: [created] | |
push: | |
jobs: | |
# https://srz-zumix.blogspot.com/2019/10/github-actions-ci-skip.html | |
prepare: | |
runs-on: ubuntu-latest | |
if: "! contains(github.event.head_commit.message, '[skip ci]')" | |
steps: | |
- run: echo "[skip ci] ${{ contains(github.event.head_commit.message, '[skip ci]') }}" | |
lint: | |
runs-on: ubuntu-latest | |
needs: [prepare] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Install latest stable | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
components: rustfmt | |
- name: Lint with rustfmt | |
uses: actions-rs/cargo@v1 | |
with: | |
command: fmt | |
# - name: Lint with clippy | |
# uses: actions-rs/cargo@v1 | |
# with: | |
# command: clippy | |
# args: --all-targets --all-features | |
# - name: Test with cargo | |
# uses: actions-rs/cargo@v1.0.1 | |
# with: | |
# command: test | |
# toolchain: nightly | |
build: # Workflow credit to https://github.com/Cryptex-github/ril-py/blob/main/.github/workflows/py-binding.yml | |
name: > | |
build ${{ matrix.python-version }} on ${{ matrix.platform || matrix.os }} | |
(${{ matrix.alt_arch_name || matrix.arch }}) | |
needs: [lint] | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu, macos, windows] | |
# python-version: ['cp310', 'pp37', 'pp38', 'pp39'] | |
python-version: ["cp38", "cp39", "cp310", "cp311"] | |
arch: [main, alt] | |
include: | |
- os: ubuntu | |
platform: linux | |
- os: ubuntu | |
arch: alt | |
alt_arch_name: "aarch64" | |
- os: windows | |
ls: dir | |
- os: macos | |
arch: alt | |
alt_arch_name: "arm64 universal2" | |
exclude: | |
- os: windows | |
arch: alt | |
# - os: macos | |
# python-version: "cp37" | |
# arch: alt | |
# - os: macos | |
# python-version: "pp37" | |
# arch: alt | |
# - os: macos | |
# python-version: "pp38" | |
# arch: alt | |
# - os: macos | |
# python-version: "pp39" | |
# arch: alt | |
# - os: ubuntu | |
# arch: alt | |
runs-on: ${{ format('{0}-latest', matrix.os) }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: set up python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.9" | |
- name: set up rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
- name: Setup Rust cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: ${{ matrix.alt_arch_name }} | |
- name: Set up QEMU on linux (aarch64) | |
if: matrix.platform == 'linux' && matrix.arch == 'alt' | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: arm64 | |
- run: rustup target add aarch64-apple-darwin | |
if: matrix.os == 'macos' | |
- run: rustup toolchain install stable-i686-pc-windows-msvc | |
if: matrix.os == 'windows' | |
- run: rustup target add i686-pc-windows-msvc | |
if: matrix.os == 'windows' | |
- name: Get pip cache dir | |
id: pip-cache | |
run: | | |
echo "::set-output name=dir::$(pip cache dir)" | |
- name: Cache python dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.pip-cache.outputs.dir }} | |
key: ${{ runner.os }}-pip-${{ matrix.python-version }} | |
- name: install python dependencies | |
run: pip install -U setuptools wheel twine cibuildwheel platformdirs | |
- name: Display cibuildwheel cache dir | |
id: cibuildwheel-cache | |
run: | | |
from platformdirs import user_cache_path | |
print('::set-output name=dir::' + str(user_cache_path(appname='cibuildwheel', appauthor='pypa'))) | |
shell: python | |
- name: Cache cibuildwheel tools | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.cibuildwheel-cache.outputs.dir }} | |
key: ${{ runner.os }}-cibuildwheel-${{ matrix.python-version }} | |
# - name: build sdist | |
# if: matrix.os == 'ubuntu' && matrix.python-version == 'cp310' | |
# run: | | |
# pip install maturin build | |
# python -m build --sdist -o wheelhouse | |
- name: build ${{ matrix.platform || matrix.os }} binaries | |
run: cibuildwheel --output-dir wheelhouse | |
env: | |
CIBW_BUILD: "${{ matrix.python-version }}-*" | |
# rust doesn't seem to be available for musl linux on i686 | |
CIBW_SKIP: "*-musllinux_i686" | |
# we build for "alt_arch_name" if it exists, else 'auto' | |
CIBW_ARCHS: ${{ matrix.alt_arch_name || 'auto' }} | |
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH" CARGO_TERM_COLOR="always"' | |
CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"' | |
CIBW_BEFORE_BUILD: rustup show | |
CIBW_BEFORE_BUILD_LINUX: > | |
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=stable --profile=minimal -y && | |
rustup show | |
CIBW_TEST_COMMAND: "pytest {project}/tests/" | |
CIBW_TEST_REQUIRES: pytest | |
CIBW_TEST_SKIP: "*-macosx_arm64 *-macosx_universal2:arm64" | |
CIBW_BUILD_VERBOSITY: 1 | |
- run: ${{ matrix.ls || 'ls -lh' }} wheelhouse/ | |
- run: twine check wheelhouse/* | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: wheels | |
path: wheelhouse | |
release: | |
needs: [build] | |
if: "success() && startsWith(github.ref, 'refs/tags/')" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: set up python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.10" | |
- run: pip install -U twine | |
- name: get wheelhouse artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
name: wheels | |
path: wheelhouse | |
- run: twine check wheelhouse/* | |
- name: upload to pypi | |
run: twine upload --skip-existing wheelhouse/* | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI }} | |
- name: Upload artifacts to release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: wheelhouse/* |