-
-
Notifications
You must be signed in to change notification settings - Fork 7
301 lines (274 loc) · 10.1 KB
/
Copy pathdeploy-release.yml
File metadata and controls
301 lines (274 loc) · 10.1 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
name: Deploy Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to deploy (e.g., 1.1.0)'
required: true
type: string
permissions:
contents: write
actions: read
jobs:
deploy-mac:
name: Build & Deploy macOS
runs-on: macos-latest
environment:
name: production
url: https://github.com/${{ github.repository }}/releases/tag/v${{ inputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: v${{ inputs.version }}
fetch-depth: 1
token: ${{ secrets.GITHUB_TOKEN }}
submodules: false
- name: Verify release tag exists
run: |
git fetch --tags --depth=1
if ! git rev-parse "v${{ inputs.version }}" >/dev/null 2>&1; then
echo "❌ Release tag v${{ inputs.version }} not found!"
echo "Available tags:"
git tag | grep "^v" | sort -V | tail -10
exit 1
fi
echo "✅ Release tag verified: v${{ inputs.version }}"
- name: Checkout main for version bump
uses: actions/checkout@v4
with:
ref: main
path: repo-version
- name: Update package.json version on main
id: bump-version
working-directory: repo-version
env:
VERSION: ${{ inputs.version }}
run: |
npm version "${VERSION}" --no-git-tag-version --allow-same-version
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add package.json package-lock.json
if git diff --staged --quiet; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "⚠️ Version already matches insights release, no commit created"
else
git commit -m "chore: bump version to v${VERSION}"
git push origin main
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
# Cache whisper.cpp build artifacts
# Note: Cache key includes script hash. To force rebuild after whisper.cpp upstream changes,
# either modify setup-whisper-cpp.sh or delete the cache manually in GitHub Actions settings.
- name: Cache whisper.cpp build
id: cache-whisper
uses: actions/cache@v4
with:
path: |
whisper.cpp/build-arm64
whisper.cpp/build-x86_64
bin/whisper-cli
key: whisper-cpp-universal-${{ runner.os }}-${{ hashFiles('scripts/setup-whisper-cpp.sh') }}
restore-keys: |
whisper-cpp-universal-${{ runner.os }}-
# Cache electron-builder's default cache location on macOS
- name: Cache Electron
uses: actions/cache@v4
with:
path: |
~/Library/Caches/electron
~/Library/Caches/electron-builder
key: electron-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
electron-${{ runner.os }}-
- name: Install dependencies
run: npm ci --prefer-offline
- name: Update package.json version
run: |
npm version ${{ inputs.version }} --no-git-tag-version --allow-same-version
echo "✅ Updated package.json to version ${{ inputs.version }}"
- name: Build whisper.cpp (universal binary)
if: steps.cache-whisper.outputs.cache-hit != 'true'
run: npm run setup:whisper:universal
- name: Verify whisper-cli exists
run: |
CACHE_HIT="${{ steps.cache-whisper.outputs.cache-hit }}"
if [ "$CACHE_HIT" = "true" ]; then
# Cache was hit - binary MUST exist
if [ ! -f "bin/whisper-cli" ]; then
echo "❌ Cache hit but whisper-cli not found - cache may be corrupt or paths misconfigured!"
exit 1
fi
echo "✅ whisper-cli restored from cache"
lipo -info bin/whisper-cli
else
# Cache miss - binary should have been built, verify it exists
if [ ! -f "bin/whisper-cli" ]; then
echo "❌ whisper-cli not found after build, rebuilding..."
npm run setup:whisper:universal
if [ ! -f "bin/whisper-cli" ]; then
echo "❌ Failed to build whisper-cli even after rebuild!"
exit 1
fi
fi
echo "✅ whisper-cli built successfully"
lipo -info bin/whisper-cli
fi
- name: Generate icons
run: npm run icons
- name: Build application
run: npm run build
- name: Verify Apple credentials
run: |
echo "🔐 Verifying Apple notarization credentials..."
if [ -z "$APPLE_ID" ]; then
echo "⚠️ Warning: APPLE_ID is not set"
else
echo "✅ APPLE_ID is set: ${APPLE_ID:0:3}***"
fi
if [ -z "$APPLE_APP_SPECIFIC_PASSWORD" ]; then
echo "⚠️ Warning: APPLE_APP_SPECIFIC_PASSWORD is not set"
else
echo "✅ APPLE_APP_SPECIFIC_PASSWORD is set: ****-****-****-****"
fi
if [ -z "$APPLE_TEAM_ID" ]; then
echo "⚠️ Warning: APPLE_TEAM_ID is not set"
else
echo "✅ APPLE_TEAM_ID is set: $APPLE_TEAM_ID"
fi
if [ -z "$CSC_LINK" ]; then
echo "⚠️ Warning: CSC_LINK (signing certificate) is not set"
else
echo "✅ CSC_LINK is set"
fi
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
CSC_LINK: ${{ secrets.CSC_LINK }}
- name: Build Electron app for macOS
id: electron-build
timeout-minutes: 60
run: |
echo "🏗️ Starting electron-builder..."
echo "📅 Start time: $(date)"
# Run electron-builder with verbose output
npx electron-builder --mac --publish never 2>&1 | tee electron-builder.log
BUILD_EXIT_CODE=${PIPESTATUS[0]}
echo "📅 End time: $(date)"
if [ $BUILD_EXIT_CODE -ne 0 ]; then
echo "❌ electron-builder failed with exit code $BUILD_EXIT_CODE"
echo "📋 Last 100 lines of log:"
tail -100 electron-builder.log
exit $BUILD_EXIT_CODE
fi
echo "✅ electron-builder completed successfully"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
# Enable verbose notarization logging
DEBUG: electron-notarize*
- name: Upload build log on failure
if: failure() && steps.electron-build.outcome == 'failure'
uses: actions/upload-artifact@v4
with:
name: electron-builder-log
path: electron-builder.log
retention-days: 7
- name: Upload macOS artifacts to release
if: success()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload v${{ inputs.version }} \
release/*.dmg \
release/*.zip \
release/*.blockmap \
release/latest-mac.yml \
--clobber
- name: Deployment notification
if: success()
uses: actions/github-script@v7
env:
VERSION: ${{ inputs.version }}
with:
script: |
const version = process.env.VERSION;
try {
const deployment = await github.rest.repos.createDeployment({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `v${version}`,
environment: 'production',
description: `WhisperDesk v${version} deployed`,
required_contexts: []
});
await github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: deployment.data.id,
state: 'success',
environment_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/releases/tag/v${version}`,
description: 'Build completed and uploaded to GitHub Release'
});
} catch (error) {
console.error('Failed to create deployment:', error);
}
# Optional: Build for Windows (uncomment when ready)
# deploy-windows:
# name: Build & Deploy Windows
# runs-on: windows-latest
# environment:
# name: production
#
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# with:
# ref: v${{ inputs.version }}
#
# - name: Verify release tag exists
# run: |
# if (-not (git rev-parse "v${{ inputs.version }}" 2>$null)) {
# Write-Error "Release tag v${{ inputs.version }} not found!"
# exit 1
# }
#
# - name: Setup Node.js
# uses: actions/setup-node@v4
# with:
# node-version: '20'
# cache: 'npm'
#
# - name: Install dependencies
# run: npm ci
#
# - name: Build application
# run: npm run build
#
# - name: Build Electron app for Windows
# run: npx electron-builder --win --publish never
# env:
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#
# - name: Upload Windows artifacts to release
# uses: softprops/action-gh-release@v2
# if: success()
# with:
# tag_name: v${{ inputs.version }}
# files: |
# release/*.exe
# release/*.blockmap
# release/latest.yml
# fail_on_unmatched_files: true
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}