Update linux.yaml #10
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: linux | |
on: | |
push: | |
tags: | |
- '*' | |
jobs: | |
sdist: | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
env: | |
RUST_TOOLCHAIN: "1.72" # MSRV | |
steps: | |
- run: curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain $RUST_TOOLCHAIN -y | |
- run: rustup default $RUST_TOOLCHAIN | |
- uses: actions/checkout@v4 | |
- run: python3 -m pip install --user --upgrade pip "maturin>=1,<2" wheel | |
- run: maturin build | |
- run: cargo fetch | |
- run: mkdir .cargo | |
- run: maturin sdist --out=dist | |
- run: python3 -m pip install --user dist/rust_x3dh*.tar.gz | |
env: | |
CARGO_NET_OFFLINE: "true" | |
- name: Store sdist | |
if: "startsWith(github.ref, 'refs/tags/')" | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: dist | |
retention-days: 1 | |
musllinux_1_2: | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
python: [ | |
{ version: '3.12' }, | |
{ version: '3.11' }, | |
{ version: '3.10' }, | |
{ version: '3.9' }, | |
{ version: '3.8' }, | |
] | |
platform: | |
- target: aarch64-unknown-linux-musl | |
arch: aarch64 | |
platform: linux/arm64 | |
- target: x86_64-unknown-linux-musl | |
arch: x86_64 | |
platform: linux/amd64 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build | |
uses: PyO3/maturin-action@v1 | |
env: | |
CC: "gcc" | |
CFLAGS: "-O2" | |
LDFLAGS: "-O2 -flto -Wl,--as-needed" | |
RUSTFLAGS: "-C target-feature=-crt-static -Z mir-opt-level=4" | |
CARGO_UNSTABLE_SPARSE_REGISTRY: "true" | |
with: | |
rust-toolchain: nightly-2024-02-13 | |
rustup-components: rust-src | |
target: ${{ matrix.platform.target }} | |
manylinux: musllinux_1_2 | |
args: --release --strip --out=dist -i python${{ matrix.python.version }} | |
- name: Set up QEMU | |
if: matrix.platform.arch != 'x86_64' | |
uses: docker/setup-qemu-action@v3 | |
with: | |
image: tonistiigi/binfmt:qemu-v8.1.4 | |
platforms: ${{ matrix.platform.platform }} | |
- name: Store wheels | |
if: "startsWith(github.ref, 'refs/tags/')" | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: dist | |
retention-days: 1 | |
pypi: | |
name: PyPI | |
permissions: | |
# trusted publisher | |
id-token: write | |
contents: write | |
runs-on: ubuntu-22.04 | |
if: "startsWith(github.ref, 'refs/tags/')" | |
needs: [musllinux_1_2, sdist] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.9" | |
- name: Install dependencies | |
run: python -m pip install --upgrade pip setuptools wheel twine | |
- name: Build package | |
run: python setup.py sdist bdist_wheel | |
- name: Publish to PyPI | |
env: | |
TWINE_USERNAME: ${{ secrets.PYPI_USER_NAME }} | |
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
run: twine upload --skip-existing dist/* |