-
Notifications
You must be signed in to change notification settings - Fork 134
321 lines (291 loc) · 15.6 KB
/
template-build-windows-x64.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
name: build-windows-x64
on:
workflow_call:
inputs:
ref:
required: true
type: string
default: 'refs/heads/main'
public_provider:
required: true
type: string
default: none
description: 'none: build only, github: build and publish to github, aws s3: build and publish to aws s3'
new_version:
required: true
type: string
default: ''
upload_url:
required: false
type: string
default: ''
runs-on:
required: false
type: string
default: 'windows-cuda-12-0'
description: 'The runner to use for this job'
cmake-flags:
required: false
type: string
default: ''
description: 'The cmake flags to use for this job'
build-deps-cmake-flags:
required: false
type: string
default: ''
description: 'The cmake flags to use for this job'
ccache-dir:
required: false
type: string
default: 'C:\Users\ContainerAdministrator\AppData\Local\ccache'
description: 'The ccache directory to use for this job'
channel:
required: true
type: string
default: 'nightly'
description: 'The channel to use for this job'
cortex-llamacpp-version:
required: true
type: string
default: '0.0.0'
description: 'The version of cortex-llamacpp to use for this job'
secrets:
MINIO_BUCKET_NAME:
required: false
MINIO_ENDPOINT:
required: false
MINIO_ACCESS_KEY_ID:
required: false
MINIO_SECRET_ACCESS_KEY:
required: false
MINIO_REGION:
required: false
DEVELOPER_ID:
required: false
AZURE_KEY_VAULT_URI:
required: false
AZURE_CLIENT_ID:
required: false
AZURE_TENANT_ID:
required: false
AZURE_CLIENT_SECRET:
required: false
AZURE_CERT_NAME:
required: false
DELTA_AWS_S3_BUCKET_NAME:
required: false
DELTA_AWS_ACCESS_KEY_ID:
required: false
DELTA_AWS_SECRET_ACCESS_KEY:
required: false
DELTA_AWS_REGION:
required: false
jobs:
build-windows-x64:
runs-on: ${{ inputs.runs-on }}
permissions:
contents: write
steps:
- name: Getting the repo
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
submodules: 'recursive'
- uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.0.x"
- name: Set output params for each channel
id : set-output-params
shell: bash
run: |
# Set output for stable channel
if [ "${{ inputs.channel }}" == "stable" ]; then
echo "::set-output name=package_name::cortexcpp"
echo "::set-output name=destination_binary_name::cortex"
echo "::set-output name=destination_binary_server_name::cortex-server"
echo "::set-output name=data_folder_name::cortexcpp"
echo "::set-output name=configuration_file_name::.cortexrc"
echo "::set-output name=uninstaller_file_name::cortex-uninstall.sh"
echo "::set-output name=iss_file_name::installer.iss"
echo "::set-output name=local_iss_file_name::local-installer.iss"
fi
# Set output for beta channel
if [ "${{ inputs.channel }}" == "beta" ]; then
echo "::set-output name=package_name::cortexcpp-beta"
echo "::set-output name=destination_binary_name::cortex-beta"
echo "::set-output name=destination_binary_server_name::cortex-server-beta"
echo "::set-output name=data_folder_name::cortexcpp-beta"
echo "::set-output name=configuration_file_name::.cortexrc-beta"
echo "::set-output name=uninstaller_file_name::cortex-beta-uninstall.sh"
echo "::set-output name=iss_file_name::installer-beta.iss"
echo "::set-output name=local_iss_file_name::local-installer-beta.iss"
fi
# Set output for nightly channel
if [ "${{ inputs.channel }}" == "nightly" ]; then
echo "::set-output name=package_name::cortexcpp-nightly"
echo "::set-output name=destination_binary_name::cortex-nightly"
echo "::set-output name=destination_binary_server_name::cortex-server-nightly"
echo "::set-output name=data_folder_name::cortexcpp-nightly"
echo "::set-output name=configuration_file_name::.cortexrc-nightly"
echo "::set-output name=uninstaller_file_name::cortex-nightly-uninstall.sh"
echo "::set-output name=iss_file_name::installer-nightly.iss"
echo "::set-output name=local_iss_file_name::local-installer-nightly.iss"
fi
- name: Install jq
uses: dcarbone/[email protected]
- name: Install dependencies on Windows
run: |
choco install make pkgconfiglite ccache awscli 7zip ninja wget -y
dotnet tool install --global AzureSignTool
- name: Download ccache from s3
continue-on-error: true
run: |
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
refreshenv
aws s3 sync s3://${{ secrets.MINIO_BUCKET_NAME }}/cortex-cpp-windows-amd64 ${{ inputs.ccache-dir }} --endpoint ${{ secrets.MINIO_ENDPOINT }}
env:
AWS_ACCESS_KEY_ID: "${{ secrets.MINIO_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.MINIO_SECRET_ACCESS_KEY }}"
AWS_DEFAULT_REGION: "${{ secrets.MINIO_REGION }}"
- name: Configure vcpkg
shell: cmd
run: |
cd engine
make configure-vcpkg
- name: Build
run: |
cd engine
make build CMAKE_EXTRA_FLAGS="${{ inputs.cmake-flags }}" BUILD_DEPS_CMAKE_EXTRA_FLAGS="${{ inputs.build-deps-cmake-flags }}"
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Pre-package
run: |
cd engine
make pre-package DESTINATION_BINARY_NAME="${{ steps.set-output-params.outputs.destination_binary_name }}" DESTINATION_BINARY_SERVER_NAME="${{ steps.set-output-params.outputs.destination_binary_server_name }}"
- name: Code Signing binaries
run: |
cd engine
make codesign-binary DESTINATION_BINARY_NAME="${{ steps.set-output-params.outputs.destination_binary_name }}" DESTINATION_BINARY_SERVER_NAME="${{ steps.set-output-params.outputs.destination_binary_server_name }}" AZURE_KEY_VAULT_URI="${{ secrets.AZURE_KEY_VAULT_URI }}" AZURE_CLIENT_ID="${{ secrets.AZURE_CLIENT_ID }}" AZURE_TENANT_ID="${{ secrets.AZURE_TENANT_ID }}" AZURE_CLIENT_SECRET="${{ secrets.AZURE_CLIENT_SECRET }}" AZURE_CERT_NAME="${{ secrets.AZURE_CERT_NAME }}"
- name: Update version in installer.iss using sed
shell: bash
run: |
cd engine/templates/windows
sed -i "s/AppVersion=1.0/AppVersion=${{ inputs.new_version }}/g" ${{ steps.set-output-params.outputs.iss_file_name }}
sed -i "s/AppVersion=1.0/AppVersion=${{ inputs.new_version }}/g" ${{ steps.set-output-params.outputs.local_iss_file_name }}
cat ${{ steps.set-output-params.outputs.iss_file_name }}
cp ${{ steps.set-output-params.outputs.iss_file_name }} ../../../
cp ${{ steps.set-output-params.outputs.local_iss_file_name }} ../../../
ls ../../../
- name: Build network Installers
shell: bash
run: |
cd engine
make build-installer PACKAGE_NAME=${{ steps.set-output-params.outputs.package_name }} VERSION=${{ inputs.new_version }} DESTINATION_BINARY_NAME="${{ steps.set-output-params.outputs.destination_binary_name }}" DESTINATION_BINARY_SERVER_NAME="${{ steps.set-output-params.outputs.destination_binary_server_name }}"
ls ../
- name: Build local Installers
shell: powershell
run: |
mkdir dependencies
cd dependencies
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-avx-cuda-11-7.tar.gz
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-avx-cuda-12-0.tar.gz
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-avx.tar.gz
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-avx2-cuda-11-7.tar.gz
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-avx2-cuda-12-0.tar.gz
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-avx2.tar.gz
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-avx512-cuda-11-7.tar.gz
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-avx512-cuda-12-0.tar.gz
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-avx512.tar.gz
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-noavx-cuda-11-7.tar.gz
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-noavx-cuda-12-0.tar.gz
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-noavx.tar.gz
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-vulkan.tar.gz
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cuda-11-7-windows-amd64.tar.gz
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cuda-12-0-windows-amd64.tar.gz
- name: Enable long paths
run: |
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem" /v LongPathsEnabled /t REG_DWORD /d 1 /f
- name: Compile .ISS to .EXE network Installer
uses: nadeemjazmawe/[email protected]
with:
filepath: ./${{ steps.set-output-params.outputs.iss_file_name }}
- name: Codesign for windows network installer
shell: pwsh
run: |
~\.dotnet\tools\azuresigntool.exe sign -kvu ${{ secrets.AZURE_KEY_VAULT_URI }} -kvi ${{ secrets.AZURE_CLIENT_ID }} -kvt ${{ secrets.AZURE_TENANT_ID }} -kvs ${{ secrets.AZURE_CLIENT_SECRET }} -kvc ${{ secrets.AZURE_CERT_NAME }} -tr http://timestamp.globalsign.com/tsa/r6advanced1 -v ".\setup.exe"
mv .\setup.exe .\network-setup.exe
- name: Compile .ISS to .EXE local Installer
uses: nadeemjazmawe/[email protected]
with:
filepath: ./${{ steps.set-output-params.outputs.local_iss_file_name }}
- name: Codesign for windows network installer
shell: pwsh
run: |
~\.dotnet\tools\azuresigntool.exe sign -kvu ${{ secrets.AZURE_KEY_VAULT_URI }} -kvi ${{ secrets.AZURE_CLIENT_ID }} -kvt ${{ secrets.AZURE_TENANT_ID }} -kvs ${{ secrets.AZURE_CLIENT_SECRET }} -kvc ${{ secrets.AZURE_CERT_NAME }} -tr http://timestamp.globalsign.com/tsa/r6advanced1 -v ".\setup.exe"
mv .\setup.exe .\local-setup.exe
- name: Package
run: |
cd engine
make package
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: cortex-${{ inputs.new_version }}-windows-amd64
path: ./engine/cortex
- name: Upload Artifact network installer
uses: actions/upload-artifact@v4
with:
name: cortex-${{ inputs.new_version }}-windows-amd64-network-installer
path: ./network-setup.exe
- name: Upload Artifact local installer
uses: actions/upload-artifact@v4
with:
name: cortex-${{ inputs.new_version }}-windows-amd64-local-installer
path: ./local-setup.exe
- name: upload to aws s3 if public provider is aws
if: inputs.public_provider == 'aws-s3'
run: |
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
refreshenv
aws s3 cp ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/windows-amd64-cortex-nightly.tar.gz
aws s3 cp ./network-setup.exe s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/cortex-windows-amd64-network-installer.exe
aws s3 cp ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/windows-amd64/cortex-nightly.tar.gz
aws s3 cp ./network-setup.exe s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/windows-amd64/cortex-${{ inputs.new_version }}-windows-amd64-network-installer.exe
aws s3 cp ./local-setup.exe s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/windows-amd64/cortex-${{ inputs.new_version }}-windows-amd64-local-installer.exe
env:
AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.DELTA_AWS_REGION }}
AWS_EC2_METADATA_DISABLED: "true"
- name: Upload release assert if public provider is github
if: inputs.public_provider == 'github'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/[email protected]
with:
upload_url: ${{ inputs.upload_url }}
asset_path: ./engine/cortex.tar.gz
asset_name: cortex-${{ inputs.new_version }}-windows-amd64.tar.gz
asset_content_type: application/zip
- name: Upload release assert if public provider is github
if: inputs.public_provider == 'github'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/[email protected]
with:
upload_url: ${{ inputs.upload_url }}
asset_path: ./network-setup.exe
asset_name: cortex-${{ inputs.new_version }}-windows-amd64-network-installer.exe
asset_content_type: application/octet-stream
- name: Upload release assert if public provider is github
if: inputs.public_provider == 'github'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/[email protected]
with:
upload_url: ${{ inputs.upload_url }}
asset_path: ./local-setup.exe
asset_name: cortex-${{ inputs.new_version }}-windows-amd64-local-installer.exe
asset_content_type: application/octet-stream