Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit aafcb82

Browse files
hiento09Hien To
authored andcommitted
Refactor CICD windows nitro
1 parent 3348406 commit aafcb82

File tree

1 file changed

+49
-84
lines changed

1 file changed

+49
-84
lines changed

.github/workflows/build.yml

Lines changed: 49 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,15 @@ jobs:
4545
if: always() && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped')
4646
permissions:
4747
contents: write
48-
49-
env:
50-
OPENBLAS_VERSION: 0.3.23
51-
OPENCL_VERSION: 2023.04.17
52-
CLBLAST_VERSION: 1.6.0
53-
54-
strategy:
55-
matrix:
56-
include:
57-
- build: 'openblas'
58-
defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_BLAS=ON -DBUILD_SHARED_LIBS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"'
59-
6048
steps:
6149
- name: Clone
62-
6350
id: checkout
6451
uses: actions/checkout@v3
6552
with:
6653
submodules: recursive
6754

68-
- name: Download OpenBLAS
69-
id: get_openblas
70-
if: ${{ matrix.build == 'openblas' }}
55+
- name: Dependencies
56+
id: depends
7157
run: |
7258
sudo apt-get update
7359
sudo apt-get install build-essential gcc-8
@@ -167,7 +153,6 @@ jobs:
167153
168154
- name: Build
169155
id: cmake_build
170-
shell: cmd
171156
run: |
172157
./install_deps.sh
173158
mkdir build && cd build
@@ -225,12 +210,10 @@ jobs:
225210
- name: Package
226211
shell: bash
227212
run: |
228-
$dst='.\build\Release'
229-
robocopy build_deps\_install\bin\zlib.dll $dst
230-
robocopy build\bin\Release\llama.dll $dst
231-
mkdir -p .\build\Release\config
232-
robocopy config.json .\build\Release\config
233-
7z a nitro.zip .\build\Release\*
213+
mkdir -p nitro && mkdir -p nitro/config
214+
cp config.json nitro/config/
215+
cp build/nitro nitro/
216+
zip -r nitro.zip nitro
234217
235218
- uses: actions/upload-release-asset@v1.0.1
236219
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
@@ -244,6 +227,8 @@ jobs:
244227

245228
windows-amd64-build:
246229
runs-on: windows-latest
230+
needs: create-draft-release
231+
if: always() && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped')
247232
permissions:
248233
contents: write
249234

@@ -255,7 +240,7 @@ jobs:
255240
strategy:
256241
matrix:
257242
include:
258-
- build: 'openblas'
243+
- build: 'normal'
259244
defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_BLAS=ON -DBUILD_SHARED_LIBS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"'
260245

261246
steps:
@@ -266,18 +251,17 @@ jobs:
266251
with:
267252
submodules: recursive
268253

269-
- name: Download OpenBLAS
270-
id: get_openblas
271-
if: ${{ matrix.build == 'openblas' }}
272-
run: |
273-
curl.exe -o $env:RUNNER_TEMP/openblas.zip -L "https://github.com/xianyi/OpenBLAS/releases/download/v${env:OPENBLAS_VERSION}/OpenBLAS-${env:OPENBLAS_VERSION}-x64.zip"
274-
curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
275-
mkdir $env:RUNNER_TEMP/openblas
276-
tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
277-
$vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
278-
$msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
279-
$lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
280-
& $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
254+
- name: Setup VSWhere.exe
255+
uses: warrenbuckley/Setup-VSWhere@v1
256+
with:
257+
version: latest
258+
silent: true
259+
env:
260+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
261+
262+
263+
- name: actions-setup-cmake
264+
uses: jwlawson/actions-setup-cmake@v1.14.1
281265

