Skip to content

Commit

Permalink
Merge pull request #176 from J-ZhengLi/luuuxxx
Browse files Browse the repository at this point in the history
新增musl构建版本
  • Loading branch information
LuuuXXX authored Dec 12, 2024
2 parents e1a06df + d3fb185 commit 0b3bc2d
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 9 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,22 @@ jobs:
fail-fast: true
matrix:
include:
- name: dist-aarch64-linux
- name: dist-aarch64-linux-gnu
os: ubuntu-20.04
target: aarch64-unknown-linux-gnu

- name: dist-x86-64-linux
- name: dist-x86-64-linux-gnu
os: ubuntu-20.04
target: x86_64-unknown-linux-gnu

- name: dist-aarch64-linux-musl
os: ubuntu-20.04
target: aarch64-unknown-linux-musl

- name: dist-x86-64-linux-musl
os: ubuntu-20.04
target: x86_64-unknown-linux-musl

- name: dist-windows-msvc
os: windows-latest
target: x86_64-pc-windows-msvc
Expand All @@ -38,10 +46,18 @@ jobs:
uses: actions/checkout@v4

- name: Set up QEMU for ARM64
if: matrix.target == 'aarch64-unknown-linux-gnu'
if: contains(matrix.target, 'aarch64')
uses: docker/setup-qemu-action@v2
with:
platforms: aarch64

- name: Set up QEMU for multiple cores
if: contains(matrix.target, 'aarch64')
run: |
echo "Setting up QEMU with multiple cores"
export QEMU_CPUS=4 # 设置虚拟 CPU 核心数为 4
# 设置 QEMU 使用多个核心
echo "Using $QEMU_CPUS CPUs with QEMU"
- name: run build job
run: bash ci/run.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
RUN npm set strict-ssl false && npm install -g pnpm

# 安装 Tauri CLI
RUN cargo install [email protected]
# RUN cargo install [email protected]
COPY ci/scripts/install-tauri-cli.sh /scripts/
RUN chmod +x /scripts/install-tauri-cli.sh && \
/scripts/install-tauri-cli.sh

# 执行项目构建
CMD cargo dev vendor && \
Expand Down
43 changes: 43 additions & 0 deletions ci/docker/dist-aarch64-linux-musl/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 使用 Ubuntu 20.04 ARM 版本作为基础镜像
FROM arm64v8/ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

# 更新系统并安装必要的软件包
RUN apt-get update && \
apt-get install -y \
make \
curl \
wget \
file \
libssl-dev \
libgtk-3-dev \
libwebkit2gtk-4.0-dev \
libappindicator3-dev \
librsvg2-dev \
perl \
musl-tools

# 安装 Rust(确保是适用于 ARM 的目标)
COPY ci/scripts/install-rust.sh /scripts/
RUN chmod +x /scripts/install-rust.sh && \
/scripts/install-rust.sh
ENV PATH=$PATH:/root/.cargo/bin

RUN rustup target add aarch64-unknown-linux-musl
ENV HOST_TRIPPLE aarch64-unknown-linux-musl

# 安装 Node.js 18.x
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y nodejs
RUN npm set strict-ssl false && npm install -g pnpm

# 安装 Tauri CLI
# RUN cargo install [email protected]
COPY ci/scripts/install-tauri-cli.sh /scripts/
RUN chmod +x /scripts/install-tauri-cli.sh && \
/scripts/install-tauri-cli.sh

# 执行项目构建
CMD cargo dev vendor && \
cargo dev dist
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
RUN npm set strict-ssl false && npm install -g pnpm

# 安装 Tauri CLI
RUN cargo install [email protected]
# RUN cargo install [email protected]
COPY ci/scripts/install-tauri-cli.sh /scripts/
RUN chmod +x /scripts/install-tauri-cli.sh && \
/scripts/install-tauri-cli.sh

# 执行项目构建
CMD cargo dev vendor && \
Expand Down
43 changes: 43 additions & 0 deletions ci/docker/dist-x86-64-linux-musl/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 使用 Ubuntu 20.04 作为基础镜像
FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

