Publish Python and Rust Packages #54
Workflow file for this run
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
name: Publish Python and Rust Packages | |
on: | |
release: | |
types: [created] | |
workflow_dispatch: | |
permissions: | |
contents: read | |
id-token: write | |
concurrency: | |
group: "publish" | |
cancel-in-progress: true | |
jobs: | |
build-wheels-x86: | |
name: Build x86_64 wheels | |
timeout-minutes: 360 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install cibuildwheel | |
shell: bash | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: all | |
- name: Build package | |
env: | |
CIBW_SKIP: "pp* *-musllinux*" | |
CIBW_ARCHS_LINUX: auto | |
CIBW_BEFORE_ALL_LINUX: | | |
yum install -y libudev-devel pkgconfig python3-devel python3-pip python3-wheel | |
CIBW_BEFORE_BUILD: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
export PATH="$HOME/.cargo/bin:$PATH" | |
pip install setuptools-rust | |
CIBW_ENVIRONMENT: | | |
PATH="/usr/local/bin:$HOME/.cargo/bin:$PATH" | |
CARGO_NET_GIT_FETCH_WITH_CLI=true | |
run: | | |
cibuildwheel --output-dir dist | |
- name: Upload wheel artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels-x86_64 | |
path: | | |
dist/*.whl | |
build-wheels-arm64: | |
name: Build ARM64 wheels | |
timeout-minutes: 360 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install cibuildwheel | |
shell: bash | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: all | |
- name: Build package | |
env: | |
CIBW_SKIP: "pp* *-musllinux*" | |
CIBW_ARCHS_LINUX: aarch64 | |
CIBW_BEFORE_ALL_LINUX: | | |
yum install -y libudev-devel pkgconfig python3-devel python3-pip python3-wheel | |
CIBW_BEFORE_BUILD: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
export PATH="$HOME/.cargo/bin:$PATH" | |
pip install setuptools-rust | |
CIBW_ENVIRONMENT: | | |
PATH="/usr/local/bin:$HOME/.cargo/bin:$PATH" | |
CARGO_NET_GIT_FETCH_WITH_CLI=true | |
run: | | |
cibuildwheel --output-dir dist | |
- name: Upload wheel artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels-arm64 | |
path: | | |
dist/*.whl | |
build-wheels-s390x: | |
name: Build s390x wheels | |
timeout-minutes: 360 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install cibuildwheel | |
shell: bash | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: all | |
- name: Build package | |
env: | |
CIBW_SKIP: "pp* *-musllinux*" | |
CIBW_ARCHS_LINUX: s390x | |
CIBW_BEFORE_ALL_LINUX: | | |
yum install -y libudev-devel pkgconfig python3-devel python3-pip python3-wheel | |
CIBW_BEFORE_BUILD: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
export PATH="$HOME/.cargo/bin:$PATH" | |
pip install setuptools-rust | |
CIBW_ENVIRONMENT: | | |
PATH="/usr/local/bin:$HOME/.cargo/bin:$PATH" | |
CARGO_NET_GIT_FETCH_WITH_CLI=true | |
run: | | |
cibuildwheel --output-dir dist | |
- name: Upload wheel artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels-s390x | |
path: | | |
dist/*.whl | |
build-source-dist: | |
name: Build and publish Python package (source distribution) | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install build | |
shell: bash | |
- name: Build source distribution | |
run: | | |
python -m build --sdist --outdir dist | |
- name: Upload source distribution | |
uses: actions/upload-artifact@v3 | |
with: | |
name: source-dist | |
path: | | |
dist/*.tar.gz | |
publish-wheels: | |
needs: [build-wheels-x86, build-wheels-arm64, build-wheels-s390x, build-source-dist] | |
name: Publish Python wheels | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download all wheels | |
uses: actions/download-artifact@v3 | |
with: | |
path: dist | |
- name: Move wheels to dist directory | |
run: | | |
mkdir -p final_dist | |
find dist -name "*.whl" -exec mv {} final_dist/ \; | |
find dist -name "*.tar.gz" -exec mv {} final_dist/ \; | |
- name: Publish package | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages-dir: final_dist/ | |
publish-rust: | |
name: Build and publish Rust package | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libudev-dev pkg-config | |
- name: Cache Cargo registry | |
uses: actions/cache@v2 | |
with: | |
path: ~/.cargo/registry | |
key: ${{ runner.os }}-cargo-registry | |
restore-keys: | | |
${{ runner.os }}-cargo-registry | |
- name: Cache Cargo index | |
uses: actions/cache@v2 | |
with: | |
path: ~/.cargo/git | |
key: ${{ runner.os }}-cargo-index | |
restore-keys: | | |
${{ runner.os }}-cargo-index | |
- name: Publish Robstride package to crates.io | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
run: | | |
cargo publish -p robstride |