jsonschema-rs/.github/workflows/python-release.yml

207 lines
6.1 KiB
YAML

name: Python Release
on:
push:
tags:
- python-v*
defaults:
run:
shell: bash
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PACKAGE_NAME: jsonschema_rs
jobs:
sdist:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.7"
architecture: x64
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Build sdist
uses: messense/maturin-action@v1
with:
command: sdist
args: -m bindings/python/Cargo.toml --out dist
- name: Install sdist
run: |
pip install dist/${{ env.PACKAGE_NAME }}-*.tar.gz --force-reinstall
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
macos-x86_64:
runs-on: macos-12
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Build wheels - x86_64
uses: messense/maturin-action@v1
with:
target: x86_64
args: --release -m bindings/python/Cargo.toml --out dist --interpreter ${{ matrix.python-version }}
- name: Install built wheel - x86_64
run: |
pip install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
macos-universal:
runs-on: macos-12
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Build wheels - universal2
uses: messense/maturin-action@v1
with:
args: --release -m bindings/python/Cargo.toml --target universal2-apple-darwin --out dist --interpreter ${{ matrix.python-version }}
- name: Install built wheel - universal2
run: |
pip install dist/${{ env.PACKAGE_NAME }}-*universal2.whl --force-reinstall
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
windows:
runs-on: windows-2022
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ]
target: [ x64, x86 ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.target }}
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
default: true
- name: Build wheels
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release -m bindings/python/Cargo.toml --out dist --interpreter ${{ matrix.python-version }}
- name: Install built wheel
shell: bash
run: |
python -m pip install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
linux:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ]
target: [ x86_64, i686, aarch64 ]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Build wheels
uses: messense/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: auto
args: --release -m bindings/python/Cargo.toml --out dist --interpreter ${{ matrix.python-version }}
- name: Install built wheel on native architecture
if: matrix.target == 'x86_64'
run: |
pip install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall
- uses: uraimo/run-on-arch-action@v2
if: matrix.target == 'aarch64'
name: Install built wheel on ARM architecture
with:
arch: ${{ matrix.target }}
distro: ubuntu22.04
githubToken: ${{ github.token }}
install: |
export TZ=UTC
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y --no-install-recommends software-properties-common gpg gpg-agent curl
add-apt-repository ppa:deadsnakes/ppa
apt-get update
apt-get install -y python${{ matrix.python-version }}-dev python${{ matrix.python-version }}-venv
run: |
python${{ matrix.python-version }} -m venv venv
venv/bin/pip install -U pip wheel
venv/bin/pip install ${{ env.PACKAGE_NAME }} --no-index --find-links dist/ --force-reinstall
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
release:
name: Release
runs-on: ubuntu-20.04
needs:
- sdist
- macos-x86_64
- macos-universal
- windows
- linux
if: "startsWith(github.ref, 'refs/tags/')"
steps:
- uses: actions/download-artifact@v3
with:
name: dist
path: dist
- name: Publish distribution package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}