-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (130 loc) · 3.66 KB
/
executable-tutorial.yml
File metadata and controls
151 lines (130 loc) · 3.66 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: Executable Tutorial CI/CD
on:
push:
branches: [ main, develop ]
paths:
- 'apps/desktop/**'
- 'packages/**'
- '.github/workflows/executable-tutorial.yml'
pull_request:
branches: [ main, develop ]
paths:
- 'apps/desktop/**'
- 'packages/**'
workflow_dispatch:
inputs:
task:
description: 'Task to execute'
required: true
default: 'build'
type: choice
options:
- build
- test
- lint
- release
env:
CARGO_TERM_COLOR: always
NODE_VERSION: '20'
jobs:
# 代码检查和测试
check:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Setup Rust
uses: dtolnay/rust-action@stable
- name: Install dependencies
run: |
npm ci
cd apps/desktop && npm ci
- name: Run linter
run: |
cd apps/desktop
npm run lint
continue-on-error: true
- name: Run tests
run: |
cd apps/desktop
npm run test
continue-on-error: true
# 构建桌面应用
build:
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-latest
target: aarch64-apple-darwin
args: '--target aarch64-apple-darwin'
- os: macos-latest
target: x86_64-apple-darwin
args: '--target x86_64-apple-darwin'
- os: windows-latest
target: x86_64-pc-windows-msvc
args: ''
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
args: ''
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Setup Rust
uses: dtolnay/rust-action@stable
with:
targets: ${{ matrix.target }}
- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf
- name: Install dependencies
run: |
npm ci
cd apps/desktop && npm ci
- name: Build Tauri app
run: |
cd apps/desktop/src-tauri
cargo build --release ${{ matrix.args }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: executable-tutorial-${{ matrix.target }}
path: |
apps/desktop/src-tauri/target/release/bundle/**/*.dmg
apps/desktop/src-tauri/target/release/bundle/**/*.app
apps/desktop/src-tauri/target/release/bundle/**/*.exe
apps/desktop/src-tauri/target/release/bundle/**/*.msi
apps/desktop/src-tauri/target/release/bundle/**/*.deb
apps/desktop/src-tauri/target/release/bundle/**/*.AppImage
# 发布版本
release:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: artifacts/**/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}