Skip to content

Build and Release

Build and Release #4

Workflow file for this run

name: Build and Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: '版本号 (例如: v1.0.0)'
required: true
default: 'v1.0.0'
permissions:
contents: write
packages: write
id-token: write
jobs:
build-tauri:
strategy:
fail-fast: false
matrix:
platform:
# Linux x86_64
- os: ubuntu-22.04
rust_target: x86_64-unknown-linux-gnu
# macOS Intel
- os: macos-latest
rust_target: x86_64-apple-darwin
# macOS Apple Silicon (ARM64)
- os: macos-latest
rust_target: aarch64-apple-darwin
# Windows x86_64
- os: windows-latest
rust_target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.platform.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies (Ubuntu only)
if: matrix.platform.os == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libssl-dev
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: '9.0.0'
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.rust_target }}
- name: Install frontend dependencies
run: pnpm install --frozen-lockfile
- name: Build Tauri app
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ""
with:
projectPath: desktop
tagName: ${{ github.ref_name }}
releaseName: 'CloudPaste ${{ github.ref_name }}'
releaseBody: |
## 下载说明
- **Windows**: 下载 `.msi` 或 `.exe` 安装包
- **macOS**: 下载 `.dmg` 文件(支持 Intel 和 Apple Silicon)
- **Linux**: 下载 `.AppImage` 或 `.deb` 包
releaseDraft: false
prerelease: false
args: --target ${{ matrix.platform.rust_target }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform.os }}-${{ matrix.platform.rust_target }}
path: |
desktop/src-tauri/target/${{ matrix.platform.rust_target }}/release/bundle/
retention-days: 7
build-docker:
# 只在标准版本号时构建 Docker 镜像(不包含 beta 等后缀)
if: github.event_name == 'push' && !contains(github.ref_name, '-') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9.0.0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build frontend
run: pnpm run build
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.event.inputs.version || github.ref_name }}
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest