2020-01-20 03:42:45 -05:00
|
|
|
name: Build and publish Python package
|
2020-01-19 00:50:21 -05:00
|
|
|
|
|
|
|
on:
|
2021-08-05 22:22:24 -04:00
|
|
|
push:
|
2020-01-19 00:50:21 -05:00
|
|
|
tags:
|
|
|
|
- 'v*'
|
2021-08-05 22:22:24 -04:00
|
|
|
workflow_dispatch:
|
2020-01-19 00:50:21 -05:00
|
|
|
|
|
|
|
jobs:
|
2020-01-20 03:42:45 -05:00
|
|
|
build:
|
2021-08-07 11:48:52 -04:00
|
|
|
runs-on: ${{ matrix.os }}
|
2020-01-19 00:50:21 -05:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-06-21 22:24:15 -04:00
|
|
|
variant: [main, onepass]
|
2023-05-07 08:10:48 -04:00
|
|
|
os: [macos-11.0, ubuntu-20.04, windows-2019, self-hosted-linux-arm64]
|
2022-10-27 20:00:42 -04:00
|
|
|
python: ['3.8', '3.9', '3.10', '3.11']
|
2020-01-19 00:50:21 -05:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
2021-11-11 23:57:08 -05:00
|
|
|
|
|
|
|
- name: Set up Python (x64)
|
2022-08-08 23:47:38 -04:00
|
|
|
if: runner.name != 'linux-arm64'
|
2022-10-27 20:00:42 -04:00
|
|
|
uses: actions/setup-python@v4
|
2020-01-19 00:50:21 -05:00
|
|
|
with:
|
2020-01-20 05:55:17 -05:00
|
|
|
python-version: ${{ matrix.python }}
|
2020-01-19 00:50:21 -05:00
|
|
|
architecture: 'x64'
|
2021-11-11 23:57:08 -05:00
|
|
|
- name: Set up Python (Linux ARM64)
|
2021-11-12 00:04:15 -05:00
|
|
|
if: runner.name == 'linux-arm64'
|
2021-11-11 23:57:08 -05:00
|
|
|
run: |
|
2021-11-12 00:09:36 -05:00
|
|
|
export PYENV_ROOT="$HOME/.pyenv"
|
|
|
|
export PATH="$PYENV_ROOT/bin:$PATH"
|
|
|
|
eval "$(pyenv init --path)"
|
2021-11-11 23:57:08 -05:00
|
|
|
pyenv install -s ${{ matrix.python }}:latest
|
|
|
|
pyenv global $(pyenv versions --bare | grep -F '${{ matrix.python }}.')
|
2020-07-11 10:47:17 -04:00
|
|
|
|
2020-07-22 07:52:54 -04:00
|
|
|
- name: Set up Rust
|
2020-01-19 00:50:21 -05:00
|
|
|
uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
2020-07-03 03:34:57 -04:00
|
|
|
toolchain: stable
|
2020-01-19 00:50:21 -05:00
|
|
|
profile: minimal
|
|
|
|
default: true
|
2020-07-11 10:47:17 -04:00
|
|
|
|
2020-07-11 09:25:36 -04:00
|
|
|
- name: Run prebuild steps
|
|
|
|
shell: bash
|
|
|
|
run: bash ./prebuild.sh
|
2020-07-11 10:47:17 -04:00
|
|
|
|
2020-01-19 00:50:21 -05:00
|
|
|
- name: Build native module
|
2022-06-21 22:44:14 -04:00
|
|
|
working-directory: ./python/${{ matrix.variant }}
|
2022-06-21 07:52:28 -04:00
|
|
|
run: cargo build --release
|
2020-07-11 10:47:17 -04:00
|
|
|
|
2021-11-12 00:17:23 -05:00
|
|
|
- name: Install Python build tools (macOS x64)
|
2022-08-08 23:47:38 -04:00
|
|
|
if: runner.os == 'macOS'
|
2021-11-11 23:43:00 -05:00
|
|
|
run: sudo pip install --upgrade maturin setuptools wheel twine
|
2021-11-12 00:17:23 -05:00
|
|
|
- name: Install Python build tools (Linux x64, Windows x64)
|
|
|
|
if: runner.os != 'macOS' && runner.name != 'linux-arm64'
|
2021-11-11 23:43:00 -05:00
|
|
|
run: pip install --upgrade maturin setuptools wheel twine
|
2021-11-12 00:17:23 -05:00
|
|
|
- name: Install Python build tools (Linux ARM64)
|
|
|
|
if: runner.name == 'linux-arm64'
|
|
|
|
run: |
|
|
|
|
export PYENV_ROOT="$HOME/.pyenv"
|
|
|
|
export PATH="$PYENV_ROOT/bin:$PATH"
|
|
|
|
eval "$(pyenv init --path)"
|
|
|
|
pip3 install --upgrade maturin setuptools wheel twine
|
2020-07-11 10:47:17 -04:00
|
|
|
|
2020-01-20 03:42:45 -05:00
|
|
|
- name: Pack and publish package
|
2020-07-11 10:47:17 -04:00
|
|
|
shell: bash
|
2022-06-21 22:44:14 -04:00
|
|
|
working-directory: ./python/${{ matrix.variant }}
|
2020-01-20 03:42:45 -05:00
|
|
|
run: |
|
|
|
|
cat << 'EOF' > "$HOME/.pypirc"
|
|
|
|
[pypi]
|
|
|
|
username = __token__
|
|
|
|
password = ${{ secrets.PYPI_API_TOKEN }}
|
|
|
|
EOF
|
2021-11-12 00:09:36 -05:00
|
|
|
if [[ "${{ runner.name }}" == linux-arm64 ]]; then
|
|
|
|
export PYENV_ROOT="$HOME/.pyenv"
|
|
|
|
export PATH="$PYENV_ROOT/bin:$PATH"
|
|
|
|
eval "$(pyenv init --path)"
|
|
|
|
fi
|
2022-10-25 16:29:40 -04:00
|
|
|
maturin build --release --sdist --strip -i "$(which python)"
|
2020-07-11 10:47:17 -04:00
|
|
|
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
|
2022-06-17 04:01:13 -04:00
|
|
|
# For idempotency, ignore any existing built wheels that have already been successfully uploaded.
|
|
|
|
twine upload --skip-existing target/wheels/*
|
2021-11-11 23:43:00 -05:00
|
|
|
else
|
|
|
|
ls -al target/wheels/*
|
2020-06-18 21:44:54 -04:00
|
|
|
fi
|