From 98f07508fa1b0a291e5b7a20d929672d3a2673ce Mon Sep 17 00:00:00 2001 From: YuWuKunCheng Date: Wed, 27 May 2026 00:07:54 +0800 Subject: [PATCH] Update workflows --- .github/workflows/publish.yml | 81 +++++++++++++++++++++++++++-------- chanlun-py/Cargo.toml | 2 - 2 files changed, 62 insertions(+), 21 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ac4901c..e6be808 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,36 +16,69 @@ env: jobs: # ============================================================ - # Linux wheels (x86_64 + aarch64) + # Linux x86_64 (manylinux) # ============================================================ - linux: + linux-x86_64: runs-on: ubuntu-latest - strategy: - matrix: - target: [x86_64, aarch64] steps: - uses: actions/checkout@v4 + - name: 安装 Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: 安装 Rust 工具链 uses: dtolnay/rust-toolchain@stable - - name: 构建 wheel + - name: 构建 wheel (manylinux) uses: PyO3/maturin-action@v1 with: - target: ${{ matrix.target }} + target: x86_64 working-directory: chanlun-py args: --release --out dist manylinux: auto - python-source: download - before-script-linux: | - if [ "${{ matrix.target }}" = "aarch64" ]; then - sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu - fi - name: 上传 wheel 产物 uses: actions/upload-artifact@v4 with: - name: wheels-linux-${{ matrix.target }} + name: wheels-linux-x86_64 + path: chanlun-py/dist/ + + # ============================================================ + # Linux aarch64 (宿主机交叉编译,非 manylinux) + # ============================================================ + linux-aarch64: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: 安装 Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: 安装 Rust 工具链 + aarch64 目标 + uses: dtolnay/rust-toolchain@stable + with: + targets: aarch64-unknown-linux-gnu + + - name: 安装 aarch64 交叉编译器 + run: | + sudo apt-get update + sudo apt-get install -y gcc-aarch64-linux-gnu + + - name: 构建 wheel + uses: PyO3/maturin-action@v1 + with: + target: aarch64 + working-directory: chanlun-py + args: --release --out dist + + - name: 上传 wheel 产物 + uses: actions/upload-artifact@v4 + with: + name: wheels-linux-aarch64 path: chanlun-py/dist/ # ============================================================ @@ -62,6 +95,11 @@ jobs: - name: 安装 Rust 工具链 uses: dtolnay/rust-toolchain@stable + - name: 安装 Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: 构建 wheel uses: PyO3/maturin-action@v1 with: @@ -89,6 +127,11 @@ jobs: - name: 安装 Rust 工具链 uses: dtolnay/rust-toolchain@stable + - name: 安装 Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: 构建 wheel uses: PyO3/maturin-action@v1 with: @@ -110,6 +153,11 @@ jobs: steps: - uses: actions/checkout@v4 + - name: 安装 Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: 构建 sdist uses: PyO3/maturin-action@v1 with: @@ -127,7 +175,7 @@ jobs: # 发布至 PyPI # ============================================================ publish: - needs: [linux, macos, windows, sdist] + needs: [linux-x86_64, linux-aarch64, macos, windows, sdist] runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.publish-to-pypi == 'true' permissions: @@ -148,8 +196,3 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 with: packages-dir: dist/ - # 使用 OIDC 信任发布(推荐),无需配置 token - # 若使用 API token,在 GitHub Secrets 中设置: - # PYPI_TOKEN: pypi-xxxxxxxxxxxx - # 然后将下一行改为: - # password: ${{ secrets.PYPI_TOKEN }} diff --git a/chanlun-py/Cargo.toml b/chanlun-py/Cargo.toml index cfe226b..140637e 100644 --- a/chanlun-py/Cargo.toml +++ b/chanlun-py/Cargo.toml @@ -12,8 +12,6 @@ crate-type = ["cdylib"] name = "chanlun" [dependencies] -# 发布至 PyPI 前,需先将 chanlun 发布至 crates.io,然后替换为版本号依赖: -# chanlun = "0.1" chanlun = "26.5.1" # { path = "../chanlun" } pyo3 = { version = "0.28", features = ["extension-module"] } serde_json = "1"