-
Notifications
You must be signed in to change notification settings - Fork 130
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
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/install-jq-action@v2.0.1 | ||
|
||
- 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; |