From d3c7243d3376b272cc6d4d3dbd3c41f930ebc36e Mon Sep 17 00:00:00 2001 From: titor Date: Fri, 24 Apr 2026 03:44:37 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E5=A4=9A=E5=B9=B3=E5=8F=B0=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=20=E6=94=AF=E6=8C=81=20matrix=20=E5=92=8C=E4=BA=A4?= =?UTF-8?q?=E5=8F=89=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用 Ubuntu 24.04 runner - 添加 cargo 镜像源 - 在一个 job 中顺序构建所有平台 - 支持:linux-amd64, linux-arm64, darwin-amd64, darwin-arm64, windows-amd64 - 每次 push 到 main 自动更新 release --- .github/workflows/release.yml | 48 +++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 09e3ff2..09a6e2c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,30 +8,40 @@ on: jobs: build: runs-on: ubuntu24.04 - container: - image: rust:1.82 steps: - name: Setup mirrors run: | - # 使用阿里云 apk 镜像源 - echo -e 'https://mirrors.aliyun.com/alpine/v3.20/main/\nhttps://mirrors.aliyun.com/alpine/v3.20/community/' > /etc/apk/repositories - apk add git + echo 'deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse' | tee /etc/apt/sources.list + apt-get update -qq + + - name: Install Rust + run: | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + . "$HOME/.cargo/env" + + # 安装交叉编译目标 + rustup target add aarch64-unknown-linux-gnu || true + rustup target add x86_64-apple-darwin || true + rustup target add aarch64-apple-darwin || true + rustup target add x86_64-pc-windows-gnu || true - name: Setup cargo mirror run: | - # 使用阿里云 cargo 镜像源 mkdir -p ~/.cargo - echo '[source.crates-io] - replace-with = "ustc" - - [source.ustc] - registry = "sparse+https://mirrors.ustc.edu.cn/crates.io/index/"' > ~/.cargo/config.toml + cat > ~/.cargo/config.toml << 'CARGO_EOF' +[source.crates-io] +replace-with = "ustc" + +[source.ustc] +registry = "sparse+https://mirrors.ustc.edu.cn/crates.io/index/" +CARGO_EOF - name: Checkout code run: git clone https://hub.gaomia.site/titor/haibao-tts-cli.git /workspace/mimo-tts - - name: Build binaries + - name: Build all binaries run: | + . "$HOME/.cargo/env" cd /workspace/mimo-tts # Linux x86_64 @@ -39,8 +49,20 @@ jobs: mv target/release/mimo-tts mimo-tts-linux-amd64 # Linux ARM64 - GOOS=linux GOARCH=arm64 cargo build --release -p mimo-tts + GOOS=linux GOARCH=arm64 cargo build --release -p mimo-tts --target aarch64-unknown-linux-gnu mv target/release/mimo-tts mimo-tts-linux-arm64 + + # macOS x86_64 + GOOS=darwin GOARCH=amd64 cargo build --release -p mimo-tts --target x86_64-apple-darwin + mv target/release/mimo-tts mimo-tts-darwin-amd64 + + # macOS ARM64 + GOOS=darwin GOARCH=arm64 cargo build --release -p mimo-tts --target aarch64-apple-darwin + mv target/release/mimo-tts mimo-tts-darwin-arm64 + + # Windows x86_64 + GOOS=windows GOARCH=amd64 cargo build --release -p mimo-tts --target x86_64-pc-windows-gnu + mv target/release/mimo-tts.exe mimo-tts-windows-amd64.exe - name: Generate checksums run: |