ci: 多平台构建 支持 matrix 和交叉编译
- 使用 Ubuntu 24.04 runner - 添加 cargo 镜像源 - 在一个 job 中顺序构建所有平台 - 支持:linux-amd64, linux-arm64, darwin-amd64, darwin-arm64, windows-amd64 - 每次 push 到 main 自动更新 release
This commit is contained in:
46
.github/workflows/release.yml
vendored
46
.github/workflows/release.yml
vendored
@@ -8,30 +8,40 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu24.04
|
runs-on: ubuntu24.04
|
||||||
container:
|
|
||||||
image: rust:1.82
|
|
||||||
steps:
|
steps:
|
||||||
- name: Setup mirrors
|
- name: Setup mirrors
|
||||||
run: |
|
run: |
|
||||||
# 使用阿里云 apk 镜像源
|
echo 'deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse' | tee /etc/apt/sources.list
|
||||||
echo -e 'https://mirrors.aliyun.com/alpine/v3.20/main/\nhttps://mirrors.aliyun.com/alpine/v3.20/community/' > /etc/apk/repositories
|
apt-get update -qq
|
||||||
apk add git
|
|
||||||
|
- 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
|
- name: Setup cargo mirror
|
||||||
run: |
|
run: |
|
||||||
# 使用阿里云 cargo 镜像源
|
|
||||||
mkdir -p ~/.cargo
|
mkdir -p ~/.cargo
|
||||||
echo '[source.crates-io]
|
cat > ~/.cargo/config.toml << 'CARGO_EOF'
|
||||||
replace-with = "ustc"
|
[source.crates-io]
|
||||||
|
replace-with = "ustc"
|
||||||
|
|
||||||
[source.ustc]
|
[source.ustc]
|
||||||
registry = "sparse+https://mirrors.ustc.edu.cn/crates.io/index/"' > ~/.cargo/config.toml
|
registry = "sparse+https://mirrors.ustc.edu.cn/crates.io/index/"
|
||||||
|
CARGO_EOF
|
||||||
|
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
run: git clone https://hub.gaomia.site/titor/haibao-tts-cli.git /workspace/mimo-tts
|
run: git clone https://hub.gaomia.site/titor/haibao-tts-cli.git /workspace/mimo-tts
|
||||||
|
|
||||||
- name: Build binaries
|
- name: Build all binaries
|
||||||
run: |
|
run: |
|
||||||
|
. "$HOME/.cargo/env"
|
||||||
cd /workspace/mimo-tts
|
cd /workspace/mimo-tts
|
||||||
|
|
||||||
# Linux x86_64
|
# Linux x86_64
|
||||||
@@ -39,9 +49,21 @@ jobs:
|
|||||||
mv target/release/mimo-tts mimo-tts-linux-amd64
|
mv target/release/mimo-tts mimo-tts-linux-amd64
|
||||||
|
|
||||||
# Linux ARM64
|
# 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
|
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
|
- name: Generate checksums
|
||||||
run: |
|
run: |
|
||||||
cd /workspace/mimo-tts
|
cd /workspace/mimo-tts
|
||||||
|
|||||||
Reference in New Issue
Block a user