修复一些bug

This commit is contained in:
wisdgod
2024-12-25 07:02:50 +08:00
parent 3ab975a5b3
commit 8ea65649c3
8 changed files with 395 additions and 371 deletions

View File

@@ -6,156 +6,6 @@ on:
- 'v*'
jobs:
build:
name: Build ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: ubuntu-latest
targets: x86_64-unknown-linux-gnu
- os: windows-latest
targets: x86_64-pc-windows-msvc
- os: macos-latest
targets: x86_64-apple-darwin,aarch64-apple-darwin
steps:
- uses: actions/checkout@v4.2.2
- name: Setup Node.js
uses: actions/setup-node@v4.1.0
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'scripts/package.json'
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.targets }}
- name: Install Linux dependencies (x86_64)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
protobuf-compiler \
pkg-config \
libssl-dev \
openssl
# 安装 npm 依赖
cd scripts && npm install && cd ..
# 设置 OpenSSL 环境变量
echo "OPENSSL_DIR=/usr" >> $GITHUB_ENV
echo "OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu" >> $GITHUB_ENV
echo "OPENSSL_INCLUDE_DIR=/usr/include/openssl" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig" >> $GITHUB_ENV
# - name: Set up Docker Buildx
# if: runner.os == 'Linux'
# uses: docker/setup-buildx-action@v3.8.0
# - name: Build Linux arm64
# if: runner.os == 'Linux'
# run: |
# # 启用 QEMU 支持
# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
# # 创建 Dockerfile
# cat > Dockerfile.arm64 << 'EOF'
# FROM arm64v8/ubuntu:22.04
# ENV DEBIAN_FRONTEND=noninteractive
# RUN apt-get update && apt-get install -y \
# build-essential \
# curl \
# pkg-config \
# libssl-dev \
# protobuf-compiler \
# nodejs \
# npm \
# git \
# && rm -rf /var/lib/apt/lists/*
# # 安装 Rust
# RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
# ENV PATH="/root/.cargo/bin:${PATH}"
# WORKDIR /build
# COPY . .
# # 安装 npm 依赖
# RUN cd scripts && npm install && cd ..
# # 构建动态链接版本
# RUN cargo build --release
# # 构建静态链接版本
# RUN RUSTFLAGS="-C target-feature=+crt-static" cargo build --release
# EOF
# # 构建 arm64 版本
# docker buildx build --platform linux/arm64 -f Dockerfile.arm64 -t builder-arm64 .
# # 创建临时容器
# docker create --name temp-container builder-arm64 sh
# # 复制动态链接版本
# docker cp temp-container:/build/target/release/cursor-api ./release/cursor-api-aarch64-unknown-linux-gnu
# # 复制静态链接版本
# docker cp temp-container:/build/target/release/cursor-api ./release/cursor-api-static-aarch64-unknown-linux-gnu
# # 清理临时容器
# docker rm temp-container
- name: Build Linux x86_64 (Dynamic)
if: runner.os == 'Linux'
run: bash scripts/build.sh
- name: Build Linux x86_64 (Static)
if: runner.os == 'Linux'
run: bash scripts/build.sh --static
- name: Install macOS dependencies
if: runner.os == 'macOS'
run: |
brew install \
protobuf \
pkg-config \
openssl@3
echo "OPENSSL_DIR=$(brew --prefix openssl@3)" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$(brew --prefix openssl@3)/lib/pkgconfig" >> $GITHUB_ENV
- name: Install Windows dependencies
if: runner.os == 'Windows'
run: |
choco install -y protoc
choco install -y openssl
echo "OPENSSL_DIR=C:/Program Files/OpenSSL-Win64" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=C:/Program Files/OpenSSL-Win64/lib/pkgconfig" >> $GITHUB_ENV
cd scripts && npm install && cd ..
- name: Build (Dynamic)
if: runner.os != 'Linux' && runner.os != 'FreeBSD'
run: bash scripts/build.sh
- name: Build (Static)
if: runner.os != 'Linux' && runner.os != 'FreeBSD'
run: bash scripts/build.sh --static
- name: Upload artifacts
uses: actions/upload-artifact@v4.5.0
with:
name: binaries-${{ matrix.os }}
path: release/*
retention-days: 1
build-freebsd:
name: Build FreeBSD
runs-on: ubuntu-latest
@@ -226,7 +76,7 @@ jobs:
release:
name: Create Release
needs: [build, build-freebsd]
needs: [build-freebsd]
runs-on: ubuntu-latest
permissions:
contents: write