v0.1.3-rc.1

This commit is contained in:
wisdgod
2024-12-30 23:29:37 +08:00
parent ea1acb555f
commit 5505ccc6cb
41 changed files with 9626 additions and 1215 deletions

View File

@@ -1,6 +1,7 @@
name: Build
on:
workflow_dispatch:
push:
tags:
- 'v*'
@@ -28,7 +29,8 @@ jobs:
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'scripts/package.json'
cache-dependency-path: 'scripts/package-lock.json'
run: cd scripts && npm install && cd ..
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
@@ -44,10 +46,11 @@ jobs:
protobuf-compiler \
pkg-config \
libssl-dev \
openssl
# 安装 npm 依赖
cd scripts && npm install && cd ..
openssl \
musl-tools \
musl-dev \
libssl-dev:native \
linux-libc-dev:native
# 设置 OpenSSL 环境变量
echo "OPENSSL_DIR=/usr" >> $GITHUB_ENV
@@ -55,72 +58,21 @@ jobs:
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
run: |
# 使用 musl 目标
rustup target remove x86_64-unknown-linux-gnu
rustup target add x86_64-unknown-linux-musl
# 设置静态编译环境变量
export CC=musl-gcc
bash scripts/build.sh --static
- name: Install macOS dependencies
if: runner.os == 'macOS'
@@ -137,18 +89,30 @@ jobs:
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 ..
choco install -y nodejs-lts
- name: Build (Dynamic)
if: runner.os != 'Linux' && runner.os != 'FreeBSD'
# 刷新环境变量
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
# 设置 OpenSSL 环境变量
echo "OPENSSL_DIR=C:\Program Files\OpenSSL" >> $env:GITHUB_ENV
echo "PKG_CONFIG_PATH=C:\Program Files\OpenSSL\lib\pkgconfig" >> $env:GITHUB_ENV
- name: Build macOS (Dynamic)
if: runner.os == 'macOS' || runner.os == 'Windows'
run: bash scripts/build.sh
- name: Build (Static)
if: runner.os != 'Linux' && runner.os != 'FreeBSD'
- name: Build macOS (Static)
if: runner.os == 'macOS' || runner.os == 'Windows'
run: bash scripts/build.sh --static
# - name: Verify build artifacts
# run: |
# if [ ! -d "release" ] || [ -z "$(ls -A release)" ]; then
# echo "Error: No build artifacts found in release directory"
# exit 1
# fi
- name: Upload artifacts
uses: actions/upload-artifact@v4.5.0
with:
@@ -184,7 +148,11 @@ jobs:
bash \
gmake \
pkgconf \
openssl
openssl \
libressl-devel \
libiconv \
gettext-tools \
gettext-runtime
export SSL_CERT_FILE=/etc/ssl/cert.pem
@@ -192,11 +160,8 @@ jobs:
cd /root
git clone $GITHUB_SERVER_URL/$GITHUB_REPOSITORY .
# 然后再进入 scripts 目录
cd scripts && npm install && cd ..
# 安装 rustup 和 Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain nightly
# 设置持久化的 Rust 环境变量
echo '. "$HOME/.cargo/env"' >> /root/.profile
@@ -210,7 +175,6 @@ jobs:
# 加载环境变量
. /root/.profile
# 构建
echo "构建动态链接版本..."
/usr/local/bin/bash scripts/build.sh

View File

@@ -2,6 +2,12 @@ name: Docker Build and Push
on:
workflow_dispatch:
inputs:
update_latest:
description: '是否更新 latest 标签'
required: true
type: boolean
default: false
push:
tags:
- 'v*'
@@ -36,6 +42,7 @@ jobs:
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable=${{ github.event_name == 'workflow_dispatch' && inputs.update_latest }}
type=raw,value=${{ steps.cargo_version.outputs.version }},enable=${{ github.event_name == 'workflow_dispatch' }}
type=ref,event=tag,enable=${{ github.event_name == 'push' }}
@@ -44,12 +51,14 @@ jobs:
with:
driver-opts: |
image=moby/buildkit:latest
network=host
- name: Build and push Docker image
uses: docker/build-push-action@v6.10.0
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha