Merge pull request #351 from janhq/349-feat-self-extend-support #464
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
schedule: | |
- cron: "0 20 * * *" # At 8 PM UTC, which is 3 AM UTC+7 | |
push: | |
branches: | |
- main | |
tags: ["v[0-9]+.[0-9]+.[0-9]+"] | |
paths: | |
[ | |
".github/scripts/**", | |
".github/workflows/build.yml", | |
"**/CMakeLists.txt", | |
"**/Makefile", | |
"**/*.h", | |
"**/*.hpp", | |
"**/*.c", | |
"**/*.cpp", | |
"**/*.cu", | |
"**/*.cc", | |
"**/*.cxx", | |
"llama.cpp", | |
"!docs/**", | |
"!.gitignore", | |
"!README.md", | |
] | |
pull_request: | |
types: [opened, synchronize, reopened] | |
paths: | |
[ | |
".github/scripts/**", | |
".github/workflows/build.yml", | |
"**/CMakeLists.txt", | |
"**/Makefile", | |
"**/*.h", | |
"**/*.hpp", | |
"**/*.c", | |
"**/*.cpp", | |
"**/*.cu", | |
"**/*.cc", | |
"**/*.cxx", | |
"llama.cpp", | |
"!docs/**", | |
"!.gitignore", | |
"!README.md", | |
] | |
workflow_dispatch: | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
MODEL_URL: https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v0.3-GGUF/resolve/main/tinyllama-1.1b-chat-v0.3.Q2_K.gguf | |
jobs: | |
create-draft-release: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
version: ${{ steps.get_version.outputs.version }} | |
permissions: | |
contents: write | |
steps: | |
- name: Extract tag name without v prefix | |
id: get_version | |
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV && echo "::set-output name=version::${GITHUB_REF#refs/tags/v}" | |
env: | |
GITHUB_REF: ${{ github.ref }} | |
- name: Create Draft Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref_name }} | |
release_name: "${{ env.VERSION }}" | |
draft: true | |
prerelease: false | |
# Get the latest version of the release | |
set-nitro-version: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.version_update.outputs.new_version }} | |
steps: | |
- name: Get latest release | |
id: version_update | |
run: | | |
ldd --version | |
if [[ ${{ github.event_name }} == push && ${{ github.ref }} == refs/tags/* ]]; then | |
echo "VERSION=${GITHUB_REF#refs/tags/}" | |
NEW_VERSION="${VERSION#v}" | |
echo "::set-output name=new_version::$NEW_VERSION" | |
else | |
# Function to get the latest release tag | |
get_latest_tag() { | |
local retries=0 | |
local max_retries=3 | |
local tag | |
while [ $retries -lt $max_retries ]; do | |
tag=$(curl -s https://api.github.com/repos/janhq/nitro/releases/latest | jq -r .tag_name) | |
if [ -n "$tag" ] && [ "$tag" != "null" ]; then | |
echo $tag | |
return | |
else | |
let retries++ | |
sleep 2 | |
fi | |
done | |
echo "Failed to fetch latest tag after $max_retries attempts." | |
exit 1 | |
} | |
# Get the latest release tag from GitHub API | |
LATEST_TAG=$(get_latest_tag) | |
# Remove the 'v' and append the build number to the version | |
NEW_VERSION="${LATEST_TAG#v}-${GITHUB_RUN_NUMBER}" | |
echo "New version: $NEW_VERSION" | |
echo "::set-output name=new_version::$NEW_VERSION" | |
fi | |
echo "Version: $NEW_VERSION" | |
ubuntu-amd64-build: | |
runs-on: ubuntu-18-04-cuda-11-7 | |
needs: [create-draft-release, set-nitro-version] | |
if: always() && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped') && needs.set-nitro-version.result == 'success' | |
permissions: | |
contents: write | |
steps: | |
- name: Clone | |
id: checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Build | |
id: make_build | |
run: | | |
ldd --version | |
./install_deps.sh | |
mkdir build && cd build | |
cmake -DLLAMA_NATIVE=OFF -DNITRO_VERSION=${{ needs.set-nitro-version.outputs.version }} .. | |
make -j $(nproc) | |
ls -la | |
- name: Package | |
shell: bash | |
run: | | |
mkdir -p nitro | |
cp build/nitro nitro/ | |
tar -czvf nitro.tar.gz nitro | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
with: | |
name: nitro-linux-amd64 | |
path: ./nitro | |
- name: Run e2e testing | |
shell: bash | |
run: | | |
# run e2e testing | |
cd nitro | |
chmod +x ../.github/scripts/e2e-test-linux-and-mac.sh && ../.github/scripts/e2e-test-linux-and-mac.sh ./nitro ${{ env.MODEL_URL }} | |
- uses: actions/[email protected] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-draft-release.outputs.upload_url }} | |
asset_path: ./nitro.tar.gz | |
asset_name: nitro-${{ needs.create-draft-release.outputs.version }}-linux-amd64.tar.gz | |
asset_content_type: application/gzip | |
ubuntu-amd64-cuda-build: | |
runs-on: ubuntu-18-04-cuda-${{ matrix.cuda }} | |
needs: [create-draft-release, set-nitro-version] | |
if: always() && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped') && needs.set-nitro-version.result == 'success' | |
permissions: | |
contents: write | |
strategy: | |
matrix: | |
cuda: ["12-0", "11-7"] | |
steps: | |
- name: Clone | |
id: checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Build | |
id: make_build | |
run: | | |
./install_deps.sh | |
mkdir build && cd build | |
cmake -DLLAMA_CUBLAS=ON -DLLAMA_NATIVE=OFF -DNITRO_VERSION=${{ needs.set-nitro-version.outputs.version }} .. | |
make -j $(nproc) | |
ls -la | |
- name: Package | |
shell: bash | |
run: | | |
mkdir -p nitro | |
cp build/nitro nitro/ | |
tar -czvf nitro.tar.gz nitro | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
with: | |
name: nitro-linux-amd64-cuda-${{ matrix.cuda }} | |
path: ./nitro | |
# - name: Run e2e testing | |
# shell: bash | |
# run: | | |
# # run e2e testing | |
# cd nitro | |
# chmod +x ../.github/scripts/e2e-test-linux-and-mac.sh && ../.github/scripts/e2e-test-linux-and-mac.sh ./nitro ${{ env.MODEL_URL }} | |
- uses: actions/[email protected] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-draft-release.outputs.upload_url }} | |
asset_path: ./nitro.tar.gz | |
asset_name: nitro-${{ needs.create-draft-release.outputs.version }}-linux-amd64-cuda-${{ matrix.cuda }}.tar.gz | |
asset_content_type: application/gzip | |
macOS-M-build: | |
runs-on: mac-silicon | |
needs: [create-draft-release, set-nitro-version] | |
if: always() && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped') && needs.set-nitro-version.result == 'success' | |
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 | |
brew install cmake | |
- name: Build | |
id: cmake_build | |
run: | | |
./install_deps.sh | |
mkdir build && cd build | |
cmake -DNITRO_VERSION=${{ needs.set-nitro-version.outputs.version }} .. | |
CC=gcc-8 make -j $(sysctl -n hw.ncp) | |
ls -la | |
- name: Package | |
shell: bash | |
run: | | |
mkdir -p nitro | |
cp llama.cpp/ggml-metal.metal nitro/ | |
cp build/nitro nitro/ | |
tar -czvf nitro.tar.gz nitro | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
with: | |
name: nitro-mac-arm64 | |
path: ./nitro | |
- name: Run e2e testing | |
shell: bash | |
run: | | |
# run e2e testing | |
cd nitro | |
chmod +x ../.github/scripts/e2e-test-linux-and-mac.sh && ../.github/scripts/e2e-test-linux-and-mac.sh ./nitro ${{ env.MODEL_URL }} | |
- uses: actions/[email protected] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-draft-release.outputs.upload_url }} | |
asset_path: ./nitro.tar.gz | |
asset_name: nitro-${{ needs.create-draft-release.outputs.version }}-mac-arm64.tar.gz | |
asset_content_type: application/gzip | |
macOS-Intel-build: | |
runs-on: macos-latest | |
needs: [create-draft-release, set-nitro-version] | |
if: always() && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped') && needs.set-nitro-version.result == 'success' | |
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 -DNITRO_VERSION=${{ needs.set-nitro-version.outputs.version }} -DLLAMA_METAL=OFF .. | |
CC=gcc-8 make -j $(sysctl -n hw.ncp) | |
ls -la | |
- name: Package | |
shell: bash | |
run: | | |
mkdir -p nitro | |
cp build/nitro nitro/ | |
tar -czvf nitro.tar.gz nitro | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
with: | |
name: nitro-mac-amd64 | |
path: ./nitro | |
- name: Run e2e testing | |
shell: bash | |
run: | | |
# run e2e testing | |
cd nitro | |
chmod +x ../.github/scripts/e2e-test-linux-and-mac.sh && ../.github/scripts/e2e-test-linux-and-mac.sh ./nitro ${{ env.MODEL_URL }} | |
- uses: actions/[email protected] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-draft-release.outputs.upload_url }} | |
asset_path: ./nitro.tar.gz | |
asset_name: nitro-${{ needs.create-draft-release.outputs.version }}-mac-amd64.tar.gz | |
asset_content_type: application/gzip | |
windows-amd64-build: | |
runs-on: windows-latest | |
needs: [create-draft-release, set-nitro-version] | |
if: always() && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped') && needs.set-nitro-version.result == 'success' | |
permissions: | |
contents: write | |
steps: | |
- name: Clone | |
id: checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Setup VSWhere.exe | |
uses: warrenbuckley/Setup-VSWhere@v1 | |
with: | |
version: latest | |
silent: true | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
- name: actions-setup-cmake | |
uses: jwlawson/[email protected] | |
- name: Build | |
id: cmake_build | |
shell: cmd | |
run: | | |
cmake -S ./nitro_deps -B ./build_deps/nitro_deps | |
cmake --build ./build_deps/nitro_deps --config Release | |
mkdir -p build | |
cd build | |
cmake .. -DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_BLAS=ON -DBUILD_SHARED_LIBS=ON -DNITRO_VERSION=${{ needs.set-nitro-version.outputs.version }} | |
cmake --build . --config Release -j "%NUMBER_OF_PROCESSORS%" | |
- name: Pack artifacts | |
id: pack_artifacts | |
shell: cmd | |
run: | | |
robocopy build_deps\_install\bin\ .\build\Release\ zlib.dll | |
robocopy build\bin\Release\ .\build\Release\ llama.dll | |
dotnet tool install --global AzureSignTool | |
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 ".\build\Release\nitro.exe" | |
7z a -ttar temp.tar .\build\Release\* | |
7z a -tgzip nitro.tar.gz temp.tar | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
with: | |
name: nitro-win-amd64 | |
path: ./build/Release | |
# - name: Run e2e testing | |
# shell: cmd | |
# run: | | |
# cd .\build\Release | |
# ..\..\.github\scripts\e2e-test-windows.bat .\nitro.exe ${{ env.MODEL_URL }} | |
- uses: actions/[email protected] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-draft-release.outputs.upload_url }} | |
asset_path: ./nitro.tar.gz | |
asset_name: nitro-${{ needs.create-draft-release.outputs.version }}-win-amd64.tar.gz | |
asset_content_type: application/gzip | |
windows-amd64-cuda-build: | |
runs-on: windows-cuda-${{ matrix.cuda }} | |
needs: [create-draft-release, set-nitro-version] | |
if: always() && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped') && needs.set-nitro-version.result == 'success' | |
permissions: | |
contents: write | |
strategy: | |
matrix: | |
cuda: ["12-0", "11-7"] | |
steps: | |
- name: Setup VSWhere.exe | |
uses: warrenbuckley/Setup-VSWhere@v1 | |
with: | |
version: latest | |
silent: true | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
- name: actions-setup-cmake | |
uses: jwlawson/[email protected] | |
- name: Clone | |
id: checkout | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Setup VSWhere.exe | |
uses: warrenbuckley/Setup-VSWhere@v1 | |
with: | |
version: latest | |
silent: true | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
- uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: "6.0.x" | |
- name: Build | |
id: cmake_build | |
shell: cmd | |
run: | | |
cmake -S ./nitro_deps -B ./build_deps/nitro_deps | |
cmake --build ./build_deps/nitro_deps --config Release | |
mkdir -p build | |
cd build | |
cmake .. -DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_CUBLAS=ON -DBUILD_SHARED_LIBS=ON -DNITRO_VERSION=${{ needs.set-nitro-version.outputs.version }} | |
cmake --build . --config Release -j "%NUMBER_OF_PROCESSORS%" | |
- name: Pack artifacts | |
id: pack_artifacts | |
shell: cmd | |
run: | | |
set PATH=%PATH%;C:\Program Files\7-Zip\ | |
robocopy build_deps\_install\bin\ .\build\Release\ zlib.dll | |
robocopy build\bin\Release\ .\build\Release\ llama.dll | |
dotnet tool install --global AzureSignTool | |
%USERPROFILE%\.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 ".\build\Release\nitro.exe" | |
7z a -ttar temp.tar .\build\Release\* | |
7z a -tgzip nitro.tar.gz temp.tar | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
with: | |
name: nitro-win-amd64-cuda-${{ matrix.cuda }} | |
path: ./build/Release | |
# - name: run e2e testing | |
# shell: cmd | |
# run: | | |
# cd .\build\Release | |
# ..\..\.github\scripts\e2e-test-windows.bat .\nitro.exe ${{ env.MODEL_URL }} | |
- uses: actions/[email protected] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create-draft-release.outputs.upload_url }} | |
asset_path: ./nitro.tar.gz | |
asset_name: nitro-${{ needs.create-draft-release.outputs.version }}-win-amd64-cuda-${{ matrix.cuda }}.tar.gz | |
asset_content_type: application/gzip | |
update_release_draft: | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
needs: | |
[ | |
ubuntu-amd64-build, | |
ubuntu-amd64-cuda-build, | |
macOS-M-build, | |
macOS-Intel-build, | |
windows-amd64-build, | |
windows-amd64-cuda-build, | |
] | |
permissions: | |
contents: write | |
pull-requests: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: release-drafter/release-drafter@v5 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
noti-discord-nightly: | |
if: always() && github.event_name == 'schedule' && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped') && needs.ubuntu-amd64-build.result == 'success' && needs.ubuntu-amd64-cuda-build.result == 'success' && needs.macOS-M-build.result == 'success' && needs.macOS-Intel-build.result == 'success' && needs.windows-amd64-build.result == 'success' && needs.windows-amd64-cuda-build.result == 'success' | |
needs: | |
[ | |
create-draft-release, | |
ubuntu-amd64-build, | |
ubuntu-amd64-cuda-build, | |
macOS-M-build, | |
macOS-Intel-build, | |
windows-amd64-build, | |
windows-amd64-cuda-build, | |
] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: "0" | |
token: ${{ secrets.PAT_SERVICE_ACCOUNT }} | |
- name: Notify Discord | |
uses: Ilshidur/action-discord@master | |
with: | |
args: "Nightly build artifact: https://github.com/janhq/nitro/actions/runs/{{ GITHUB_RUN_ID }}" | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
- name: Update README.md with artifact URL | |
run: | | |
sed -i "s|<a href='https://github.com/janhq/nitro/actions/runs/.*'>|<a href='https://github.com/janhq/nitro/actions/runs/${GITHUB_RUN_ID}'>|" README.md | |
git config --global user.email "[email protected]" | |
git config --global user.name "Service Account" | |
git add README.md | |
git commit -m "${GITHUB_REPOSITORY}: Update README.md with nightly build artifact URL" | |
git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin HEAD:main | |
env: | |
GITHUB_RUN_ID: ${{ github.run_id }} | |
noti-discord-manual: | |
if: always() && github.event_name == 'workflow_dispatch' && (needs.create-draft-release.result == 'success' || needs.create-draft-release.result == 'skipped') && needs.ubuntu-amd64-build.result == 'success' && needs.ubuntu-amd64-cuda-build.result == 'success' && needs.macOS-M-build.result == 'success' && needs.macOS-Intel-build.result == 'success' && needs.windows-amd64-build.result == 'success' && needs.windows-amd64-cuda-build.result == 'success' | |
needs: | |
[ | |
create-draft-release, | |
ubuntu-amd64-build, | |
ubuntu-amd64-cuda-build, | |
macOS-M-build, | |
macOS-Intel-build, | |
windows-amd64-build, | |
windows-amd64-cuda-build, | |
] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: "0" | |
token: ${{ secrets.PAT_SERVICE_ACCOUNT }} | |
- name: Notify Discord | |
uses: Ilshidur/action-discord@master | |
with: | |
args: "Manual build artifact: https://github.com/janhq/nitro/actions/runs/{{ GITHUB_RUN_ID }}" | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
# Update README.md with artifact URL if manual build from main branch | |
- name: Update README.md with artifact URL | |
if: github.ref == 'refs/heads/main' | |
run: | | |
sed -i "s|<a href='https://github.com/janhq/nitro/actions/runs/.*'>|<a href='https://github.com/janhq/nitro/actions/runs/${GITHUB_RUN_ID}'>|" README.md | |
git config --global user.email "[email protected]" | |
git config --global user.name "Service Account" | |
git add README.md | |
git commit -m "${GITHUB_REPOSITORY}: Update README.md with nightly build artifact URL" | |
git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin HEAD:main | |
env: | |
GITHUB_RUN_ID: ${{ github.run_id }} |