282266
- name: Build
283267
id: cmake_build
@@ -287,26 +271,9 @@ jobs:
287271
cmake --build ./build_deps/nitro_deps --config Release
288272
mkdir build
289273
cd build
290-
cmake .. ${{ matrix.defines }}
274+
cmake ..
291275
cmake --build . --config Release -j 4
292276
293-
- name: Add libopenblas.dll
294-
id: add_libopenblas_dll
295-
if: ${{ matrix.build == 'openblas' }}
296-
run: |
297-
cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/Release/openblas.dll
298-
cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
299-
300-
- name: Extract branch name
301-
shell: cmd
302-
id: extract_branch
303-
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
304-
305-
- name: Extract commit short SHA
306-
shell: cmd
307-
id: extract_commit_id
308-
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
309-
310277
- name: Pack artifacts
311278
id: pack_artifacts
312279
run: |
@@ -317,16 +284,20 @@ jobs:
317284
robocopy config.json .\build\Release\config
318285
7z a nitro.zip .\build\Release\*
319286
320-
- name: Upload binaries to release
321-
uses: svenstaro/upload-release-action@v2
287+
- uses: actions/upload-release-asset@v1.0.1
288+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
289+
env:
290+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
322291
with:
323-
repo_token: ${{ secrets.GITHUB_TOKEN }}
324-
file: nitro.zip
325-
asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-win-amd64-${{ matrix.build }}.zip
326-
tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }}
292+
upload_url: ${{ needs.create-draft-release.outputs.upload_url }}
293+
asset_path: ./nitro.zip
294+
asset_name: nitro-${{ needs.create-draft-release.outputs.version }}-win-amd64-${{ matrix.build }}.zip
295+
asset_content_type: application/zip
327296

328297
windows-amd64-cuda-build:
329298
runs-on: windows-nvidia
299+
needs: create-draft-release
300+
if: always() && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped')
330301
permissions:
331302
contents: write
332303

@@ -342,12 +313,13 @@ jobs:
342313
with:
343314
submodules: recursive
344315

345-
# - uses: Jimver/cuda-toolkit@v0.2.11
346-
# id: cuda-toolkit
347-
# with:
348-
# cuda: ${{ matrix.cuda }}
349-
# method: 'network'
350-
# sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
316+
- name: Setup VSWhere.exe
317+
uses: warrenbuckley/Setup-VSWhere@v1
318+
with:
319+
version: latest
320+
silent: true
321+
env:
322+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
351323

352324
- name: Build
353325
id: cmake_build
@@ -360,35 +332,28 @@ jobs:
360332
cmake .. -DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_CUBLAS=ON -DBUILD_SHARED_LIBS=ON
361333
cmake --build . --config Release -j 4
362334
363-
- name: Extract branch name
364-
shell: cmd
365-
id: extract_branch
366-
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
367-
368-
- name: Extract commit short SHA
369-
shell: cmd
370-
id: extract_commit_id
371-
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
372-
373-
374335
- name: Pack artifacts
375336
id: pack_artifacts
337+
shell: cmd
376338
run: |
339+
set PATH=%PATH%;C:\Program Files\7-Zip\
340+
echo %PATH%
377341
$dst='.\build\Release'
378342
robocopy build_deps\_install\bin\zlib.dll $dst
379343
robocopy build\bin\Release\llama.dll $dst
380-
robocopy "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
381344
mkdir -p .\build\Release\config
382345
robocopy config.json .\build\Release\config
383346
7z a nitro.zip .\build\Release\*
384347
385-
- name: Upload binaries to release
386-
uses: svenstaro/upload-release-action@v2
348+
- uses: actions/upload-release-asset@v1.0.1
349+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
350+
env:
351+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
387352
with:
388-
repo_token: ${{ secrets.GITHUB_TOKEN }}
389-
file: nitro.zip
390-
asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-win-amd64-${{ matrix.build }}-cu${{ matrix.cuda }}.zip
391-
tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }}
353+
upload_url: ${{ needs.create-draft-release.outputs.upload_url }}
354+
asset_path: ./nitro.zip
355+
asset_name: nitro-${{ needs.create-draft-release.outputs.version }}-win-amd64-${{ matrix.build }}-cu${{ matrix.cuda }}.zip
356+
asset_content_type: application/zip
392357

393358
update_release_draft:
394359
needs: [ubuntu-amd64-build, ubuntu-amd64-cuda-build, macOS-M-build, macOS-Intel-build, windows-amd64-build, windows-amd64-cuda-build]

0 commit comments

Comments
 (0)