-
Notifications
You must be signed in to change notification settings - Fork 12
475 lines (417 loc) · 15.9 KB
/
build.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
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
name: CI-CD
on:
workflow_dispatch:
inputs:
create_release:
description: 'Create new release'
required: true
type: boolean
push:
branches:
- main
- test
- dev
paths: ['.github/workflows/**', '**/Makefile', '**/*.go', '**/*.json', '**/*.yml', '**/*.ts', '**/*.js']
pull_request:
types: [opened, reopened, synchronize]
paths: ['.github/workflows/**', '**/Makefile', '**/*.go', '**/*.json', '**/*.yml', '**/*.ts', '**/*.js']
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
GitLab-Deploy:
if: ${{ github.repository != 'MorpheusAIs/Morpheus-Lumerin-Node' && (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/test' || github.ref == 'refs/heads/dev')) }}
runs-on: ubuntu-latest
steps:
- name: Clone
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -y jq
- name: Generate Tag Name
uses: ./.github/actions/gen_tag_name
- name: Determine GitLab Target Branch
id: set_target_branch
run: |
if [ "${{ github.ref_name }}" == "dev" ]; then
echo "gitlab_branch=dev" >> $GITHUB_ENV
elif [ "${{ github.ref_name }}" == "test" ]; then
echo "gitlab_branch=stg" >> $GITHUB_ENV
elif [ "${{ github.ref_name }}" == "main" ]; then
echo "gitlab_branch=main" >> $GITHUB_ENV
else
echo "This branch is not configured to trigger GitLab pipelines."
exit 1
fi
- name: Trigger GitLab Pipeline
run: |
echo "Triggering GitLab Build and Deploy for branch ${{ github.ref_name }} with tag ${{ env.TAG_NAME }}"
# Send request to GitLab
response=$(curl --silent \
--request POST \
--url "${{ secrets.GITLAB_TRIGGER_URL }}" \
--form "token=${{ secrets.GITLAB_TRIGGER_TOKEN }}" \
--form "ref=${{ env.gitlab_branch }}" \
--form "variables[SOURCE_REPO]=${{ github.repository }}" \
--form "variables[SOURCE_BRANCH]=${{ github.ref_name }}" \
--form "variables[GITHUB_TAG]=${{ env.TAG_NAME }}")
# Parse JSON response using jq
gitlab_status=$(echo "$response" | jq -r '.status // "unknown"')
gitlab_web_url=$(echo "$response" | jq -r '.web_url // "N/A"')
# Log the response
echo "GitLab Response: $response"
# Validate the status field
if [[ "$gitlab_status" =~ ^(created|preparing|success|running|scheduled)$ ]]; then
echo "GitLab pipeline triggered successfully! Status: $gitlab_status"
echo "Pipeline details: $gitlab_web_url"
else
echo "GitLab pipeline FAILED. Invalid status: $gitlab_status"
echo "Pipeline details: $gitlab_web_url"
exit 1
fi
Ubuntu-22-x64:
if: ${{ github.repository != 'MorpheusAIs/Morpheus-Lumerin-Node' }}
runs-on: ubuntu-22.04
steps:
- name: Clone
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'
cache-dependency-path: |
launcher/go.sum
proxy-router/go.sum
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
cache-dependency-path: ui-desktop/yarn.lock
- name: Install dependencies
run: |
cd launcher
go mod tidy
cd ../proxy-router
go mod download
cd ../ui-desktop
yarn install --network-timeout 600000
- name: Copy Environment Files
uses: ./.github/actions/copy_env_files
- name: Generate Tag Name
uses: ./.github/actions/gen_tag_name
- name: Build
id: build
run: |
cd launcher
make
cd ../proxy-router
make build
cd ../cli
make build
cd ../ui-desktop
echo "Injecting version ${VFULL} into package.json"
sed -i "s/\"version\": \".*\"/\"version\": \"${VFULL}\"/" package.json
cat package.json | grep '"version"' # Optional: Verify the change
yarn build:linux
- name: Pack artifacts
id: pack_artifacts
run: |
ARTIFACT="mor-launch-$TAG_NAME-ubuntu-x64.zip"
echo "Artifact: $ARTIFACT"
LLAMACPP=llama-b3256-bin-ubuntu-x64.zip
MODEL=tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf
wget -nv https://github.com/ggerganov/llama.cpp/releases/download/b3256/$LLAMACPP
wget -nv https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/$MODEL
unzip -o -j $LLAMACPP build/bin/llama-server
echo '{"run":["./llama-server -m ./'$MODEL'","./proxy-router","./morpheus-ui-${VFULL}-x86_64-linux.AppImage"]}' > mor-launch.json
mv ./cli/mor-cli mor-cli
zip -j $ARTIFACT ./LICENSE ./launcher/mor-launch llama-server ./proxy-router/bin/proxy-router .env $MODEL mor-launch.json ./ui-desktop/dist/morpheus-ui-${VFULL}-x86_64-linux.AppImage models-config.json rating-config.json mor-cli
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: mor-launch-${{ env.TAG_NAME }}-ubuntu-x64.zip
name: mor-launch-ubuntu-x64.zip
macOS-13-x64:
if: ${{ github.repository != 'MorpheusAIs/Morpheus-Lumerin-Node' }}
runs-on: macos-13
steps:
- name: Clone
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'
cache-dependency-path: |
launcher/go.sum
proxy-router/go.sum
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
cache-dependency-path: ui-desktop/yarn.lock
- name: Install dependencies
run: |
cd launcher
go mod tidy
cd ../proxy-router
go mod download
cd ../ui-desktop
python3 -m pip install setuptools
yarn install --network-timeout 600000
- name: Copy Environment Files
uses: ./.github/actions/copy_env_files
- name: Generate Tag Name
uses: ./.github/actions/gen_tag_name
- name: Build
id: build
run: |
cd launcher
make
cd ../proxy-router
make build
cd ../cli
make build
cd ../ui-desktop
echo "Injecting version ${VFULL} into package.json"
sed -i "" "s/\"version\": \".*\"/\"version\": \"${VFULL}\"/" package.json
cat package.json | grep '"version"' # Optional: Verify the change
yarn build:mac
- name: Pack artifacts
id: pack_artifacts
run: |
ARTIFACT="mor-launch-$TAG_NAME-macos-x64.zip"
echo "Artifact: $ARTIFACT"
LLAMACPP=llama-b3256-bin-macos-x64.zip
MODEL=tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf
wget -nv https://github.com/ggerganov/llama.cpp/releases/download/b3256/$LLAMACPP
wget -nv https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/$MODEL
unzip -o -j $LLAMACPP build/bin/llama-server
echo '{"run":["./llama-server -m ./'$MODEL'","./proxy-router","./MorpheusUI.app/Contents/MacOS/MorpheusUI"]}' > mor-launch.json
mv ./cli/mor-cli mor-cli
unzip ./ui-desktop/dist/morpheus-ui-${VFULL}-x64-mac.zip
zip -j $ARTIFACT ./LICENSE ./launcher/mor-launch ./proxy-router/bin/proxy-router .env llama-server $MODEL mor-launch.json models-config.json rating-config.json mor-cli
zip -r $ARTIFACT 'MorpheusUI.app'
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: mor-launch-${{ env.TAG_NAME }}-macos-x64.zip
name: mor-launch-macos-x64.zip
macOS-14-arm64:
if: ${{ github.repository != 'MorpheusAIs/Morpheus-Lumerin-Node' }}
runs-on: macos-14
steps:
- name: Clone
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'
cache-dependency-path: |
launcher/go.sum
proxy-router/go.sum
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
cache-dependency-path: ui-desktop/yarn.lock
- name: Install dependencies
run: |
cd launcher
go mod tidy
cd ../proxy-router
go mod download
cd ../ui-desktop
brew install python-setuptools
yarn install --network-timeout 600000
- name: Copy Environment Files
uses: ./.github/actions/copy_env_files
- name: Generate Tag Name
uses: ./.github/actions/gen_tag_name
- name: Build
id: build
run: |
cd launcher
make
cd ../proxy-router
make build
cd ../cli
make build
cd ../ui-desktop
echo "Injecting version ${VFULL}} into package.json"
sed -i "" "s/\"version\": \".*\"/\"version\": \"${VFULL}\"/" package.json
cat package.json | grep '"version"' # Optional: Verify the change
yarn build:mac
- name: Pack artifacts
id: pack_artifacts
run: |
ARTIFACT="mor-launch-$TAG_NAME-macos-arm64.zip"
echo "Artifact: $ARTIFACT"
LLAMACPP=llama-b3256-bin-macos-arm64.zip
MODEL=tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf
wget -nv https://github.com/ggerganov/llama.cpp/releases/download/b3256/$LLAMACPP
wget -nv https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/$MODEL
unzip -o -j $LLAMACPP build/bin/llama-server
echo '{"run":["./llama-server -m ./'$MODEL'","./proxy-router","./MorpheusUI.app/Contents/MacOS/MorpheusUI"]}' > mor-launch.json
mv ./cli/mor-cli mor-cli
unzip ./ui-desktop/dist/morpheus-ui-${VFULL}-arm64-mac.zip
zip -j $ARTIFACT ./LICENSE ./launcher/mor-launch ./proxy-router/bin/proxy-router .env llama-server $MODEL mor-launch.json models-config.json rating-config.json mor-cli
zip -r $ARTIFACT 'MorpheusUI.app'
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: mor-launch-${{ env.TAG_NAME }}-macos-arm64.zip
name: mor-launch-macos-arm64.zip
Windows-avx2-x64:
if: ${{ github.repository != 'MorpheusAIs/Morpheus-Lumerin-Node' }}
runs-on: windows-latest
steps:
- name: Clone
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'
cache-dependency-path: |
launcher/go.sum
proxy-router/go.sum
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
cache-dependency-path: ui-desktop/yarn.lock
- name: Install wget and sed
run: |
choco install wget --no-progress
choco install sed --no-progress
- name: Install dependencies
run: |
cd launcher
go mod tidy
cd ../proxy-router
go mod download
cd ../ui-desktop
yarn install --network-timeout 600000
- name: Copy Environment Files
uses: ./.github/actions/copy_env_files
- name: Generate Tag Name
uses: ./.github/actions/gen_tag_name
- name: Build
id: build
run: |
cd launcher
make
cd ../proxy-router
make build
cd ../cli
make build
cd ../ui-desktop
echo "Injecting version ${VFULL} into package.json"
sed -i "s/\"version\": \".*\"/\"version\": \"${VFULL}\"/" package.json
cat package.json | grep '"version"' # Optional: Verify the change
yarn build:win
- name: Pack artifacts
id: pack_artifacts
run: |
ARTIFACT="mor-launch-$TAG_NAME-win-x64.zip"
echo "Artifact: $ARTIFACT"
LLAMACPP=llama-b3256-bin-win-avx2-x64.zip
MODEL=tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf
wget -nv https://github.com/ggerganov/llama.cpp/releases/download/b3256/$LLAMACPP
wget -nv https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/$MODEL
unzip -o -j $LLAMACPP llama-server.exe llama.dll ggml.dll
echo '{"run":["./llama-server.exe -m ./'$MODEL'","./proxy-router.exe","./morpheus-ui-${VFULL}-x64-win.exe"]}' > mor-launch.json
mv .env .env.tmp
sed 's|\./data/|.\\data\\|g' .env.tmp > .env
mv ./proxy-router/bin/proxy-router proxy-router.exe
mv ./cli/mor-cli mor-cli.exe
mv ./launcher/mor-launch mor-launch.exe
mv "./ui-desktop/dist/morpheus-ui-${VFULL}-x64-win" morpheus-ui-${VFULL}-x64-win.exe
7z a $ARTIFACT LICENSE mor-launch.exe proxy-router.exe .env llama-server.exe llama.dll ggml.dll $MODEL mor-launch.json morpheus-ui-${VFULL}-x64-win.exe models-config.json rating-config.json mor-cli.exe
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: mor-launch-${{ env.TAG_NAME }}-win-x64.zip
name: mor-launch-win-x64.zip
release:
if: ${{ github.repository != 'MorpheusAIs/Morpheus-Lumerin-Node' && (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/test' )) || github.event.inputs.create_release == 'true' }}
runs-on: ubuntu-latest
needs:
- Ubuntu-22-x64
- macOS-13-x64
- macOS-14-arm64
- Windows-avx2-x64
steps:
- name: Clone
id: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Generate Tag Name
uses: ./.github/actions/gen_tag_name
- name: Download artifacts
id: download-artifact
uses: actions/download-artifact@v4
with:
path: ./artifact
- name: Move artifacts
id: move_artifacts
run: |
mkdir -p ./artifact/release
mv ./artifact/*/*.zip ./artifact/release
- name: Create release
id: create_release
uses: anzz1/action-create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.TAG_NAME }}
prerelease: ${{ github.ref != 'refs/heads/main' }}
- name: Upload release
id: upload_release
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const path = require('path');
const fs = require('fs');
const release_id = '${{ steps.create_release.outputs.id }}';
for (let file of await fs.readdirSync('./artifact/release')) {
if (path.extname(file) === '.zip') {
console.log('uploadReleaseAsset', file);
await github.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release_id,
name: file,
data: await fs.readFileSync(`./artifact/release/${file}`)
});
}
}