合并 工作流
This commit is contained in:
@@ -1,85 +0,0 @@
|
|||||||
name: 发布至 crates.io
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
env:
|
|
||||||
CARGO_TERM_COLOR: always
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
# ============================================================
|
|
||||||
# 发布 chanlun 核心库至 crates.io
|
|
||||||
# ============================================================
|
|
||||||
publish-chanlun:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: 安装 Rust 工具链
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
with:
|
|
||||||
components: rustfmt, clippy
|
|
||||||
|
|
||||||
- name: 缓存依赖
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.cargo/registry
|
|
||||||
~/.cargo/git
|
|
||||||
target
|
|
||||||
key: ${{ runner.os }}-cargo-${{ hashFiles('chanlun/Cargo.lock') }}
|
|
||||||
|
|
||||||
- name: 提取版本号
|
|
||||||
id: version
|
|
||||||
working-directory: chanlun
|
|
||||||
run: |
|
|
||||||
VER=$(cargo metadata --format-version 1 --no-deps 2>/dev/null \
|
|
||||||
| jq -r '.packages[] | select(.name == "chanlun") | .version')
|
|
||||||
echo "version=$VER" >> $GITHUB_OUTPUT
|
|
||||||
echo "当前版本: $VER"
|
|
||||||
|
|
||||||
- name: 检查版本是否已存在
|
|
||||||
id: check
|
|
||||||
run: |
|
|
||||||
VER="${{ steps.version.outputs.version }}"
|
|
||||||
EXISTS=$(curl -sS "https://crates.io/api/v1/crates/chanlun" \
|
|
||||||
| jq -r --arg v "$VER" '.versions[]?.num // empty | select(. == $v)')
|
|
||||||
if [ -n "$EXISTS" ]; then
|
|
||||||
echo "版本 $VER 已存在于 crates.io,跳过发布"
|
|
||||||
echo "exists=true" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
echo "版本 $VER 未发布,继续"
|
|
||||||
echo "exists=false" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: 格式检查
|
|
||||||
if: steps.check.outputs.exists == 'false'
|
|
||||||
working-directory: chanlun
|
|
||||||
run: cargo fmt --check
|
|
||||||
|
|
||||||
- name: Lint 检查
|
|
||||||
if: steps.check.outputs.exists == 'false'
|
|
||||||
working-directory: chanlun
|
|
||||||
run: cargo clippy -- -D warnings
|
|
||||||
|
|
||||||
- name: 运行测试
|
|
||||||
if: steps.check.outputs.exists == 'false'
|
|
||||||
working-directory: chanlun
|
|
||||||
run: cargo test
|
|
||||||
|
|
||||||
- name: 验证打包
|
|
||||||
if: steps.check.outputs.exists == 'false'
|
|
||||||
working-directory: chanlun
|
|
||||||
run: cargo package --dry-run
|
|
||||||
|
|
||||||
- name: 登录 crates.io
|
|
||||||
if: steps.check.outputs.exists == 'false'
|
|
||||||
run: cargo login ${{ secrets.CARGO_TOKEN }}
|
|
||||||
|
|
||||||
- name: 发布 chanlun 至 crates.io
|
|
||||||
if: steps.check.outputs.exists == 'false'
|
|
||||||
working-directory: chanlun
|
|
||||||
run: cargo publish
|
|
||||||
@@ -16,9 +16,87 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Linux x86_64 (manylinux)
|
# 1. 发布 chanlun 核心库至 crates.io
|
||||||
|
# ============================================================
|
||||||
|
publish-crates:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
version: ${{ steps.version.outputs.version }}
|
||||||
|
exists: ${{ steps.check.outputs.exists }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: 安装 Rust 工具链
|
||||||
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
components: rustfmt, clippy
|
||||||
|
|
||||||
|
- name: 缓存依赖
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo/registry
|
||||||
|
~/.cargo/git
|
||||||
|
target
|
||||||
|
key: ${{ runner.os }}-cargo-${{ hashFiles('chanlun/Cargo.lock') }}
|
||||||
|
|
||||||
|
- name: 提取版本号
|
||||||
|
id: version
|
||||||
|
working-directory: chanlun
|
||||||
|
run: |
|
||||||
|
VER=$(cargo metadata --format-version 1 --no-deps 2>/dev/null \
|
||||||
|
| jq -r '.packages[] | select(.name == "chanlun") | .version')
|
||||||
|
echo "version=$VER" >> $GITHUB_OUTPUT
|
||||||
|
echo "当前版本: $VER"
|
||||||
|
|
||||||
|
- name: 检查版本是否已存在
|
||||||
|
id: check
|
||||||
|
run: |
|
||||||
|
VER="${{ steps.version.outputs.version }}"
|
||||||
|
EXISTS=$(curl -sS "https://crates.io/api/v1/crates/chanlun" \
|
||||||
|
| jq -r --arg v "$VER" '.versions[]?.num // empty | select(. == $v)')
|
||||||
|
if [ -n "$EXISTS" ]; then
|
||||||
|
echo "版本 $VER 已存在于 crates.io,跳过发布"
|
||||||
|
echo "exists=true" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "版本 $VER 未发布,继续"
|
||||||
|
echo "exists=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: 格式检查
|
||||||
|
if: steps.check.outputs.exists == 'false'
|
||||||
|
working-directory: chanlun
|
||||||
|
run: cargo fmt --check
|
||||||
|
|
||||||
|
- name: Lint 检查
|
||||||
|
if: steps.check.outputs.exists == 'false'
|
||||||
|
working-directory: chanlun
|
||||||
|
run: cargo clippy -- -D warnings
|
||||||
|
|
||||||
|
- name: 运行测试
|
||||||
|
if: steps.check.outputs.exists == 'false'
|
||||||
|
working-directory: chanlun
|
||||||
|
run: cargo test
|
||||||
|
|
||||||
|
- name: 验证打包
|
||||||
|
if: steps.check.outputs.exists == 'false'
|
||||||
|
working-directory: chanlun
|
||||||
|
run: cargo package --dry-run
|
||||||
|
|
||||||
|
- name: 登录 crates.io
|
||||||
|
if: steps.check.outputs.exists == 'false'
|
||||||
|
run: cargo login ${{ secrets.CARGO_TOKEN }}
|
||||||
|
|
||||||
|
- name: 发布 chanlun 至 crates.io
|
||||||
|
if: steps.check.outputs.exists == 'false'
|
||||||
|
working-directory: chanlun
|
||||||
|
run: cargo publish
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# 2. 构建 wheel — Linux x86_64 (manylinux)
|
||||||
# ============================================================
|
# ============================================================
|
||||||
linux-x86_64:
|
linux-x86_64:
|
||||||
|
needs: [publish-crates]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -31,6 +109,10 @@ jobs:
|
|||||||
- name: 安装 Rust 工具链
|
- name: 安装 Rust 工具链
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
|
- name: 更新 cargo 索引(确保新版本可见)
|
||||||
|
run: cargo update
|
||||||
|
working-directory: chanlun-py
|
||||||
|
|
||||||
- name: 构建 wheel (manylinux)
|
- name: 构建 wheel (manylinux)
|
||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
with:
|
with:
|
||||||
@@ -45,11 +127,11 @@ jobs:
|
|||||||
name: wheels-linux-x86_64
|
name: wheels-linux-x86_64
|
||||||
path: chanlun-py/dist/
|
path: chanlun-py/dist/
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# macOS wheels (x86_64 + arm64)
|
# 3. 构建 wheel — macOS (x86_64 + arm64)
|
||||||
# ============================================================
|
# ============================================================
|
||||||
macos:
|
macos:
|
||||||
|
needs: [publish-crates]
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
@@ -65,6 +147,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version: '3.12'
|
python-version: '3.12'
|
||||||
|
|
||||||
|
- name: 更新 cargo 索引
|
||||||
|
run: cargo update
|
||||||
|
working-directory: chanlun-py
|
||||||
|
|
||||||
- name: 构建 wheel
|
- name: 构建 wheel
|
||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
with:
|
with:
|
||||||
@@ -79,9 +165,10 @@ jobs:
|
|||||||
path: chanlun-py/dist/
|
path: chanlun-py/dist/
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# Windows wheels (x86_64)
|
# 4. 构建 wheel — Windows x86_64
|
||||||
# ============================================================
|
# ============================================================
|
||||||
windows:
|
windows:
|
||||||
|
needs: [publish-crates]
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
@@ -97,6 +184,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version: '3.12'
|
python-version: '3.12'
|
||||||
|
|
||||||
|
- name: 更新 cargo 索引
|
||||||
|
run: cargo update
|
||||||
|
working-directory: chanlun-py
|
||||||
|
|
||||||
- name: 构建 wheel
|
- name: 构建 wheel
|
||||||
uses: PyO3/maturin-action@v1
|
uses: PyO3/maturin-action@v1
|
||||||
with:
|
with:
|
||||||
@@ -111,9 +202,10 @@ jobs:
|
|||||||
path: chanlun-py/dist/
|
path: chanlun-py/dist/
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# 源码分发包 (sdist)
|
# 5. 源码分发包 (sdist)
|
||||||
# ============================================================
|
# ============================================================
|
||||||
sdist:
|
sdist:
|
||||||
|
needs: [publish-crates]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -137,14 +229,14 @@ jobs:
|
|||||||
path: chanlun-py/dist/
|
path: chanlun-py/dist/
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# 发布至 PyPI
|
# 6. 发布至 PyPI
|
||||||
# ============================================================
|
# ============================================================
|
||||||
publish:
|
publish:
|
||||||
needs: [linux-x86_64, macos, windows, sdist]
|
needs: [publish-crates, linux-x86_64, macos, windows, sdist]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.publish-to-pypi == 'true'
|
if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.publish-to-pypi == 'true'
|
||||||
permissions:
|
permissions:
|
||||||
id-token: write # PyPI 信任发布(推荐)
|
id-token: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: 下载所有产物
|
- name: 下载所有产物
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ crate-type = ["cdylib"]
|
|||||||
name = "chanlun"
|
name = "chanlun"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chanlun = { path = "../chanlun" }
|
chanlun = "26.5.5" # { path = "../chanlun" }
|
||||||
pyo3 = { version = "0.28", features = ["experimental-inspect"] }
|
pyo3 = { version = "0.28", features = ["experimental-inspect"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "chanlun"
|
name = "chanlun"
|
||||||
version = "26.5.4"
|
version = "26.5.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.70"
|
rust-version = "1.70"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|||||||
Reference in New Issue
Block a user