Skip to content

Commit

Permalink
Linux add local installer
Browse files Browse the repository at this point in the history
  • Loading branch information
hientominh authored and hiento09 committed Sep 25, 2024
1 parent 1d1104e commit b67e373
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/beta-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:
cmake-flags: "-DCORTEX_VARIANT=beta -DCORTEX_CPP_VERSION='v${{ needs.get-update-version.outputs.new_version }}' -DCMAKE_TOOLCHAIN_FILE=/home/runner/actions-runner/_work/cortex.cpp/cortex.cpp/engine/vcpkg/scripts/buildsystems/vcpkg.cmake"
channel: beta
upload_url: ${{ needs.create-draft-release.outputs.upload_url }}
cortex-llamacpp-version: ${{ needs.get-cortex-llamacpp-latest-version.outputs.cortex_llamacpp_latest_version }}

update_release_draft:
needs: [build-macos-x64, build-macos-arm64, build-windows-x64, build-linux-x64]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ jobs:
runs-on: ubuntu-20-04
cmake-flags: "-DCORTEX_VARIANT=nightly -DCORTEX_CPP_VERSION='v${{ needs.get-update-version.outputs.new_version }}' -DCMAKE_TOOLCHAIN_FILE=/home/runner/actions-runner/_work/cortex.cpp/cortex.cpp/engine/vcpkg/scripts/buildsystems/vcpkg.cmake"
channel: nightly
cortex-llamacpp-version: ${{ needs.get-cortex-llamacpp-latest-version.outputs.cortex_llamacpp_latest_version }}

update-latest-version:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/stable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:
cmake-flags: "-DCORTEX_VARIANT=prod -DCORTEX_CPP_VERSION='v${{ needs.get-update-version.outputs.new_version }}' -DCMAKE_TOOLCHAIN_FILE=/home/runner/actions-runner/_work/cortex.cpp/cortex.cpp/engine/vcpkg/scripts/buildsystems/vcpkg.cmake"
channel: stable
upload_url: ${{ needs.create-draft-release.outputs.upload_url }}
cortex-llamacpp-version: ${{ needs.get-cortex-llamacpp-latest-version.outputs.cortex_llamacpp_latest_version }}

update_release_draft:
needs: [build-macos-x64, build-macos-arm64, build-windows-x64, build-linux-x64]
Expand Down
65 changes: 59 additions & 6 deletions .github/workflows/template-build-linux-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ on:
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:
DELTA_AWS_S3_BUCKET_NAME:
required: false
Expand Down Expand Up @@ -128,11 +133,41 @@ jobs:
cd engine
make pre-package DESTINATION_BINARY_NAME="${{ steps.set-output-params.outputs.destination_binary_name }}"
- name: Build Installers
- 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 }}" VERSION=${{ inputs.new_version }} DESTINATION_BINARY_NAME="${{ steps.set-output-params.outputs.destination_binary_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 }}"
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
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
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 }} ${{ steps.set-output-params.outputs.destination_binary_name }} ${{ steps.set-output-params.outputs.data_folder_name }} ${{ steps.set-output-params.outputs.configuration_file_name }};
cp ${{ steps.set-output-params.outputs.package_name }}.deb ../../${{ steps.set-output-params.outputs.package_name }}-local.deb
- name: Package
run: |
Expand All @@ -148,16 +183,23 @@ jobs:
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: cortex-${{ inputs.new_version }}-linux-amd64-installer
path: ./engine/${{ steps.set-output-params.outputs.package_name }}.deb
name: cortex-${{ inputs.new_version }}-linux-amd64-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-amd64-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-amd64-cortex-nightly.tar.gz
aws s3 cp ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/linux-amd64/cortex-nightly.tar.gz
aws s3 cp ./engine/${{ steps.set-output-params.outputs.package_name }}.deb s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/linux-amd64/cortex-${{ inputs.new_version }}-linux-amd64-installer.deb
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-amd64/cortex-${{ inputs.new_version }}-linux-amd64-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-amd64/cortex-${{ inputs.new_version }}-linux-amd64-local-installer.deb
env:
AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }}
Expand All @@ -182,6 +224,17 @@ jobs:
uses: actions/[email protected]
with:
upload_url: ${{ inputs.upload_url }}
asset_path: ./engine/${{ steps.set-output-params.outputs.package_name }}.deb
asset_name: cortex-${{ inputs.new_version }}-linux-amd64-installer.deb
asset_path: ./engine/${{ steps.set-output-params.outputs.package_name }}-network.deb
asset_name: cortex-${{ inputs.new_version }}-linux-amd64-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-amd64-local-installer.deb
asset_content_type: application/octet-stream
4 changes: 3 additions & 1 deletion .github/workflows/template-noti-discord.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ jobs:
- Local Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/windows-amd64/cortex-{{ VERSION }}-windows-amd64-local-installer.exe
- macOS Intel: https://delta.jan.ai/cortex/v{{ VERSION }}/mac-amd64/cortex-{{ VERSION }}-mac-amd64-installer.pkg
- macOS Apple Silicon: https://delta.jan.ai/cortex/v{{ VERSION }}/mac-arm64/cortex-{{ VERSION }}-mac-arm64-installer.pkg
- Linux Deb: https://delta.jan.ai/cortex/v{{ VERSION }}/linux-amd64/cortex-{{ VERSION }}-linux-amd64-installer.deb
- Linux Deb:
- Network Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/linux-amd64/cortex-{{ VERSION }}-linux-amd64-network-installer.deb
- Local Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/linux-amd64/cortex-{{ VERSION }}-linux-amd64-local-installer.deb
- Github action run: https://github.com/janhq/cortex.cpp/actions/runs/{{ GITHUB_RUN_ID }}
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
38 changes: 38 additions & 0 deletions engine/templates/linux/create_deb_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
PACKAGE_NAME=$1
VERSION=$2
SOURCE_BINARY_PATH=$3
DESTINATION_BINARY_NAME=$4
DATA_FOLDER_NAME=$5
CONFIGURATION_FILE_NAME=$6

