-
Notifications
You must be signed in to change notification settings - Fork 0
251 lines (212 loc) · 7.33 KB
/
Copy pathpack-web-cli.yml
File metadata and controls
251 lines (212 loc) · 7.33 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
name: Pack Web CLI
# PanAI web CLI packaging workflow.
on:
workflow_call:
inputs:
ref:
description: 'Git ref to checkout (leave empty to use the triggering commit)'
type: string
default: ''
append_commit_hash:
description: 'Append short commit hash to artifact names'
type: boolean
default: false
skip_code_quality:
description: 'Skip code quality checks (caller already ran them)'
type: boolean
default: false
workflow_dispatch:
inputs:
ref:
description: 'Git ref to checkout (leave empty to use the triggering commit)'
type: string
default: ''
skip_code_quality:
description: 'Skip code quality checks'
type: boolean
default: false
env:
BUN_INSTALL_REGISTRY: 'https://registry.npmjs.org/'
jobs:
code-quality:
name: Code Quality
runs-on: ubuntu-latest
if: ${{ !inputs.skip_code_quality }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ inputs.ref }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Setup bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Run postinstall
run: bun run postinstall || true
- name: Run ESLint
run: bun run lint
- name: Check Prettier formatting
run: bun run format:check
- name: TypeScript type check
run: bunx tsc --noEmit
- name: Run unit tests
run: bunx vitest run
pack-web-cli:
name: Pack web-cli ${{ matrix.platform }}-${{ matrix.arch }}
runs-on: ${{ matrix.os }}
needs: code-quality
if: ${{ always() && (inputs.skip_code_quality || needs.code-quality.result == 'success') }}
strategy:
fail-fast: false
matrix:
include:
- { platform: darwin, arch: arm64, os: macos-14 }
- { platform: darwin, arch: x64, os: macos-14 }
- { platform: linux, arch: x64, os: ubuntu-latest }
- { platform: linux, arch: arm64, os: ubuntu-24.04-arm }
- { platform: win32, arch: x64, os: windows-2022 }
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ inputs.ref }}
- name: Get commit hash
id: commit
shell: bash
run: |
SHORT=$(git rev-parse --short HEAD)
echo "short=$SHORT" >> $GITHUB_OUTPUT
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Setup bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Build desktop renderer (for static files)
run: bunx electron-vite build --config packages/desktop/electron.vite.config.ts
env:
# macOS runners OOM at the default ~2GB V8 heap during renderer bundling.
NODE_OPTIONS: '--max-old-space-size=8192'
- name: Pack web-cli tarball
shell: bash
run: node scripts/pack-web-cli.js
env:
PACK_PLATFORM: ${{ matrix.platform }}
PACK_ARCH: ${{ matrix.arch }}
# Version is pinned in repo-root package.json (panaiCoreVersion).
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload tarball artifact
uses: actions/upload-artifact@v6
with:
name: ${{ inputs.append_commit_hash && format('web-cli-{0}-{1}-{2}', matrix.platform, matrix.arch, steps.commit.outputs.short) || format('web-cli-{0}-{1}', matrix.platform, matrix.arch) }}
path: |
dist-web-cli/*.tar.gz
dist-web-cli/*.sha256
retention-days: 7
prepare-install-script:
name: Prepare install-web.sh for release
runs-on: ubuntu-latest
needs: pack-web-cli
if: ${{ always() && needs.pack-web-cli.result == 'success' }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ inputs.ref }}
- name: Get commit hash
id: commit
shell: bash
run: |
SHORT=$(git rev-parse --short HEAD)
echo "short=$SHORT" >> $GITHUB_OUTPUT
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Get version from package.json
id: version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Replace __VERSION__ placeholder in install-web.sh
run: |
mkdir -p dist-scripts
sed "s/__VERSION__/${{ steps.version.outputs.version }}/g" scripts/install-web.sh > dist-scripts/install-web.sh
chmod +x dist-scripts/install-web.sh
- name: Upload install-web.sh artifact
uses: actions/upload-artifact@v6
with:
name: ${{ inputs.append_commit_hash && format('install-web-script-{0}', steps.commit.outputs.short) || 'install-web-script' }}
path: dist-scripts/install-web.sh
retention-days: 7
smoke-test:
name: Smoke test web-cli tarball (Linux x86_64)
runs-on: ubuntu-latest
needs: pack-web-cli
if: ${{ always() && needs.pack-web-cli.result == 'success' }}
container:
image: debian:bookworm-slim
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install dependencies
run: |
apt-get update
apt-get install -y curl tar gzip nodejs
- name: Download linux-x86_64 tarball
uses: actions/download-artifact@v7
with:
name: web-cli-linux-x64
path: dist-web-cli
- name: Run smoke test
shell: bash
run: |
chmod +x scripts/smoke-test-web-cli.sh
TARBALL=$(ls dist-web-cli/*.tar.gz | head -1)
bash scripts/smoke-test-web-cli.sh "$TARBALL"
smoke-test-install:
name: Smoke test install-web.sh (Linux x86_64)
runs-on: ubuntu-latest
needs: [pack-web-cli, prepare-install-script]
if: ${{ always() && needs.pack-web-cli.result == 'success' && needs.prepare-install-script.result == 'success' }}
container:
image: debian:bookworm-slim
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install dependencies
run: |
apt-get update
apt-get install -y curl tar gzip nodejs coreutils
- name: Resolve version
id: version
shell: bash
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Resolved version: $VERSION"
- name: Download linux-x86_64 tarball
uses: actions/download-artifact@v7
with:
name: web-cli-linux-x64
path: /tmp/releases/v${{ steps.version.outputs.version }}
- name: Download install-web.sh
uses: actions/download-artifact@v7
with:
name: install-web-script
path: /tmp/releases
- name: Run smoke test
shell: bash
run: |
chmod +x scripts/smoke-test-install-web.sh
bash scripts/smoke-test-install-web.sh file:///tmp/releases ${{ steps.version.outputs.version }}