2020-01-20 03:42:45 -05:00
|
|
|
name: Build and publish Python package
|
2020-01-19 00:50:21 -05:00
|
|
|
|
|
|
|
on:
|
|
|
|
create:
|
|
|
|
tags:
|
|
|
|
- 'v*'
|
2020-06-18 21:06:22 -04:00
|
|
|
repository_dispatch:
|
|
|
|
types: [wf-python]
|
2020-01-19 00:50:21 -05:00
|
|
|
|
|
|
|
jobs:
|
2020-01-20 03:42:45 -05:00
|
|
|
build:
|
2020-01-19 00:50:21 -05:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2021-01-05 23:59:40 -05:00
|
|
|
os: [macos-11.0, ubuntu-latest, windows-latest]
|
2021-01-06 02:03:01 -05:00
|
|
|
python: [3.7, 3.8, 3.9]
|
2020-01-19 00:50:21 -05:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v1
|
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v1
|
|
|
|
with:
|
2020-01-20 05:55:17 -05:00
|
|
|
python-version: ${{ matrix.python }}
|
2020-01-19 00:50:21 -05:00
|
|
|
architecture: 'x64'
|
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-22 07:56:07 -04:00
|
|
|
- name: Set up GCC (Windows)
|
|
|
|
if: runner.os == 'Windows'
|
|
|
|
run: .\.github\workflows\gcc.ps1
|
|
|
|
|
2020-07-10 11:33:38 -04:00
|
|
|
- name: Set up Go
|
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
|
|
|
go-version: '^1.14.0'
|
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
|
|
|
|
working-directory: ./python
|
2020-01-20 03:42:45 -05:00
|
|
|
run: cargo build --release
|
2020-07-11 10:47:17 -04:00
|
|
|
|
2020-07-11 12:33:35 -04:00
|
|
|
- name: Install Python build tools (macOS)
|
|
|
|
if: runner.os == 'macOS'
|
2020-07-11 10:47:17 -04:00
|
|
|
run: sudo pip install --upgrade maturin setuptools wheel twine
|
2020-07-11 12:33:35 -04:00
|
|
|
- name: Install Python build tools (Linux, Windows)
|
|
|
|
if: runner.os != 'macOS'
|
2020-07-11 10:47:17 -04:00
|
|
|
run: pip install --upgrade maturin setuptools wheel twine
|
|
|
|
|
2020-01-20 03:42:45 -05:00
|
|
|
- name: Pack and publish package
|
2020-07-11 10:47:17 -04:00
|
|
|
shell: bash
|
2020-01-20 03:42:45 -05:00
|
|
|
working-directory: ./python
|
|
|
|
run: |
|
|
|
|
cat << 'EOF' > "$HOME/.pypirc"
|
|
|
|
[pypi]
|
|
|
|
username = __token__
|
|
|
|
password = ${{ secrets.PYPI_API_TOKEN }}
|
|
|
|
EOF
|
2020-07-11 11:46:53 -04:00
|
|
|
maturin build --release --strip -i "$(which python)"
|
2020-07-11 10:47:17 -04:00
|
|
|
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
|
2020-07-11 12:09:36 -04:00
|
|
|
twine upload target/wheels/*
|
2020-06-18 21:44:54 -04:00
|
|
|
fi
|