# 更新系统并安装必要的软件包
RUN apt-get update && \
apt-get install -y \
make \
curl \
wget \
file \
libssl-dev \
libgtk-3-dev \
libwebkit2gtk-4.0-dev \
libappindicator3-dev \
librsvg2-dev \
perl \
musl-tools

# 安装 Rust
COPY ci/scripts/install-rust.sh /scripts/
RUN chmod +x /scripts/install-rust.sh && \
/scripts/install-rust.sh
ENV PATH=$PATH:/root/.cargo/bin

RUN rustup target add x86_64-unknown-linux-musl
ENV HOST_TRIPPLE x86_64-unknown-linux-musl

# 安装 Node.js 18.x
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
apt-get install -y nodejs
RUN npm set strict-ssl false && npm install -g pnpm

# 安装 Tauri CLI
# RUN cargo install [email protected]
COPY ci/scripts/install-tauri-cli.sh /scripts/
RUN chmod +x /scripts/install-tauri-cli.sh && \
/scripts/install-tauri-cli.sh

# 执行项目构建
CMD cargo dev vendor && \
cargo dev dist
20 changes: 20 additions & 0 deletions ci/scripts/install-tauri-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

mkdir ./cargo_tauri

if [ "$(uname -s)" = "Linux" ]; then
if [ "$(uname -m)" = "x86_64" ]; then
curl -OL https://github.com/LuuuXXX/tauri-mirror/releases/download/tauri-cli-v1.6.3/cargo-tauri-x86_64-unknown-linux-gnu.tgz
tar -xf cargo-tauri-x86_64-unknown-linux-gnu.tgz -C ./cargo_tauri
else
curl -OL https://github.com/LuuuXXX/tauri-mirror/releases/download/tauri-cli-v1.6.3/cargo-tauri-aarch64-unknown-linux-gnu.tgz
tar -xf cargo-tauri-aarch64-unknown-linux-gnu.tgz -C ./cargo_tauri
fi
mv ./cargo_tauri/cargo-tauri ~/.cargo/bin
else
curl -OL https://github.com/LuuuXXX/tauri-mirror/releases/download/tauri-cli-v1.6.3/cargo-tauri-x86_64-pc-windows-msvc.zip
unzip cargo-tauri-x86_64-pc-windows-msvc.zip -d ./cargo_tauri
mv ./cargo_tauri/cargo-tauri.exe ~/.cargo/bin
fi

rm -r ./cargo_tauri
13 changes: 10 additions & 3 deletions ci/scripts/run-with-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,16 @@ else
echo "Invalid docker image: $image"
fi

# run ther docker image.
# 运行 Docker 容器
if [[ "$image" == *"aarch64"* ]]; then
docker run --platform linux/arm64 --workdir /checkout/obj -v "$source_dir:/checkout/obj" --init --rm rim-ci
# 设置 QEMU_CPUS 环境变量并运行容器,支持多核配置
docker run -e QEMU_CPUS=${QEMU_CPUS:-4} --platform linux/arm64 \
--workdir /checkout/obj \
-v "$source_dir:/checkout/obj" \
--init --rm rim-ci
else
docker run --workdir /checkout/obj -v "$source_dir:/checkout/obj" --init --rm rim-ci
# 默认处理其他架构
docker run --workdir /checkout/obj \
-v "$source_dir:/checkout/obj" \
--init --rm rim-ci
fi
3 changes: 2 additions & 1 deletion ci/scripts/run-without-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ sh ci/scripts/install-nodejs.sh
npm set strict-ssl false && npm install -g pnpm

# 安装 Tauri CLI
cargo install [email protected]
# cargo install [email protected]
sh ci/scripts/install-tauri-cli.sh

echo "Execiting cargo dev vendor"
cargo dev vendor
Expand Down

0 comments on commit 0b3bc2d

Please sign in to comment.