-
Notifications
You must be signed in to change notification settings - Fork 148
269 lines (246 loc) · 14.3 KB
/
template-build-linux.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
name: build-linux
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: 'ubuntu-20-04-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: ''
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'
arch:
required: false
type: string
default: 'amd64'
description: 'The architecture to use for this job'
secrets:
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-linux:
runs-on: ${{ inputs.runs-on }}
permissions:
contents: write
steps:
- name: Getting the repo
uses: actions/checkout@v3
with:
ref: ${{ inputs.ref }}
submodules: 'recursive'
- name: use python 3.9
continue-on-error: true
uses: actions/setup-python@v4
with:
python-version: '3.9'
- 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"
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"
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"
fi
- name: Install jq
uses: dcarbone/[email protected]
- name: Install dependencies linux
run: |
sudo apt update && sudo apt install gettext-base -y
python3 -m pip install awscli
- name: Configure vcpkg
run: |
cd engine
# Set env if arch is arm64
if [ "${{ inputs.arch }}" == "arm64" ]; then
sudo apt install ninja-build pkg-config -y
export VCPKG_FORCE_SYSTEM_BINARIES=1
fi
make configure-vcpkg
- name: Build
run: |
cd engine
# Set env if arch is arm64
if [ "${{ inputs.arch }}" == "arm64" ]; then
export VCPKG_FORCE_SYSTEM_BINARIES=1
fi
make build CMAKE_EXTRA_FLAGS="${{ inputs.cmake-flags }}" BUILD_DEPS_CMAKE_EXTRA_FLAGS="${{ inputs.build-deps-cmake-flags }}"
- name: Install Python
continue-on-error: true
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: Build network Installers
shell: bash
run: |
cd engine
make build-installer PACKAGE_NAME="${{ steps.set-output-params.outputs.package_name }}" SOURCE_BINARY_PATH="../../cortex/${{ steps.set-output-params.outputs.destination_binary_name }}" SOURCE_BINARY_SERVER_PATH="../../cortex/${{ steps.set-output-params.outputs.destination_binary_server_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 }}" DATA_FOLDER_NAME="${{ steps.set-output-params.outputs.data_folder_name }}" CONFIGURATION_FILE_NAME="${{ steps.set-output-params.outputs.configuration_file_name }}" UNINSTALLER_FILE_NAME="${{ steps.set-output-params.outputs.uninstaller_file_name }}" ARCH="${{ inputs.arch }}"
mv ${{ steps.set-output-params.outputs.package_name }}.deb ${{ steps.set-output-params.outputs.package_name }}-network.deb
- name: Build local Installers
run: |
mkdir -p engine/templates/linux/dependencies
cd engine/templates/linux/dependencies
if [ "${{ inputs.arch }}" == "amd64" ]; then
wget https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-linux-amd64-avx-cuda-11-7.tar.gz
wget https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-linux-amd64-avx-cuda-12-0.tar.gz
wget https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-linux-amd64-avx.tar.gz
wget https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-linux-amd64-avx2-cuda-11-7.tar.gz
wget https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-linux-amd64-avx2-cuda-12-0.tar.gz
wget https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-linux-amd64-avx2.tar.gz
wget https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-linux-amd64-avx512-cuda-11-7.tar.gz
wget https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-linux-amd64-avx512-cuda-12-0.tar.gz
wget https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-linux-amd64-avx512.tar.gz
wget https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-linux-amd64-noavx-cuda-11-7.tar.gz
wget https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-linux-amd64-noavx-cuda-12-0.tar.gz
wget https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-linux-amd64-noavx.tar.gz
wget https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-linux-amd64-vulkan.tar.gz
wget https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cuda-11-7-linux-amd64.tar.gz
wget https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cuda-12-0-linux-amd64.tar.gz
else
wget https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-linux-arm64.tar.gz
fi
cd ..
# Remove network package
ls -al
rm -rf ${{ steps.set-output-params.outputs.package_name }}
rm ${{ steps.set-output-params.outputs.package_name }}.deb
chmod +x create_deb_local.sh
./create_deb_local.sh ${{ steps.set-output-params.outputs.package_name }} ${{ inputs.new_version }} ../../cortex/${{ steps.set-output-params.outputs.destination_binary_name }} ../../cortex/${{ steps.set-output-params.outputs.destination_binary_server_name }} ${{ steps.set-output-params.outputs.destination_binary_name }} ${{ steps.set-output-params.outputs.destination_binary_server_name }} ${{ steps.set-output-params.outputs.data_folder_name }} ${{ steps.set-output-params.outputs.configuration_file_name }} ${{ inputs.arch }};
cp ${{ steps.set-output-params.outputs.package_name }}.deb ../../${{ steps.set-output-params.outputs.package_name }}-local.deb
- name: Package
run: |
cd engine
make package
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: cortex-${{ inputs.new_version }}-linux-${{ inputs.arch }}
path: ./engine/cortex
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: cortex-${{ inputs.new_version }}-linux-${{ inputs.arch }}-network-installer
path: ./engine/${{ steps.set-output-params.outputs.package_name }}-network.deb
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: cortex-${{ inputs.new_version }}-linux-${{ inputs.arch }}-local-installer
path: ./engine/${{ steps.set-output-params.outputs.package_name }}-local.deb
- name: upload to aws s3 if public provider is aws
if: inputs.public_provider == 'aws-s3'
run: |
aws s3 cp ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/linux-${{ inputs.arch }}-cortex-nightly.tar.gz
aws s3 cp ./engine/${{ steps.set-output-params.outputs.package_name }}-network.deb s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/cortex-linux-${{ inputs.arch }}-network-installer.deb
aws s3 cp ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/linux-${{ inputs.arch }}/cortex-nightly.tar.gz
aws s3 cp ./engine/${{ steps.set-output-params.outputs.package_name }}-network.deb s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/linux-${{ inputs.arch }}/cortex-${{ inputs.new_version }}-linux-${{ inputs.arch }}-network-installer.deb
aws s3 cp ./engine/${{ steps.set-output-params.outputs.package_name }}-local.deb s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/linux-${{ inputs.arch }}/cortex-${{ inputs.new_version }}-linux-${{ inputs.arch }}-local-installer.deb
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'
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ inputs.upload_url }}
asset_path: ./engine/cortex.tar.gz
asset_name: cortex-${{ inputs.new_version }}-linux-${{ inputs.arch }}.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: ./engine/${{ steps.set-output-params.outputs.package_name }}-network.deb
asset_name: cortex-${{ inputs.new_version }}-linux-${{ inputs.arch }}-network-installer.deb
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: ./engine/${{ steps.set-output-params.outputs.package_name }}-local.deb
asset_name: cortex-${{ inputs.new_version }}-linux-${{ inputs.arch }}-local-installer.deb
asset_content_type: application/octet-stream