Files
cursor-api/.github/workflows/build.yml
2024-12-25 08:33:41 +08:00

113 lines
2.7 KiB
YAML

name: Build
on:
push:
tags:
- 'v*'
jobs:
build-freebsd:
name: Build FreeBSD
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- name: Build on FreeBSD
uses: vmactions/freebsd-vm@v1.1.5
with:
usesh: true
prepare: |
# 设置持久化的环境变量
echo 'export SSL_CERT_FILE=/etc/ssl/cert.pem' >> /root/.profile
echo 'export PATH="/usr/local/bin:$PATH"' >> /root/.profile
# 安装基础依赖
pkg update
pkg install -y \
git \
curl \
node20 \
www/npm \
protobuf \
ca_root_nss \
bash \
gmake \
pkgconf \
openssl
export SSL_CERT_FILE=/etc/ssl/cert.pem
# 克隆代码(确保在正确的目录)
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
# 设置持久化的 Rust 环境变量
echo '. "$HOME/.cargo/env"' >> /root/.profile
# 添加所需的目标支持
. /root/.profile
rustup target add x86_64-unknown-freebsd
rustup component add rust-src
run: |
# 加载环境变量
. /root/.profile
# 构建
echo "构建动态链接版本..."
/usr/local/bin/bash scripts/build.sh
echo "构建静态链接版本..."
/usr/local/bin/bash scripts/build.sh --static
- name: Upload artifacts
uses: actions/upload-artifact@v4.5.0
with:
name: binaries-freebsd
path: release/*
retention-days: 1
release:
name: Create Release
needs: [build-freebsd]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4.2.2
- name: Download all artifacts
uses: actions/download-artifact@v4.1.8
with:
path: artifacts
- name: Prepare release assets
run: |
mkdir release
cd artifacts
for dir in binaries-*; do
cp -r "$dir"/* ../release/
done
- name: Generate checksums
run: |
cd release
sha256sum * > SHA256SUMS.txt
- name: Create Release
uses: softprops/action-gh-release@v2.2.0
with:
files: |
release/*
draft: false
prerelease: false
generate_release_notes: true
fail_on_unmatched_files: true