-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (129 loc) · 4.56 KB
/
build.yml
File metadata and controls
151 lines (129 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
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: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- 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
${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:${{ github.event.inputs.version || github.ref_name }}
${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:latest