From 17b4d5ed3d55214821354d1509777b77ae88a0c3 Mon Sep 17 00:00:00 2001 From: vuonghoainam Date: Thu, 5 Oct 2023 14:26:32 +0700 Subject: [PATCH 01/13] =?UTF-8?q?feat(ci):=20A=C4=91=20mac=20intel=20and?= =?UTF-8?q?=20linux=20no=20cuda=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 67 +++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..76d1904e0 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,67 @@ +name: CI + +on: + workflow_dispatch: # allows manual triggering + inputs: + create_release: + description: 'Create new release' + required: true + type: boolean + push: + branches: + - master + - 35-add-github-action-for-nitro-build + paths: ['.github/workflows/**', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu'] + pull_request: + types: [opened, synchronize, reopened] + paths: ['**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu'] + +env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + GGML_NLOOP: 3 + GGML_N_THREADS: 1 + +jobs: + ubuntu-focal-make: + runs-on: ubuntu-20.04 + + steps: + - name: Clone + id: checkout + uses: actions/checkout@v3 + + - name: Dependencies + id: depends + run: | + sudo apt-get update + sudo apt-get install build-essential gcc-8 + + - name: Build + id: make_build + run: | + mkdir build && cd build + cmake .. + CC=gcc-8 make -j $(nproc) + ls -la + + macOS-latest-cmake: + runs-on: macos-latest + + steps: + - name: Clone + id: checkout + uses: actions/checkout@v3 + + - name: Dependencies + id: depends + continue-on-error: true + run: | + brew update + + - name: Build + id: cmake_build + run: | + mkdir build && cd build + cmake -DLLAMA_METAL=OFF .. + CC=gcc-8 make -j $(nproc) + ls -la From b0431ce3a8a927203a0fbc826b2b6a1b7206924f Mon Sep 17 00:00:00 2001 From: vuonghoainam Date: Thu, 5 Oct 2023 14:31:02 +0700 Subject: [PATCH 02/13] fix(ci): Update ./install_deps.sh as step --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 76d1904e0..94a77bf33 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,6 +39,7 @@ jobs: - name: Build id: make_build run: | + ./install_deps.sh mkdir build && cd build cmake .. CC=gcc-8 make -j $(nproc) @@ -61,6 +62,7 @@ jobs: - name: Build id: cmake_build run: | + ./install_deps.sh mkdir build && cd build cmake -DLLAMA_METAL=OFF .. CC=gcc-8 make -j $(nproc) From 7dd870442c39efab6d4eb596309f9dd4e6f6a2d5 Mon Sep 17 00:00:00 2001 From: vuonghoainam Date: Thu, 5 Oct 2023 14:36:52 +0700 Subject: [PATCH 03/13] fix(ci): Add clone recursive for llama.cpp git submodule --- .github/workflows/build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 94a77bf33..297a1729d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,6 +29,8 @@ jobs: - name: Clone id: checkout uses: actions/checkout@v3 + with: + submodules: recursive - name: Dependencies id: depends @@ -52,6 +54,8 @@ jobs: - name: Clone id: checkout uses: actions/checkout@v3 + with: + submodules: recursive - name: Dependencies id: depends From 7be7a471bf5176555be4e0a495d8a1927af748ca Mon Sep 17 00:00:00 2001 From: vuonghoainam Date: Thu, 5 Oct 2023 15:00:59 +0700 Subject: [PATCH 04/13] feat(ci): Add linux gpu and mac sillicon build env --- .github/workflows/build.yml | 66 +++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 297a1729d..e294fc624 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,13 +18,12 @@ on: env: BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - GGML_NLOOP: 3 - GGML_N_THREADS: 1 jobs: - ubuntu-focal-make: + ubuntu-amd64-build: runs-on: ubuntu-20.04 - + permissions: + contents: write steps: - name: Clone id: checkout @@ -47,9 +46,36 @@ jobs: CC=gcc-8 make -j $(nproc) ls -la - macOS-latest-cmake: - runs-on: macos-latest + ubuntu-amd64-cuda-build: + runs-on: linux-gpu + permissions: + contents: write + steps: + - name: Clone + id: checkout + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Dependencies + id: depends + run: | + sudo apt-get update + sudo apt-get install build-essential gcc-8 + - name: Build + id: make_build + run: | + ./install_deps.sh + mkdir build && cd build + cmake -DLLAMA_CUBLAS=ON .. + CC=gcc-8 make -j $(nproc) + ls -la + + macOS-M-build: + runs-on: mac-silicon + permissions: + contents: write steps: - name: Clone id: checkout @@ -68,6 +94,32 @@ jobs: run: | ./install_deps.sh mkdir build && cd build - cmake -DLLAMA_METAL=OFF .. + cmake .. CC=gcc-8 make -j $(nproc) ls -la + + macOS-Intel-build: + runs-on: macos-latest + permissions: + contents: write + steps: + - name: Clone + id: checkout + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Dependencies + id: depends + continue-on-error: true + run: | + brew update + + - name: Build + id: cmake_build + run: | + ./install_deps.sh + mkdir build && cd build + cmake -DLLAMA_METAL=OFF .. + CC=gcc-8 make -j $(nproc) + ls -la \ No newline at end of file From 32bab7e816765ed7d7baa6484de4e79f51aef2e3 Mon Sep 17 00:00:00 2001 From: vuonghoainam Date: Thu, 5 Oct 2023 15:10:11 +0700 Subject: [PATCH 05/13] fix(ci): Update release action --- .github/workflows/build.yml | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e294fc624..b871abcb2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,6 +46,14 @@ jobs: CC=gcc-8 make -j $(nproc) ls -la + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: build/nitro + asset_name: nitro-linux-amd64 + tag: ${{ github.ref }} + ubuntu-amd64-cuda-build: runs-on: linux-gpu permissions: @@ -70,7 +78,15 @@ jobs: mkdir build && cd build cmake -DLLAMA_CUBLAS=ON .. CC=gcc-8 make -j $(nproc) - ls -la + ls -la + + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: build/nitro + asset_name: nitro-linux-amd64-cuda + tag: ${{ github.ref }} macOS-M-build: runs-on: mac-silicon @@ -98,6 +114,14 @@ jobs: CC=gcc-8 make -j $(nproc) ls -la + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: build/nitro + asset_name: nitro-mac-arm64-metal + tag: ${{ github.ref }} + macOS-Intel-build: runs-on: macos-latest permissions: @@ -122,4 +146,12 @@ jobs: mkdir build && cd build cmake -DLLAMA_METAL=OFF .. CC=gcc-8 make -j $(nproc) - ls -la \ No newline at end of file + ls -la + + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: build/nitro + asset_name: nitro-mac-amd64 + tag: ${{ github.ref }} \ No newline at end of file From fca69c18f290c2e9d283e05389421135d00c1b0c Mon Sep 17 00:00:00 2001 From: vuonghoainam Date: Thu, 5 Oct 2023 15:13:13 +0700 Subject: [PATCH 06/13] fix(ci): Disable deps installation on self hosted linux gpu --- .github/workflows/build.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b871abcb2..507437d31 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -65,11 +65,11 @@ jobs: with: submodules: recursive - - name: Dependencies - id: depends - run: | - sudo apt-get update - sudo apt-get install build-essential gcc-8 + # - name: Dependencies + # id: depends + # run: | + # sudo apt-get update + # sudo apt-get install build-essential gcc-8 - name: Build id: make_build From 1ac4c9e3a89a6b4a94a9726c8f7faa0b8bb3ded9 Mon Sep 17 00:00:00 2001 From: vuonghoainam Date: Thu, 5 Oct 2023 15:14:23 +0700 Subject: [PATCH 07/13] fix(ci): Update mac m cmake and gc installation --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 507437d31..3884da710 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -104,6 +104,7 @@ jobs: continue-on-error: true run: | brew update + brew install cmake gcc@8 - name: Build id: cmake_build From c3a175f6f1601d45c85371f2bdf3de9cfa04208e Mon Sep 17 00:00:00 2001 From: vuonghoainam Date: Thu, 5 Oct 2023 15:42:06 +0700 Subject: [PATCH 08/13] feat(ci): Release as zip --- .github/workflows/build.yml | 132 ++++++++++++++++++++++++++++++++---- 1 file changed, 119 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3884da710..0092fdf0e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,13 +46,39 @@ jobs: CC=gcc-8 make -j $(nproc) ls -la + - name: Determine tag name + id: tag + shell: bash + run: | + BUILD_NUMBER="$(git rev-list --count HEAD)" + SHORT_HASH="$(git rev-parse --short=7 HEAD)" + if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then + echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT + else + SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') + echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT + fi + + - name: Package + shell: bash + run: | + mkdir -p build/nitro-${{ steps.tag.outputs.name }}-linux-amd64 + mkdir -p build/nitro-${{ steps.tag.outputs.name }}-linux-amd64/config + cp config.json build/nitro-${{ steps.tag.outputs.name }}-linux-amd64/config + cp build/nitro build/nitro-${{ steps.tag.outputs.name }}-linux-amd64 + cd build + zip -r nitro-${{ steps.tag.outputs.name }}-linux-amd64.zip nitro-${{ steps.tag.outputs.name }}-linux-amd64 + ls -la + cd .. + - name: Upload binaries to release + if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: build/nitro - asset_name: nitro-linux-amd64 - tag: ${{ github.ref }} + file: build/nitro-${{ steps.tag.outputs.name }}-linux-amd64.zip + asset_name: nitro-${{ steps.tag.outputs.name }}-linux-amd64.zip + tag: ${{ steps.tag.outputs.name }} ubuntu-amd64-cuda-build: runs-on: linux-gpu @@ -69,7 +95,7 @@ jobs: # id: depends # run: | # sudo apt-get update - # sudo apt-get install build-essential gcc-8 + # sudo apt-get install build-essential gcc-8 uuid-dev - name: Build id: make_build @@ -80,13 +106,39 @@ jobs: CC=gcc-8 make -j $(nproc) ls -la + - name: Determine tag name + id: tag + shell: bash + run: | + BUILD_NUMBER="$(git rev-list --count HEAD)" + SHORT_HASH="$(git rev-parse --short=7 HEAD)" + if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then + echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT + else + SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') + echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT + fi + + - name: Package + shell: bash + run: | + mkdir -p build/nitro-${{ steps.tag.outputs.name }}-linux-amd64-cuda + mkdir -p build/nitro-${{ steps.tag.outputs.name }}-linux-amd64-cuda/config + cp config.json build/nitro-${{ steps.tag.outputs.name }}-linux-amd64-cuda/config + cp build/nitro build/nitro-${{ steps.tag.outputs.name }}-linux-amd64-cuda + cd build + zip -r nitro-${{ steps.tag.outputs.name }}-linux-amd64-cuda.zip nitro-${{ steps.tag.outputs.name }}-linux-amd64-cuda + ls -la + cd .. + - name: Upload binaries to release + if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: build/nitro - asset_name: nitro-linux-amd64-cuda - tag: ${{ github.ref }} + file: build/nitro-${{ steps.tag.outputs.name }}-linux-amd64-cuda.zip + asset_name: nitro-${{ steps.tag.outputs.name }}-linux-amd64-cuda.zip + tag: ${{ steps.tag.outputs.name }} macOS-M-build: runs-on: mac-silicon @@ -115,13 +167,40 @@ jobs: CC=gcc-8 make -j $(nproc) ls -la + - name: Determine tag name + id: tag + shell: bash + run: | + BUILD_NUMBER="$(git rev-list --count HEAD)" + SHORT_HASH="$(git rev-parse --short=7 HEAD)" + if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then + echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT + else + SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') + echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT + fi + + - name: Package + shell: bash + run: | + mkdir -p build/nitro-${{ steps.tag.outputs.name }}-mac-arm64 + mkdir -p build/nitro-${{ steps.tag.outputs.name }}-mac-arm64/config + cp config.json build/nitro-${{ steps.tag.outputs.name }}-mac-arm64/config + cp llama.cpp/ggml-metal.h build/nitro-${{ steps.tag.outputs.name }}-mac-arm64 + cp build/nitro build/nitro-${{ steps.tag.outputs.name }}-mac-arm64 + cd build + zip -r nitro-${{ steps.tag.outputs.name }}-mac-arm64.zip nitro-${{ steps.tag.outputs.name }}-mac-arm64 + ls -la + cd .. + - name: Upload binaries to release + if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: build/nitro - asset_name: nitro-mac-arm64-metal - tag: ${{ github.ref }} + file: build/nitro-${{ steps.tag.outputs.name }}-mac-arm64.zip + asset_name: nitro-${{ steps.tag.outputs.name }}-mac-arm64.zip + tag: ${{ steps.tag.outputs.name }} macOS-Intel-build: runs-on: macos-latest @@ -149,10 +228,37 @@ jobs: CC=gcc-8 make -j $(nproc) ls -la + - name: Determine tag name + id: tag + shell: bash + run: | + BUILD_NUMBER="$(git rev-list --count HEAD)" + SHORT_HASH="$(git rev-parse --short=7 HEAD)" + if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then + echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT + else + SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') + echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT + fi + + - name: Package + shell: bash + run: | + mkdir -p build/nitro-${{ steps.tag.outputs.name }}-mac-amd64 + mkdir -p build/nitro-${{ steps.tag.outputs.name }}-mac-amd64/config + cp config.json build/nitro-${{ steps.tag.outputs.name }}-mac-amd64/config + cp llama.cpp/ggml-metal.h build/nitro-${{ steps.tag.outputs.name }}-mac-amd64 + cp build/nitro build/nitro-${{ steps.tag.outputs.name }}-mac-amd64 + cd build + zip -r nitro-${{ steps.tag.outputs.name }}-mac-amd64.zip nitro-${{ steps.tag.outputs.name }}-mac-amd64 + ls -la + cd .. + - name: Upload binaries to release + if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: build/nitro - asset_name: nitro-mac-amd64 - tag: ${{ github.ref }} \ No newline at end of file + file: build/nitro-${{ steps.tag.outputs.name }}-mac-amd64.zip + asset_name: nitro-${{ steps.tag.outputs.name }}-mac-amd64.zip.zip + tag: ${{ steps.tag.outputs.name }} \ No newline at end of file From d0957daf8362a30dd8e7c51758d9254be3db25f9 Mon Sep 17 00:00:00 2001 From: vuonghoainam Date: Thu, 5 Oct 2023 15:51:39 +0700 Subject: [PATCH 09/13] chore(ci): Temp disable if in publish --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0092fdf0e..efc22caba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -132,7 +132,7 @@ jobs: cd .. - name: Upload binaries to release - if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} + # if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} @@ -194,7 +194,7 @@ jobs: cd .. - name: Upload binaries to release - if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} + # if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} @@ -255,7 +255,7 @@ jobs: cd .. - name: Upload binaries to release - if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} + # if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} From 38647e3e0e5329f10d5cb7c68310b5ea2c396de8 Mon Sep 17 00:00:00 2001 From: vuonghoainam Date: Thu, 5 Oct 2023 16:16:02 +0700 Subject: [PATCH 10/13] fix(ci): Update tag name and unified steps --- .github/workflows/build.yml | 152 ++++++++++++++---------------------- 1 file changed, 59 insertions(+), 93 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index efc22caba..a461e6164 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,39 +46,30 @@ jobs: CC=gcc-8 make -j $(nproc) ls -la - - name: Determine tag name - id: tag + - name: Extract branch name shell: bash - run: | - BUILD_NUMBER="$(git rev-list --count HEAD)" - SHORT_HASH="$(git rev-parse --short=7 HEAD)" - if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then - echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT - else - SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') - echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT - fi + id: extract_branch + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + - name: Extract commit short SHA + id: extract_commit_id + run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - name: Package shell: bash run: | - mkdir -p build/nitro-${{ steps.tag.outputs.name }}-linux-amd64 - mkdir -p build/nitro-${{ steps.tag.outputs.name }}-linux-amd64/config - cp config.json build/nitro-${{ steps.tag.outputs.name }}-linux-amd64/config - cp build/nitro build/nitro-${{ steps.tag.outputs.name }}-linux-amd64 - cd build - zip -r nitro-${{ steps.tag.outputs.name }}-linux-amd64.zip nitro-${{ steps.tag.outputs.name }}-linux-amd64 - ls -la - cd .. + mkdir -p nitro && mkdir -p nitro/config + cp config.json nitro/config/ + cp build/nitro nitro/ + zip -r nitro.zip nitro - name: Upload binaries to release - if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} + # if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: build/nitro-${{ steps.tag.outputs.name }}-linux-amd64.zip - asset_name: nitro-${{ steps.tag.outputs.name }}-linux-amd64.zip - tag: ${{ steps.tag.outputs.name }} + file: nitro.zip + asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-linux-amd64.zip + tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} ubuntu-amd64-cuda-build: runs-on: linux-gpu @@ -106,39 +97,31 @@ jobs: CC=gcc-8 make -j $(nproc) ls -la - - name: Determine tag name - id: tag + - name: Extract branch name shell: bash - run: | - BUILD_NUMBER="$(git rev-list --count HEAD)" - SHORT_HASH="$(git rev-parse --short=7 HEAD)" - if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then - echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT - else - SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') - echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT - fi + id: extract_branch + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + + - name: Extract commit short SHA + id: extract_commit_id + run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - name: Package shell: bash run: | - mkdir -p build/nitro-${{ steps.tag.outputs.name }}-linux-amd64-cuda - mkdir -p build/nitro-${{ steps.tag.outputs.name }}-linux-amd64-cuda/config - cp config.json build/nitro-${{ steps.tag.outputs.name }}-linux-amd64-cuda/config - cp build/nitro build/nitro-${{ steps.tag.outputs.name }}-linux-amd64-cuda - cd build - zip -r nitro-${{ steps.tag.outputs.name }}-linux-amd64-cuda.zip nitro-${{ steps.tag.outputs.name }}-linux-amd64-cuda - ls -la - cd .. + mkdir -p nitro && mkdir -p nitro/config + cp config.json nitro/config/ + cp build/nitro nitro/ + zip -r nitro.zip nitro - name: Upload binaries to release # if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: build/nitro-${{ steps.tag.outputs.name }}-linux-amd64-cuda.zip - asset_name: nitro-${{ steps.tag.outputs.name }}-linux-amd64-cuda.zip - tag: ${{ steps.tag.outputs.name }} + file: nitro.zip + asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-linux-amd64-cuda.zip + tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} macOS-M-build: runs-on: mac-silicon @@ -167,40 +150,32 @@ jobs: CC=gcc-8 make -j $(nproc) ls -la - - name: Determine tag name - id: tag + - name: Extract branch name shell: bash - run: | - BUILD_NUMBER="$(git rev-list --count HEAD)" - SHORT_HASH="$(git rev-parse --short=7 HEAD)" - if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then - echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT - else - SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') - echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT - fi - + id: extract_branch + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + + - name: Extract commit short SHA + id: extract_commit_id + run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + - name: Package shell: bash run: | - mkdir -p build/nitro-${{ steps.tag.outputs.name }}-mac-arm64 - mkdir -p build/nitro-${{ steps.tag.outputs.name }}-mac-arm64/config - cp config.json build/nitro-${{ steps.tag.outputs.name }}-mac-arm64/config - cp llama.cpp/ggml-metal.h build/nitro-${{ steps.tag.outputs.name }}-mac-arm64 - cp build/nitro build/nitro-${{ steps.tag.outputs.name }}-mac-arm64 - cd build - zip -r nitro-${{ steps.tag.outputs.name }}-mac-arm64.zip nitro-${{ steps.tag.outputs.name }}-mac-arm64 - ls -la - cd .. + mkdir -p nitro && mkdir -p nitro/config + cp config.json nitro/config/ + cp llama.cpp/ggml-metal.h nitro/ + cp build/nitro nitro/ + zip -r nitro.zip nitro - name: Upload binaries to release # if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: build/nitro-${{ steps.tag.outputs.name }}-mac-arm64.zip - asset_name: nitro-${{ steps.tag.outputs.name }}-mac-arm64.zip - tag: ${{ steps.tag.outputs.name }} + file: nitro.zip + asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-mac-arm64.zip + tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} macOS-Intel-build: runs-on: macos-latest @@ -228,37 +203,28 @@ jobs: CC=gcc-8 make -j $(nproc) ls -la - - name: Determine tag name - id: tag + - name: Extract branch name shell: bash - run: | - BUILD_NUMBER="$(git rev-list --count HEAD)" - SHORT_HASH="$(git rev-parse --short=7 HEAD)" - if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then - echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT - else - SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') - echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT - fi - + id: extract_branch + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + + - name: Extract commit short SHA + id: extract_commit_id + run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + - name: Package shell: bash run: | - mkdir -p build/nitro-${{ steps.tag.outputs.name }}-mac-amd64 - mkdir -p build/nitro-${{ steps.tag.outputs.name }}-mac-amd64/config - cp config.json build/nitro-${{ steps.tag.outputs.name }}-mac-amd64/config - cp llama.cpp/ggml-metal.h build/nitro-${{ steps.tag.outputs.name }}-mac-amd64 - cp build/nitro build/nitro-${{ steps.tag.outputs.name }}-mac-amd64 - cd build - zip -r nitro-${{ steps.tag.outputs.name }}-mac-amd64.zip nitro-${{ steps.tag.outputs.name }}-mac-amd64 - ls -la - cd .. + mkdir -p nitro && mkdir -p nitro/config + cp config.json nitro/config/ + cp build/nitro nitro/ + zip -r nitro.zip nitro - name: Upload binaries to release # if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: build/nitro-${{ steps.tag.outputs.name }}-mac-amd64.zip - asset_name: nitro-${{ steps.tag.outputs.name }}-mac-amd64.zip.zip - tag: ${{ steps.tag.outputs.name }} \ No newline at end of file + file: build/nitro-${{ steps.extract_commit_id.outputs.sha_short }}-mac-amd64.zip + asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-mac-amd64.zip.zip + tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} \ No newline at end of file From b29e481df9d4021d7bf5c07d63b7d3c971150d48 Mon Sep 17 00:00:00 2001 From: vuonghoainam Date: Thu, 5 Oct 2023 16:29:00 +0700 Subject: [PATCH 11/13] fix(ci): Update file in mac intel build --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a461e6164..22263545c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -225,6 +225,6 @@ jobs: uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: build/nitro-${{ steps.extract_commit_id.outputs.sha_short }}-mac-amd64.zip + file: nitro.zip asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-mac-amd64.zip.zip tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} \ No newline at end of file From d09bae493d60112581664b6a5fff4d9c3cdb71f6 Mon Sep 17 00:00:00 2001 From: vuonghoainam Date: Thu, 5 Oct 2023 16:41:46 +0700 Subject: [PATCH 12/13] fix(ci): Change body name --- .github/workflows/build.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 22263545c..f15e92d7d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -69,7 +69,8 @@ jobs: repo_token: ${{ secrets.GITHUB_TOKEN }} file: nitro.zip asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-linux-amd64.zip - tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} + body: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} + overwrite: true ubuntu-amd64-cuda-build: runs-on: linux-gpu @@ -121,7 +122,8 @@ jobs: repo_token: ${{ secrets.GITHUB_TOKEN }} file: nitro.zip asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-linux-amd64-cuda.zip - tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} + body: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} + overwrite: true macOS-M-build: runs-on: mac-silicon @@ -175,7 +177,8 @@ jobs: repo_token: ${{ secrets.GITHUB_TOKEN }} file: nitro.zip asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-mac-arm64.zip - tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} + body: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} + overwrite: true macOS-Intel-build: runs-on: macos-latest @@ -227,4 +230,5 @@ jobs: repo_token: ${{ secrets.GITHUB_TOKEN }} file: nitro.zip asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-mac-amd64.zip.zip - tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} \ No newline at end of file + body: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} + overwrite: true \ No newline at end of file From 1d30aea8c4b7242d9fe5b366a70f18edeceaaf8c Mon Sep 17 00:00:00 2001 From: vuonghoainam Date: Thu, 5 Oct 2023 16:51:35 +0700 Subject: [PATCH 13/13] chore(ci): Update conditional step and body content --- .github/workflows/build.yml | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f15e92d7d..ee9e9a2c8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,6 @@ on: push: branches: - master - - 35-add-github-action-for-nitro-build paths: ['.github/workflows/**', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu'] pull_request: types: [opened, synchronize, reopened] @@ -63,14 +62,13 @@ jobs: zip -r nitro.zip nitro - name: Upload binaries to release - # if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} + if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: nitro.zip asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-linux-amd64.zip - body: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} - overwrite: true + tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} ubuntu-amd64-cuda-build: runs-on: linux-gpu @@ -116,14 +114,13 @@ jobs: zip -r nitro.zip nitro - name: Upload binaries to release - # if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} + if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: nitro.zip asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-linux-amd64-cuda.zip - body: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} - overwrite: true + tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} macOS-M-build: runs-on: mac-silicon @@ -171,14 +168,13 @@ jobs: zip -r nitro.zip nitro - name: Upload binaries to release - # if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} + if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: nitro.zip asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-mac-arm64.zip - body: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} - overwrite: true + tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} macOS-Intel-build: runs-on: macos-latest @@ -224,11 +220,10 @@ jobs: zip -r nitro.zip nitro - name: Upload binaries to release - # if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} + if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: nitro.zip asset_name: nitro-${{ steps.extract_commit_id.outputs.sha_short }}-mac-amd64.zip.zip - body: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} - overwrite: true \ No newline at end of file + tag: ${{ steps.extract_branch.outputs.branch }}-${{ steps.extract_commit_id.outputs.sha_short }} \ No newline at end of file