Skip to content

Release to PyPI

Release to PyPI #13

Workflow file for this run

name: Release to PyPI
on:
push:
tags: [ 'python-v*' ]
defaults:
run:
working-directory: ./python
jobs:
validate-release-tag:
name: Validate git tag
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: compare git tag with cargo metadata
run: |
PUSHED_TAG=${GITHUB_REF##*/}
CURR_VER=$( grep version Cargo.toml | head -n 1 | awk '{print $3}' | tr -d '"' )
if [[ "${PUSHED_TAG}" != "python-v${CURR_VER}" ]]; then
echo "Cargo metadata has version set to ${CURR_VER}, but got pushed tag ${PUSHED_TAG}."
exit 1
fi
release-github-pypi:
needs: validate-release-tag
name: PyPI release
strategy:
fail-fast: false
matrix:
os:
- macOS-10.15
- windows-2019
include:
- target: x86_64-apple-darwin
os: macOS-10.15
- target: x86_64-pc-windows-msvc
os: windows-2019
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: ${{ matrix.target }}
- uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Install matruin
run: |
pip install maturin==0.9.0
- name: Publish to pypi (without sdist)
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: maturin publish -b pyo3 --target ${{ matrix.target }} --no-sdist
release-github-pypi-manylinux:
needs: validate-release-tag
name: PyPI release manylinux
runs-on: ubuntu-20.04
container: quay.io/pypa/manylinux2010_x86_64:2020-12-31-4928808
steps:
# actions/checkout@v2 is a node action, which runs on a fairly new
# version of node. however, manylinux environment's glibc is too old for
# that version of the node. so we will have to use v1 instead, which is a
# docker based action.
- uses: actions/checkout@v1
# actions-rs/toolchain@v1 is a node action, which runs on a fairly new
# version of node. however, manylinux environment's glibc is too old for
# that version of the node. so we will have to install rust manually here.
- name: Install Rust
run: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
$HOME/.cargo/bin/rustup default stable
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Enable manylinux Python targets
run: |
echo "/opt/python/cp36-cp36m/bin" >> $GITHUB_PATH
- name: Install matruin
run: |
pip install maturin==0.9.0
- name: Publish manylinux to pypi (without sdist)
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
# linux build uploads sdist to update projection description on PyPI
run: maturin publish -b pyo3 --target x86_64-unknown-linux-gnu