-
Notifications
You must be signed in to change notification settings - Fork 124
133 lines (117 loc) · 3.53 KB
/
Copy pathrelease.yml
File metadata and controls
133 lines (117 loc) · 3.53 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
name: Build and Release
# 当推送 tag 时触发(如 v1.0.0, v1.2.3)
on:
push:
tags:
- 'v*'
jobs:
# 多平台并行构建
build:
strategy:
# 即使某个平台构建失败,也继续构建其他平台
fail-fast: false
matrix:
include:
# Windows 构建
- os: windows-latest
platform: win
build_cmd: npm run dist:win
artifact_name: release-windows
artifact_path: |
release/*.exe
release/*.zip
# macOS 构建
- os: macos-latest
platform: mac
build_cmd: npm run dist:mac
artifact_name: release-macos
artifact_path: |
release/*.dmg
# Linux 构建
- os: ubuntu-latest
platform: linux
build_cmd: npm run dist:linux
artifact_name: release-linux
artifact_path: |
release/*.AppImage
release/*.deb
runs-on: ${{ matrix.os }}
steps:
# 1. 检出代码
- name: Checkout code
uses: actions/checkout@v4
# 2. 安装 Node.js
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
# 3. 安装依赖
- name: Install dependencies
run: npm ci
# 4. 打包 Electron 应用
- name: Build Electron app for ${{ matrix.platform }}
run: ${{ matrix.build_cmd }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 5. 上传构建产物
- name: Upload ${{ matrix.platform }} artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_path }}
retention-days: 5
# 创建 Release 并上传所有平台的文件
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract release notes
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "Extracting release notes for version $VERSION"
awk "/^## \[$VERSION\]/{flag=1;next} /^## /{flag=0} flag" CHANGELOG.md > RELEASE_NOTE.md
cat RELEASE_NOTE.md
# 下载所有平台的构建产物
- name: Download Windows artifacts
uses: actions/download-artifact@v4
with:
name: release-windows
path: ./release
continue-on-error: true
- name: Download macOS artifacts
uses: actions/download-artifact@v4
with:
name: release-macos
path: ./release
continue-on-error: true
- name: Download Linux artifacts
uses: actions/download-artifact@v4
with:
name: release-linux
path: ./release
continue-on-error: true
# 列出所有下载的文件(调试用)
- name: List release files
run: |
echo "=== Release files ==="
ls -la ./release || echo "No release directory"
# 创建 Release 并上传文件
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
release/*.exe
release/*.zip
release/*.dmg
release/*.AppImage
release/*.deb
body_path: RELEASE_NOTE.md
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}