-
Notifications
You must be signed in to change notification settings - Fork 17
424 lines (387 loc) · 19.7 KB
/
release-prod.yml
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
name: Release production
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
defaults:
run:
working-directory: ./
jobs:
prebuild:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.package-version.outputs.version }}
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: get npm version
id: package-version
uses: Saionaro/[email protected]
- name: Check version match
if: ${{ github.ref_name != steps.package-version.outputs.version }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('Version mismatch')
release-shinkai-visor:
needs: prebuild
runs-on: ubuntu-latest
environment: production
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node version
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
check-latest: false
cache: "npm"
cache-dependency-path: package-lock.json
- name: Install dependencies
run: |
npm cache verify
npm ci --no-audit --prefer-offline
- name: Run NX build on shinkai-visor
run: npx nx build shinkai-visor --skip-nx-cache
env:
VERSION: ${{ needs.prebuild.outputs.version }}.${{github.run_number}}
NAME_PREFIX: ''
DESCRIPTION_PREFIX: ''
PUBLIC_KEY: ${{ secrets.CHROME_EXTENSION_PUBLIC_KEY }}
- name: Zip extension
run: cd ./dist/apps && zip -r shinkai-visor.zip shinkai-visor
- name: Upload & Release
uses: mnao305/[email protected]
with:
file-path: dist/apps/shinkai-visor.zip
extension-id: ${{ secrets.CHROME_EXTENSION_ID }}
client-id: ${{ secrets.CHROME_CLIENT_ID }}
client-secret: ${{ secrets.CHROME_CLIENT_SECRET }}
refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }}
publish: false
release-shinkai-desktop:
needs: prebuild
name: Release Shinkai Desktop
environment: production
strategy:
matrix:
include:
- arch: x86_64-unknown-linux-gnu
os: ubuntu-22.04
build_output_file_path: apps/shinkai-desktop/src-tauri/target/release/bundle/appimage/Shinkai Desktop_${{ needs.prebuild.outputs.version }}_amd64.AppImage
build_output_update_file_path: apps/shinkai-desktop/src-tauri/target/release/bundle/appimage/Shinkai Desktop_${{ needs.prebuild.outputs.version }}_amd64.AppImage.tar.gz
build_output_update_signature_file_path: apps/shinkai-desktop/src-tauri/target/release/bundle/appimage/Shinkai Desktop_${{ needs.prebuild.outputs.version }}_amd64.AppImage.tar.gz.sig
distributable_file_name: Shinkai-Desktop-${{ needs.prebuild.outputs.version }}.${{ github.run_number }}_x86_64-unknown-linux-gnu.AppImage
distributable_update_file_name: Shinkai-Desktop-${{ needs.prebuild.outputs.version }}.${{ github.run_number }}_x86_64-unknown-linux-gnu.AppImage.tar.gz
distributable_update_signature_file_name: Shinkai-Desktop-${{ needs.prebuild.outputs.version }}.${{ github.run_number }}_x86_64-unknown-linux-gnu.AppImage.tar.gz.sig
- arch: aarch64-apple-darwin
os: macos-14
build_output_file_path: apps/shinkai-desktop/src-tauri/target/release/bundle/dmg/Shinkai Desktop_${{ needs.prebuild.outputs.version }}_aarch64.dmg
build_output_update_file_path: apps/shinkai-desktop/src-tauri/target/release/bundle/macos/Shinkai Desktop.app.tar.gz
build_output_update_signature_file_path: apps/shinkai-desktop/src-tauri/target/release/bundle/macos/Shinkai Desktop.app.tar.gz.sig
distributable_file_name: Shinkai-Desktop-${{ needs.prebuild.outputs.version }}.${{ github.run_number }}_aarch64-apple-darwin.dmg
distributable_update_file_name: Shinkai-Desktop-${{ needs.prebuild.outputs.version }}.${{ github.run_number }}_aarch64-apple-darwin.app.tar.gz
distributable_update_signature_file_name: Shinkai-Desktop-${{ needs.prebuild.outputs.version }}.${{ github.run_number }}_aarch64-apple-darwin.app.tar.gz.sig
- arch: x86_64-pc-windows-msvc
os: windows-2022
build_output_file_path: apps/shinkai-desktop/src-tauri/target/release/bundle/nsis/Shinkai Desktop_${{ needs.prebuild.outputs.version }}_x64-setup.exe
build_output_update_file_path: apps/shinkai-desktop/src-tauri/target/release/bundle/nsis/Shinkai Desktop_${{ needs.prebuild.outputs.version }}_x64-setup.nsis.zip
build_output_update_signature_file_path: apps/shinkai-desktop/src-tauri/target/release/bundle/nsis/Shinkai Desktop_${{ needs.prebuild.outputs.version }}_x64-setup.nsis.zip.sig
distributable_file_name: Shinkai-Desktop-${{ needs.prebuild.outputs.version }}.${{ github.run_number }}_x86_64-pc-windows-msvc.exe
distributable_update_file_name: Shinkai-Desktop-${{ needs.prebuild.outputs.version }}.${{ github.run_number }}_x86_64-pc-windows-msvc.nsis.zip
distributable_update_signature_file_name: Shinkai-Desktop-${{ needs.prebuild.outputs.version }}.${{ github.run_number }}_x86_64-pc-windows-msvc.nsis.zip.sig
runs-on: ${{ matrix.os }}
outputs:
signature-x86_64-unknown-linux-gnu: ${{ steps.prepare-files.outputs.signature-x86_64-unknown-linux-gnu }}
update-url-x86_64-unknown-linux-gnu: ${{ steps.prepare-files.outputs.update-url-x86_64-unknown-linux-gnu }}
app-url-x86_64-unknown-linux-gnu: ${{ steps.prepare-files.outputs.app-url-x86_64-unknown-linux-gnu }}
signature-aarch64-apple-darwin: ${{ steps.prepare-files.outputs.signature-aarch64-apple-darwin }}
update-url-aarch64-apple-darwin: ${{ steps.prepare-files.outputs.update-url-aarch64-apple-darwin }}
app-url-aarch64-apple-darwin: ${{ steps.prepare-files.outputs.app-url-aarch64-apple-darwin }}
signature-x86_64-pc-windows-msvc: ${{ steps.prepare-files.outputs.signature-x86_64-pc-windows-msvc }}
update-url-x86_64-pc-windows-msvc: ${{ steps.prepare-files.outputs.update-url-x86_64-pc-windows-msvc }}
app-url-x86_64-pc-windows-msvc: ${{ steps.prepare-files.outputs.app-url-x86_64-pc-windows-msvc }}
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: (Windows) Install asiosdk}
if: ${{ matrix.arch == 'x86_64-pc-windows-msvc' }}
shell: PowerShell
run: |
curl https://www.steinberg.net/asiosdk -o asiosdk.zip
Expand-Archive .\asiosdk.zip -DestinationPath .\
choco install asio4all
choco install llvm
# This is a workaround for NSIS bundle size limits https://nsis.sourceforge.io/Talk:Special_Builds
- name: (Windows) Override NSIS by NSISBI
if: ${{ matrix.arch == 'x86_64-pc-windows-msvc' }}
shell: PowerShell
run: |
Invoke-WebRequest -Uri "https://downloads.sourceforge.net/sourceforge/nsisbi/nsis-binary-7423-1.zip" -MaximumRedirection 5 -OutFile "nsisbi.zip" -UserAgent "Wget"
Expand-Archive .\nsisbi.zip -DestinationPath .\
# Add tauri plugins
Invoke-WebRequest -Uri "https://github.com/tauri-apps/nsis-tauri-utils/releases/download/nsis_tauri_utils-v0.4.1/nsis_tauri_utils.dll" -MaximumRedirection 5 -OutFile "nsis_tauri_utils.dll" -UserAgent "Wget"
mv .\nsis_tauri_utils.dll .\nsis-binary-7423-1\Plugins\x86-unicode\
mkdir -p C:\Users\runneradmin\AppData\Local\tauri\NSIS
mv .\nsis-binary-7423-1\* C:\Users\runneradmin\AppData\Local\tauri\NSIS\
- name: (Linux) Install build dependencies
if: ${{ matrix.arch == 'x86_64-unknown-linux-gnu' }}
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev build-essential wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev libasound2-dev libsoup-3.0-dev
- name: (MACOS) Install the Apple certificate and provisioning profile
if: ${{ matrix.arch == 'aarch64-apple-darwin' }}
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.APPLE_CERTIFICATE }}
P12_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
- name: Cache cargo assets
id: cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.arch }}-build-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Setup Node version
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
check-latest: false
cache: "npm"
cache-dependency-path: package-lock.json
- name: Install dependencies
run: |
npm cache verify
npm ci --no-audit --prefer-offline
- name: Download side binaries
env:
ARCH: ${{ matrix.arch }}
SHINKAI_NODE_VERSION: v0.8.9
OLLAMA_VERSION: v0.3.12
run: |
npx ts-node ./ci-scripts/download-side-binaries.ts
- name: Download ollama repository
run: |
npx ts-node ./ci-scripts/generate-ollama-models-repository.ts
- name: (Linux) Run NX build on shinkai-desktop
if: ${{ matrix.arch == 'x86_64-unknown-linux-gnu' }}
run: npx nx build shinkai-desktop --skip-nx-cache
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
VITE_POSTHOG_API_KEY: ${{ secrets.VITE_POSTHOG_API_KEY }}
SECRET_DESKTOP_INSTALLATION_PROOF_KEY: ${{ secrets.SECRET_DESKTOP_INSTALLATION_PROOF_KEY }}
NODE_OPTIONS: "--max_old_space_size=4096"
- name: (Macos) Run NX build on shinkai-desktop
if: ${{ matrix.arch == 'aarch64-apple-darwin' }}
run: npx nx build shinkai-desktop --skip-nx-cache
env:
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
VITE_POSTHOG_API_KEY: ${{ secrets.VITE_POSTHOG_API_KEY }}
SECRET_DESKTOP_INSTALLATION_PROOF_KEY: ${{ secrets.SECRET_DESKTOP_INSTALLATION_PROOF_KEY }}
NODE_OPTIONS: "--max_old_space_size=4096"
- name: (Windows) Run NX build on shinkai-desktop
if: ${{ matrix.arch == 'x86_64-pc-windows-msvc' }}
run: npx nx build shinkai-desktop --skip-nx-cache
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
VITE_POSTHOG_API_KEY: ${{ secrets.VITE_POSTHOG_API_KEY }}
SECRET_DESKTOP_INSTALLATION_PROOF_KEY: ${{ secrets.SECRET_DESKTOP_INSTALLATION_PROOF_KEY }}
# Windows Only
CPAL_ASIO_DIR: ${{ github.workspace }}/asiosdk_2.3.3_2019-06-14
LIBCLANG_PATH: C:\Program Files\LLVM\bin
NODE_OPTIONS: "--max_old_space_size=4096"
- name: Prepare binary files
id: prepare-files
shell: bash
run: |
mkdir files-to-r2
cp "${{ matrix.build_output_file_path }}" files-to-r2/${{ matrix.distributable_file_name }}
cp "${{ matrix.build_output_update_file_path }}" files-to-r2/${{ matrix.distributable_update_file_name }}
cp "${{ matrix.build_output_update_signature_file_path }}" files-to-r2/${{ matrix.distributable_update_signature_file_name }}
echo "signature-${{ matrix.arch }}=$(cat files-to-r2/${{ matrix.distributable_update_signature_file_name }})" >> "$GITHUB_OUTPUT"
echo "update-url-${{ matrix.arch }}=https://download.shinkai.com/shinkai-desktop/binaries/production/${{ matrix.arch }}/${{ needs.prebuild.outputs.version }}.${{ github.run_number }}/${{ matrix.distributable_update_file_name }}" >> "$GITHUB_OUTPUT"
echo "app-url-${{ matrix.arch }}=https://download.shinkai.com/shinkai-desktop/binaries/production/${{ matrix.arch }}/${{ needs.prebuild.outputs.version }}.${{ github.run_number }}/${{ matrix.distributable_file_name }}" >> "$GITHUB_OUTPUT"
- name: Upload binaries to R2 bucket
uses: shallwefootball/s3-upload-action@master
with:
endpoint: https://54bf1bf573b3e6471e574cc4d318db64.r2.cloudflarestorage.com
aws_key_id: ${{ secrets.R2_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
aws_bucket: shinkai-download
source_dir: files-to-r2
destination_dir: ./shinkai-desktop/binaries/production/${{ matrix.arch }}/${{ needs.prebuild.outputs.version }}.${{ github.run_number }}/
rollout-shinkai-desktop:
environment: production
needs:
- prebuild
- release-shinkai-desktop
name: Generate & Update updates.json
runs-on: ubuntu-22.04
outputs:
updates-next-json-url: ${{ steps.generate-updates-next-json.outputs.updates-next-json-url }}
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node version
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
check-latest: false
cache: "npm"
cache-dependency-path: package-lock.json
- name: Install dependencies
run: |
npm cache verify
npm ci --no-audit --prefer-offline
- name: Generate updates-next.json
id: generate-updates-next-json
env:
JSON_PATH: files-to-r2/updates-next.json
VERSION: ${{ needs.prebuild.outputs.version }}
NOTES: Automatic update to ${{ needs.prebuild.outputs.version }}
LINUX_x86_64_SIGNATURE: ${{ needs.release-shinkai-desktop.outputs.signature-x86_64-unknown-linux-gnu }}
LINUX_x86_64_URL: ${{ needs.release-shinkai-desktop.outputs.update-url-x86_64-unknown-linux-gnu }}
DARWIN_AARCH64_SIGNATURE: ${{ needs.release-shinkai-desktop.outputs.signature-aarch64-apple-darwin }}
DARWIN_AARCH64_URL: ${{ needs.release-shinkai-desktop.outputs.update-url-aarch64-apple-darwin }}
WINDOWS_x86_64_SIGNATURE: ${{ needs.release-shinkai-desktop.outputs.signature-x86_64-pc-windows-msvc }}
WINDOWS_x86_64_URL: ${{ needs.release-shinkai-desktop.outputs.update-url-x86_64-pc-windows-msvc }}
run: |
mkdir files-to-r2
npx ts-node ./ci-scripts/generate-updates-json.ts
echo "updates-next-json-url=https://download.shinkai.com/shinkai-desktop/binaries/production/updates-next.json" >> "$GITHUB_OUTPUT"
- name: Upload updates.json to R2
uses: shallwefootball/s3-upload-action@master
with:
endpoint: https://54bf1bf573b3e6471e574cc4d318db64.r2.cloudflarestorage.com
aws_key_id: ${{ secrets.R2_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
aws_bucket: shinkai-download
source_dir: files-to-r2
destination_dir: ./shinkai-desktop/binaries/production/
notify-slack:
environment: production
needs:
- prebuild
- release-shinkai-desktop
- rollout-shinkai-desktop
name: Notify Slack
runs-on: ubuntu-22.04
steps:
- name: Post Shinkai Desktop to a Slack channel
id: slack
uses: slackapi/[email protected]
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: 'C072VJ6E7GC'
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "📦 New build: Shinkai Desktop v${{ needs.prebuild.outputs.version }}.${{ github.run_number }}",
"emoji": true
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Download it from:\n* <${{ needs.release-shinkai-desktop.outputs.app-url-aarch64-apple-darwin }}|Macos>\n* <${{ needs.release-shinkai-desktop.outputs.app-url-x86_64-pc-windows-msvc }}|Windows>\n* <${{ needs.release-shinkai-desktop.outputs.app-url-x86_64-unknown-linux-gnu }}|Linux>"
}
},
{
"type": "divider"
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "_💡 Rename file <${{ needs.rollout-shinkai-desktop.outputs.updates-next-json-url }}|updates-next.json> to updates.json to start the rollout through the auto updater_"
}
]
}
]
}
- name: Post Shinkai Visor to a Slack channel
uses: slackapi/[email protected]
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
with:
channel-id: 'C072VJ6E7GC'
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "📦 New build: Shinkai Visor v${{ needs.prebuild.outputs.version }}.${{ github.run_number }}",
"emoji": true
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Found it at <https://chromewebstore.google.com/detail/shinkai-visor-supercharge/${{ secrets.CHROME_EXTENSION_ID }}|Chrome Web Store>"
}
},
{
"type": "divider"
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "_💡 Send it for review and publish on <https://chrome.google.com/u/4/webstore/devconsole/f35b7411-6fce-4a2b-8865-c310ce95c89f/${{ secrets.CHROME_EXTENSION_ID }}/edit|Chrome Web Store Developer> to start the rollout_"
}
]
}
]
}