-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9707a3b
commit 868b298
Showing
4 changed files
with
237 additions
and
17 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
MINIO_BUCKET_NAME: | ||
required: false | ||
|
@@ -104,6 +109,7 @@ jobs: | |
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" | ||
echo "::set-output name=local_iss_file_name::local-installer.iss" | ||
fi | ||
# Set output for beta channel | ||
|
@@ -114,6 +120,7 @@ jobs: | |
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" | ||
echo "::set-output name=local_iss_file_name::local-installer-beta.iss" | ||
fi | ||
# Set output for nightly channel | ||
|
@@ -124,14 +131,15 @@ jobs: | |
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" | ||
echo "::set-output name=local_iss_file_name::local-installer-nightly.iss" | ||
fi | ||
- name: Install jq | ||
uses: dcarbone/[email protected] | ||
|
||
- name: Install dependencies on Windows | ||
run: | | ||
choco install make pkgconfiglite ccache awscli 7zip ninja -y | ||
choco install make pkgconfiglite ccache awscli 7zip ninja wget -y | ||
dotnet tool install --global AzureSignTool | ||
- name: Download ccache from s3 | ||
|
@@ -171,30 +179,65 @@ jobs: | |
run: | | ||
cd engine/templates/windows | ||
sed -i "s/AppVersion=1.0/AppVersion=${{ inputs.new_version }}/g" ${{ steps.set-output-params.outputs.iss_file_name }} | ||
sed -i "s/AppVersion=1.0/AppVersion=${{ inputs.new_version }}/g" ${{ steps.set-output-params.outputs.local_iss_file_name }} | ||
cat ${{ steps.set-output-params.outputs.iss_file_name }} | ||
cp ${{ steps.set-output-params.outputs.iss_file_name }} ../../../ | ||
cp ${{ steps.set-output-params.outputs.local_iss_file_name }} ../../../ | ||
ls ../../../ | ||
- name: Build Installers | ||
- name: Build network Installers | ||
shell: bash | ||
run: | | ||
cd engine | ||
make build-installer PACKAGE_NAME=${{ steps.set-output-params.outputs.package_name }} VERSION=${{ inputs.new_version }} DESTINATION_BINARY_NAME="${{ steps.set-output-params.outputs.destination_binary_name }}" | ||
ls ../ | ||
- name: Build local Installers | ||
shell: powershell | ||
run: | | ||
mkdir dependencies | ||
cd dependencies | ||
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-avx-cuda-11-7.tar.gz | ||
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-avx-cuda-12-0.tar.gz | ||
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-avx.tar.gz | ||
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-avx2-cuda-11-7.tar.gz | ||
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-avx2-cuda-12-0.tar.gz | ||
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-avx2.tar.gz | ||
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-avx512-cuda-11-7.tar.gz | ||
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-avx512-cuda-12-0.tar.gz | ||
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-avx512.tar.gz | ||
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-noavx-cuda-11-7.tar.gz | ||
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-noavx-cuda-12-0.tar.gz | ||
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-noavx.tar.gz | ||
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-windows-amd64-vulkan.tar.gz | ||
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cuda-11-7-windows-amd64.tar.gz | ||
wget.exe https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cuda-12-0-windows-amd64.tar.gz | ||
- name: Enable long paths | ||
run: | | ||
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem" /v LongPathsEnabled /t REG_DWORD /d 1 /f | ||
- name: Compile .ISS to .EXE Installer | ||
- name: Compile .ISS to .EXE network Installer | ||
uses: nadeemjazmawe/[email protected] | ||
with: | ||
filepath: ./${{ steps.set-output-params.outputs.iss_file_name }} | ||
|
||
- name: Codesign for windows installer | ||
- name: Codesign for windows network installer | ||
shell: pwsh | ||
run: | | ||
~\.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 ".\setup.exe" | ||
mv .\setup.exe .\network-setup.exe | ||
- name: Compile .ISS to .EXE local Installer | ||
uses: nadeemjazmawe/[email protected] | ||
with: | ||
filepath: ./${{ steps.set-output-params.outputs.local_iss_file_name }} | ||
|
||
- name: Codesign for windows network installer | ||
shell: pwsh | ||
run: | | ||
~\.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 ".\setup.exe" | ||
mv .\setup.exe .\local-setup.exe | ||
- name: Package | ||
run: | | ||
|
@@ -207,11 +250,17 @@ jobs: | |
name: cortex-${{ inputs.new_version }}-windows-amd64 | ||
path: ./engine/cortex | ||
|
||
- name: Upload Artifact | ||
- name: Upload Artifact network installer | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: cortex-${{ inputs.new_version }}-windows-amd64-installer | ||
path: ./setup.exe | ||
name: cortex-${{ inputs.new_version }}-windows-amd64-network-installer | ||
path: ./network-setup.exe | ||
|
||
- name: Upload Artifact local installer | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: cortex-${{ inputs.new_version }}-windows-amd64-local-installer | ||
path: ./local-setup.exe | ||
|
||
- name: upload to aws s3 if public provider is aws | ||
if: inputs.public_provider == 'aws-s3' | ||
|
@@ -221,7 +270,8 @@ jobs: | |
aws s3 cp ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/windows-amd64-cortex-nightly.tar.gz | ||
aws s3 cp ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/windows-amd64/cortex-nightly.tar.gz | ||
aws s3 cp ./setup.exe s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/windows-amd64/cortex-${{ inputs.new_version }}-windows-amd64-installer.exe | ||
aws s3 cp ./network-setup.exe s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/windows-amd64/cortex-${{ inputs.new_version }}-windows-amd64-network-installer.exe | ||
aws s3 cp ./local-setup.exe s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/windows-amd64/cortex-${{ inputs.new_version }}-windows-amd64-local-installer.exe | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }} | ||
|
@@ -246,6 +296,17 @@ jobs: | |
uses: actions/[email protected] | ||
with: | ||
upload_url: ${{ inputs.upload_url }} | ||
asset_path: ./setup.exe | ||
asset_name: cortex-${{ inputs.new_version }}-windows-amd64-installer.exe | ||
asset_path: ./network-setup.exe | ||
asset_name: cortex-${{ inputs.new_version }}-windows-amd64-network-installer.exe | ||
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: ./local-setup.exe | ||
asset_name: cortex-${{ inputs.new_version }}-windows-amd64-local-installer.exe | ||
asset_content_type: application/octet-stream |
47 changes: 47 additions & 0 deletions
47
.github/workflows/template-cortex-llamacpp-latest-version.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: get-cortex-llamacpp-latest-version | ||
on: | ||
workflow_call: | ||
outputs: | ||
cortex_llamacpp_latest_version: | ||
description: 'The latest version of cortex.llamacpp engines' | ||
value: ${{ jobs.get-cortex-llamacpp-latest-version.outputs.new_version }} | ||
|
||
jobs: | ||
get-cortex-llamacpp-latest-version: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
new_version: ${{ steps.version_update.outputs.new_version }} | ||
steps: | ||
- name: Install jq | ||
uses: dcarbone/[email protected] | ||
|
||
- name: Update app version based on latest release tag with build number | ||
id: version_update | ||
run: | | ||
# 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/cortex.llamacpp/releases/latest | jq -r .tag_name) | ||
if [ -n "$tag" ] && [ "$tag" != "null" ]; then | ||
echo $tag | ||
return | ||
else | ||
let retries++ | ||
echo "Retrying... ($retries/$max_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}" | ||
echo "New version: $new_version" | ||
echo "::set-output name=new_version::$new_version" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
; Define the application name, version, and other details | ||
[Setup] | ||
AppName=cortexcpp-nightly | ||
AppVersion=1.0 | ||
DefaultDirName={localappdata}\cortexcpp-nightly | ||
DefaultGroupName=cortexcpp-nightly | ||
OutputDir=. | ||
OutputBaseFilename=setup | ||
Compression=lzma | ||
SolidCompression=yes | ||
PrivilegesRequired=lowest | ||
AllowNoIcons=yes | ||
|
||
; Define the languages section | ||
[Languages] | ||
Name: "english"; MessagesFile: "compiler:Default.isl" | ||
|
||
; Define the files to be installed | ||
[Files] | ||
Source: "cortex-nightly.exe"; DestDir: "{app}"; Flags: ignoreversion | ||
Source: "msvcp140.dll"; DestDir: "{app}"; Flags: ignoreversion | ||
Source: "vcruntime140.dll"; DestDir: "{app}"; Flags: ignoreversion | ||
Source: "vcruntime140_1.dll"; DestDir: "{app}"; Flags: ignoreversion | ||
Source: "dependencies\*"; DestDir: "{tmp}\dependencies"; Flags: ignoreversion recursesubdirs | ||
|
||
; Define the icons to be created | ||
[Icons] | ||
Name: "{group}\cortexcpp-nightly"; Filename: "{app}\cortex-nightly.exe" | ||
|
||
; Define the uninstall run section to execute commands before uninstallation | ||
[UninstallRun] | ||
Filename: "{app}\cortex-nightly.exe"; Parameters: "stop"; StatusMsg: "Stopping cortexcpp-nightly service..."; Flags: runhidden | ||
|
||
; Combine all Pascal scripting code in one [Code] section | ||
[Code] | ||
procedure AddToUserPathAndInstallEngines; | ||
var | ||
ExpandedAppDir: String; | ||
TempFolder: String; | ||
CmdLine, CortexInstallCmd: String; | ||
ResultCode: Integer; | ||
begin | ||
ExpandedAppDir := ExpandConstant('{app}'); | ||
TempFolder := ExpandConstant('{tmp}\dependencies'); // Path to the extracted dependencies folder | ||
// Add {app} to PATH | ||
CmdLine := Format('setx PATH "%s;%%PATH%%"', [ExpandedAppDir]); | ||
Exec('cmd.exe', '/C ' + CmdLine, '', SW_HIDE, ewWaitUntilTerminated, ResultCode); | ||
// Update status message for installing engines | ||
WizardForm.StatusLabel.Caption := 'Installing engines from offline package...'; | ||
WizardForm.StatusLabel.Update; | ||
// Run the installation command with the -s option pointing to TempFolder | ||
CortexInstallCmd := Format('"%s\cortex-nightly.exe" engines install cortex.llamacpp -s "%s"', [ExpandedAppDir, TempFolder]); | ||
Exec('powershell.exe', '-Command ' + CortexInstallCmd + ' > "' + ExpandConstant('{app}\install_log.txt') + '" 2>&1', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); | ||
// Clear the status message after completion | ||
WizardForm.StatusLabel.Caption := ''; | ||
WizardForm.StatusLabel.Update; | ||
// Remove the temp folder after the installation is complete | ||
DelTree(ExpandConstant('{tmp}\dependencies'), True, True, True); | ||
end; | ||
procedure DeleteCurrentUserCortexFolderAndConfig; | ||
var | ||
UserCortexFolder: String; | ||
UserCortexConfig: String; | ||
ShouldDelete: Integer; | ||
begin | ||
UserCortexFolder := ExpandConstant('{%USERPROFILE}\cortexcpp-nightly'); | ||
UserCortexConfig := ExpandConstant('{%USERPROFILE}\.cortexrc-nightly'); | ||
if DirExists(UserCortexFolder) or FileExists(UserCortexConfig) then | ||
begin | ||
ShouldDelete := MsgBox('Do you want to delete the application data in cortexcpp-nightly and the .cortexrc-nightly config file (this will remove all user data)?', mbConfirmation, MB_YESNO); | ||
if ShouldDelete = idYes then | ||
begin | ||
if DirExists(UserCortexFolder) then | ||
begin | ||
DelTree(UserCortexFolder, True, True, True); | ||
end; | ||
if FileExists(UserCortexConfig) then | ||
begin | ||
DeleteFile(UserCortexConfig); | ||
end; | ||
end; | ||
end; | ||
end; | ||
procedure CurStepChanged(CurStep: TSetupStep); | ||
begin | ||
if CurStep = ssPostInstall then | ||
begin | ||
AddToUserPathAndInstallEngines; | ||
end; | ||
end; | ||
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); | ||
begin | ||
if CurUninstallStep = usPostUninstall then | ||
begin | ||
DeleteCurrentUserCortexFolderAndConfig; | ||
end; | ||
end; |