mirror of
https://github.com/zeke-chin/cursor-api.git
synced 2025-12-24 11:50:59 +08:00
124 lines
3.6 KiB
YAML
124 lines
3.6 KiB
YAML
name: Build and Release
|
|
|
|
on:
|
|
push:
|
|
# branches: [ "main" ]
|
|
tags: [ "v*" ]
|
|
# paths:
|
|
# - 'rs-capi/**'
|
|
# - '.github/workflows/**'
|
|
|
|
jobs:
|
|
# 构建各平台二进制文件
|
|
build-release:
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- os: ubuntu-latest
|
|
target: x86_64-unknown-linux-gnu
|
|
artifact_name: rs-capi-linux-x86_64.tar.gz
|
|
- os: ubuntu-latest
|
|
target: aarch64-unknown-linux-gnu
|
|
artifact_name: rs-capi-linux-aarch64.tar.gz
|
|
- os: macos-latest
|
|
target: x86_64-apple-darwin
|
|
artifact_name: rs-capi-darwin-x86_64.tar.gz
|
|
- os: macos-latest
|
|
target: aarch64-apple-darwin
|
|
artifact_name: rs-capi-darwin-aarch64.tar.gz
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup Rust
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
target: ${{ matrix.target }}
|
|
override: true
|
|
|
|
- name: Install dependencies
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu pkg-config libssl-dev crossbuild-essential-arm64 musl-tools libudev-dev
|
|
|
|
- name: Build
|
|
working-directory: rs-capi
|
|
env:
|
|
PKG_CONFIG_ALLOW_CROSS: "1"
|
|
OPENSSL_DIR: "/usr"
|
|
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: "aarch64-linux-gnu-gcc"
|
|
run: cargo build --release --target ${{ matrix.target }}
|
|
|
|
- name: Package
|
|
working-directory: rs-capi
|
|
run: |
|
|
tar -czf ../${{ matrix.artifact_name }} -C target/${{ matrix.target }}/release rs-capi
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ matrix.artifact_name }}
|
|
path: ${{ matrix.artifact_name }}
|
|
|
|
# 创建 GitHub Release
|
|
create-release:
|
|
needs: build-release
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
# 添加下载构建产物的步骤
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
path: artifacts
|
|
|
|
# 列出下载的文件(可选,用于调试)
|
|
- name: Display structure of downloaded files
|
|
run: ls -R artifacts/
|
|
|
|
- name: Create Release
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
tag_name: ${{ github.ref_name }}
|
|
files: artifacts/**/* # 修改为包含所有下载的构建产物
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
# 构建并发布 Docker 镜像
|
|
build-docker:
|
|
runs-on: ubuntu-latest
|
|
# 添加权限设置
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
# 添加 GHCR 登录步骤
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: rs-capi
|
|
file: rs-capi/Dockerfile
|
|
platforms: ${{ matrix.platform }}
|
|
push: true
|
|
tags: |
|
|
ghcr.io/${{ github.repository }}:latest
|
|
ghcr.io/${{ github.repository }}:${{ github.ref_name }} |