mkdir -p $PACKAGE_NAME/DEBIAN

mkdir -p $PACKAGE_NAME/usr/bin
cp $SOURCE_BINARY_PATH $PACKAGE_NAME/usr/bin/$DESTINATION_BINARY_NAME

mkdir -p $PACKAGE_NAME/tmp/$DESTINATION_BINARY_NAME-dependencies
cp dependencies/* $PACKAGE_NAME/tmp/$DESTINATION_BINARY_NAME-dependencies

export DESTINATION_BINARY_NAME

cp postinst_local $PACKAGE_NAME/DEBIAN/postinst
sed -i "2s/.*/DESTINATION_BINARY_NAME=$DESTINATION_BINARY_NAME/" $PACKAGE_NAME/DEBIAN/postinst

cp prerm $PACKAGE_NAME/DEBIAN/prerm
sed -i "3s/.*/DESTINATION_BINARY_NAME=$DESTINATION_BINARY_NAME/" $PACKAGE_NAME/DEBIAN/prerm

export DATA_FOLDER_NAME CONFIGURATION_FILE_NAME

cp postrm $PACKAGE_NAME/DEBIAN/postrm
sed -i "3s/.*/DATA_FOLDER_NAME=$DATA_FOLDER_NAME/" $PACKAGE_NAME/DEBIAN/postrm
sed -i "4s/.*/CONFIGURATION_FILE_NAME=$CONFIGURATION_FILE_NAME/" $PACKAGE_NAME/DEBIAN/postrm

chmod 755 $PACKAGE_NAME/DEBIAN/postinst
chmod 755 $PACKAGE_NAME/DEBIAN/postrm
chmod 755 $PACKAGE_NAME/DEBIAN/prerm

export PACKAGE_NAME VERSION

envsubst < control > $PACKAGE_NAME/DEBIAN/control

dpkg-deb --build $PACKAGE_NAME $PACKAGE_NAME.deb
6 changes: 6 additions & 0 deletions engine/templates/linux/postinst_local
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
DESTINATION_BINARY_NAME=cortex
USER_TO_RUN_AS=${SUDO_USER:-$(whoami)}
echo "Download cortex.llamacpp engines by default for user $USER_TO_RUN_AS"
sudo -u $USER_TO_RUN_AS /usr/bin/$DESTINATION_BINARY_NAME --verbose engines install cortex.llamacpp -s /tmp/$DESTINATION_BINARY_NAME-dependencies
rm -rf /tmp/$DESTINATION_BINARY_NAME-dependencies

0 comments on commit b67e373

Please sign in to comment.