-
Notifications
You must be signed in to change notification settings - Fork 191
212 lines (185 loc) · 7.98 KB
/
Copy pathrelease.yml
File metadata and controls
212 lines (185 loc) · 7.98 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: Build and Release
on:
push:
tags:
- "v*"
workflow_dispatch:
jobs:
build:
strategy:
matrix:
include:
- os: macos-latest
platform: mac
- os: windows-latest
platform: win
arch: x64
- os: windows-latest
platform: win
arch: arm64
- os: ubuntu-latest
platform: linux
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
# 显式使用与 package.json 中一致的 pnpm 版本
version: 9.15.0
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Clean previous build artifacts
shell: bash
run: |
rm -rf dist || true
- name: Build for ${{ matrix.platform }} ${{ matrix.arch }}
shell: bash
run: |
if [ "${{ matrix.platform }}" = "win" ] && [ -n "${{ matrix.arch }}" ]; then
# Windows: build specific architecture
pnpm vite build && pnpm electron-builder --win --${{ matrix.arch }} --publish never
else
pnpm electron:build:${{ matrix.platform }}
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Normalize Windows update metadata
if: matrix.platform == 'win' && matrix.arch != ''
shell: bash
run: |
# Generate appropriate yml files for each architecture
# 为每个架构生成适当的 yml 文件
if [ "${{ matrix.arch }}" = "arm64" ]; then
if [ -f "dist/latest.yml" ]; then
# Rename to latest-arm64.yml for arm64 builds
mv dist/latest.yml dist/latest-arm64.yml
echo "Renamed latest.yml to latest-arm64.yml for ARM64"
fi
else
# x64: Generate BOTH latest.yml AND latest-x64.yml for backward compatibility
# x64: 同时生成 latest.yml 和 latest-x64.yml 以保持向后兼容
# - New versions (0.3.5+) use default behavior -> latest.yml
# - Old versions (0.3.4 and earlier) use channel='x64' -> latest-x64.yml
if [ -f "dist/latest.yml" ]; then
exe=$(ls dist/PromptHub-Setup-*-x64.exe 2>/dev/null | head -1 | xargs -I {} basename {})
if [ -n "$exe" ]; then
sed -i.bak "s/PromptHub-Setup-[0-9.]*\.exe/$exe/g" dist/latest.yml
rm -f dist/latest.yml.bak
echo "Updated latest.yml to point to $exe"
fi
# Create latest-x64.yml as a copy for backward compatibility with old versions
# 创建 latest-x64.yml 副本以兼容旧版本
cp dist/latest.yml dist/latest-x64.yml
echo "Created latest-x64.yml for backward compatibility"
fi
fi
# Remove duplicate NSIS blockmap without arch (prevents release upload errors)
shopt -s nullglob
for file in dist/*.exe.blockmap; do
case "$file" in
*-x64.exe.blockmap|*-arm64.exe.blockmap) ;;
*) rm -f "$file" ;;
esac
done
- name: Remove debug files
shell: bash
run: |
# 删除 builder-debug.yml
find dist -name "builder-debug.yml" -delete || true
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}-${{ matrix.arch || 'default' }}-build
path: |
dist/*.dmg
dist/*.zip
dist/*-x64.exe
dist/*-arm64.exe
dist/*.AppImage
dist/*.deb
dist/*.blockmap
dist/latest*.yml
if-no-files-found: ignore
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Set release version
shell: bash
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV"
- name: List artifacts for debugging
shell: bash
run: |
echo "=== Artifact structure ==="
find artifacts -type f -name "*.yml" -o -name "*.exe" -o -name "*.dmg" | head -50
- name: Delete existing release if exists
shell: bash
run: |
# Delete the existing release to avoid asset deletion conflicts
# Do NOT use --cleanup-tag, keep the tag for release action
gh release delete "${GITHUB_REF_NAME}" --yes || true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
uses: softprops/action-gh-release@v1
with:
fail_on_unmatched_files: false
files: |
artifacts/**/PromptHub-*-x64.dmg
artifacts/**/PromptHub-*-arm64.dmg
artifacts/**/PromptHub-Setup-*-x64.exe
artifacts/**/PromptHub-Setup-*-arm64.exe
artifacts/**/PromptHub-*-x64.AppImage
artifacts/**/prompthub_*_amd64.deb
artifacts/**/PromptHub-*.zip
artifacts/**/latest*.yml
artifacts/**/*.blockmap
draft: false
prerelease: ${{ contains(github.ref, 'beta') || contains(github.ref, 'alpha') }}
generate_release_notes: true
body: |
## 📦 下载安装
| 平台 | 下载 |
|------|------|
| Windows | [](https://github.com/legeling/PromptHub/releases/latest/download/PromptHub-Setup-${{ env.VERSION }}-x64.exe) [](https://github.com/legeling/PromptHub/releases/latest/download/PromptHub-Setup-${{ env.VERSION }}-arm64.exe) |
| macOS | [](https://github.com/legeling/PromptHub/releases/latest/download/PromptHub-${{ env.VERSION }}-arm64.dmg) [](https://github.com/legeling/PromptHub/releases/latest/download/PromptHub-${{ env.VERSION }}-x64.dmg) |
| Linux | [](https://github.com/legeling/PromptHub/releases/latest/download/PromptHub-${{ env.VERSION }}-x64.AppImage) [](https://github.com/legeling/PromptHub/releases/latest/download/prompthub_${{ env.VERSION }}_amd64.deb) |
### ⚠️ macOS 首次启动
如果提示"无法打开"或"已损坏",请在终端执行:
```bash
sudo xattr -rd com.apple.quarantine /Applications/PromptHub.app
```
---
## 🔄 本次更新
详细更新日志请查看 [更新日志](https://github.com/legeling/PromptHub#-更新日志)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}