diff --git a/.github/workflows/beta-build.yml b/.github/workflows/beta-build.yml index 010ca31b2..928e76db0 100644 --- a/.github/workflows/beta-build.yml +++ b/.github/workflows/beta-build.yml @@ -9,6 +9,9 @@ jobs: get-update-version: uses: ./.github/workflows/template-get-update-version.yml + get-cortex-llamacpp-latest-version: + uses: ./.github/workflows/template-cortex-llamacpp-latest-version.yml + create-draft-release: runs-on: ubuntu-latest if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') @@ -35,7 +38,7 @@ jobs: build-macos-x64: uses: ./.github/workflows/template-build-macos.yml - needs: [get-update-version, create-draft-release] + needs: [get-update-version, create-draft-release, get-cortex-llamacpp-latest-version] secrets: inherit with: ref: ${{ github.ref }} @@ -49,7 +52,7 @@ jobs: build-macos-arm64: uses: ./.github/workflows/template-build-macos.yml - needs: [get-update-version, create-draft-release] + needs: [get-update-version, create-draft-release, get-cortex-llamacpp-latest-version] secrets: inherit with: ref: ${{ github.ref }} @@ -64,7 +67,7 @@ jobs: build-windows-x64: uses: ./.github/workflows/template-build-windows-x64.yml secrets: inherit - needs: [get-update-version, create-draft-release] + needs: [get-update-version, create-draft-release, get-cortex-llamacpp-latest-version] with: ref: ${{ github.ref }} public_provider: github @@ -75,11 +78,12 @@ jobs: ccache-dir: 'C:\Users\ContainerAdministrator\AppData\Local\ccache' 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 }} build-linux-x64: uses: ./.github/workflows/template-build-linux-x64.yml secrets: inherit - needs: [get-update-version, create-draft-release] + needs: [get-update-version, create-draft-release, get-cortex-llamacpp-latest-version] with: ref: ${{ github.ref }} public_provider: github diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml index e0b659f93..85ce2c27a 100644 --- a/.github/workflows/nightly-build.yml +++ b/.github/workflows/nightly-build.yml @@ -43,9 +43,12 @@ jobs: get-update-version: uses: ./.github/workflows/template-get-update-version.yml + get-cortex-llamacpp-latest-version: + uses: ./.github/workflows/template-cortex-llamacpp-latest-version.yml + build-macos-x64: uses: ./.github/workflows/template-build-macos.yml - needs: [get-update-version, set-public-provider] + needs: [get-update-version, set-public-provider, get-cortex-llamacpp-latest-version] secrets: inherit with: ref: ${{ needs.set-public-provider.outputs.ref }} @@ -58,7 +61,7 @@ jobs: build-macos-arm64: uses: ./.github/workflows/template-build-macos.yml - needs: [get-update-version, set-public-provider] + needs: [get-update-version, set-public-provider, get-cortex-llamacpp-latest-version] secrets: inherit with: ref: ${{ needs.set-public-provider.outputs.ref }} @@ -72,7 +75,7 @@ jobs: build-windows-x64: uses: ./.github/workflows/template-build-windows-x64.yml secrets: inherit - needs: [get-update-version, set-public-provider] + needs: [get-update-version, set-public-provider, get-cortex-llamacpp-latest-version] with: ref: ${{ needs.set-public-provider.outputs.ref }} public_provider: ${{ needs.set-public-provider.outputs.public_provider }} @@ -82,11 +85,12 @@ jobs: build-deps-cmake-flags: "-DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache -GNinja" ccache-dir: 'C:\Users\ContainerAdministrator\AppData\Local\ccache' channel: nightly + cortex-llamacpp-version: ${{ needs.get-cortex-llamacpp-latest-version.outputs.cortex_llamacpp_latest_version }} build-linux-x64: uses: ./.github/workflows/template-build-linux-x64.yml secrets: inherit - needs: [get-update-version, set-public-provider] + needs: [get-update-version, set-public-provider, get-cortex-llamacpp-latest-version] with: ref: ${{ needs.set-public-provider.outputs.ref }} public_provider: ${{ needs.set-public-provider.outputs.public_provider }} @@ -98,7 +102,7 @@ jobs: update-latest-version: runs-on: ubuntu-latest if: needs.set-public-provider.outputs.public_provider == 'aws-s3' - needs: [get-update-version, set-public-provider, build-linux-x64, build-macos-x64, build-macos-arm64, build-windows-x64] + needs: [get-update-version, set-public-provider, build-linux-x64, build-macos-x64, build-macos-arm64, build-windows-x64, get-cortex-llamacpp-latest-version] steps: - name: Update latest version id: update-latest-version @@ -117,7 +121,7 @@ jobs: AWS_EC2_METADATA_DISABLED: "true" noti-discord-nightly-and-update-url-readme: - needs: [build-macos-x64, build-macos-arm64, build-windows-x64, build-linux-x64, get-update-version, set-public-provider] + needs: [build-macos-x64, build-macos-arm64, build-windows-x64, build-linux-x64, get-update-version, set-public-provider, get-cortex-llamacpp-latest-version] secrets: inherit if: github.event_name == 'schedule' uses: ./.github/workflows/template-noti-discord.yaml @@ -126,7 +130,7 @@ jobs: new_version: ${{ needs.get-update-version.outputs.new_version }} noti-discord-manual: - needs: [build-macos-x64, build-macos-arm64, build-windows-x64, build-linux-x64, get-update-version, set-public-provider] + needs: [build-macos-x64, build-macos-arm64, build-windows-x64, build-linux-x64, get-update-version, set-public-provider, get-cortex-llamacpp-latest-version] secrets: inherit if: github.event_name == 'workflow_dispatch' && github.event.inputs.public_provider == 'aws-s3' uses: ./.github/workflows/template-noti-discord.yaml diff --git a/.github/workflows/stable-build.yml b/.github/workflows/stable-build.yml index 42bed1dd6..a54f6ad41 100644 --- a/.github/workflows/stable-build.yml +++ b/.github/workflows/stable-build.yml @@ -9,6 +9,9 @@ jobs: get-update-version: uses: ./.github/workflows/template-get-update-version.yml + get-cortex-llamacpp-latest-version: + uses: ./.github/workflows/template-cortex-llamacpp-latest-version.yml + create-draft-release: runs-on: ubuntu-latest if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') @@ -35,7 +38,7 @@ jobs: build-macos-x64: uses: ./.github/workflows/template-build-macos.yml - needs: [get-update-version, create-draft-release] + needs: [get-update-version, create-draft-release, get-cortex-llamacpp-latest-version] secrets: inherit with: ref: ${{ github.ref }} @@ -49,7 +52,7 @@ jobs: build-macos-arm64: uses: ./.github/workflows/template-build-macos.yml - needs: [get-update-version, create-draft-release] + needs: [get-update-version, create-draft-release, get-cortex-llamacpp-latest-version] secrets: inherit with: ref: ${{ github.ref }} @@ -64,7 +67,7 @@ jobs: build-windows-x64: uses: ./.github/workflows/template-build-windows-x64.yml secrets: inherit - needs: [get-update-version, create-draft-release] + needs: [get-update-version, create-draft-release, get-cortex-llamacpp-latest-version] with: ref: ${{ github.ref }} public_provider: github @@ -75,11 +78,12 @@ jobs: ccache-dir: 'C:\Users\ContainerAdministrator\AppData\Local\ccache' 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 }} build-linux-x64: uses: ./.github/workflows/template-build-linux-x64.yml secrets: inherit - needs: [get-update-version, create-draft-release] + needs: [get-update-version, create-draft-release, get-cortex-llamacpp-latest-version] with: ref: ${{ github.ref }} public_provider: github diff --git a/.github/workflows/template-build-windows-x64.yml b/.github/workflows/template-build-windows-x64.yml index 872c46d48..73f3ccb0e 100644 --- a/.github/workflows/template-build-windows-x64.yml +++ b/.github/workflows/template-build-windows-x64.yml @@ -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,6 +131,7 @@ 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 @@ -131,7 +139,7 @@ jobs: - 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/inno-setup-action-cli@v6.0.5 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/inno-setup-action-cli@v6.0.5 + 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/upload-release-asset@v1.0.1 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/upload-release-asset@v1.0.1 + 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 \ No newline at end of file diff --git a/.github/workflows/template-cortex-llamacpp-latest-version.yml b/.github/workflows/template-cortex-llamacpp-latest-version.yml new file mode 100644 index 000000000..5135c55ab --- /dev/null +++ b/.github/workflows/template-cortex-llamacpp-latest-version.yml @@ -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" \ No newline at end of file diff --git a/.github/workflows/template-get-update-version.yml b/.github/workflows/template-get-update-version.yml index 9d853c7d3..7b715a6e0 100644 --- a/.github/workflows/template-get-update-version.yml +++ b/.github/workflows/template-get-update-version.yml @@ -9,7 +9,6 @@ on: jobs: get-update-version: runs-on: ubuntu-latest - environment: production outputs: new_version: ${{ steps.version_update.outputs.new_version }} steps: diff --git a/.github/workflows/template-noti-discord.yaml b/.github/workflows/template-noti-discord.yaml index bbf56aee4..f86cf7bd0 100644 --- a/.github/workflows/template-noti-discord.yaml +++ b/.github/workflows/template-noti-discord.yaml @@ -13,7 +13,6 @@ on: jobs: noti-discord: - environment: production runs-on: ubuntu-latest permissions: contents: write @@ -27,7 +26,9 @@ jobs: with: args: | Cortex.cpp ${{ inputs.build_reason }} build artifact version {{ VERSION }}: - - Windows: https://delta.jan.ai/cortex/v{{ VERSION }}/windows-amd64/cortex-{{ VERSION }}-windows-amd64-installer.exe + - Windows: + - Network Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/windows-amd64/cortex-{{ VERSION }}-windows-amd64-network-installer.exe + - 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 diff --git a/engine/templates/windows/local-installer-beta.iss b/engine/templates/windows/local-installer-beta.iss new file mode 100644 index 000000000..39f66d486 --- /dev/null +++ b/engine/templates/windows/local-installer-beta.iss @@ -0,0 +1,108 @@ +; Define the application name, version, and other details +[Setup] +AppName=cortexcpp-beta +AppVersion=1.0 +DefaultDirName={localappdata}\cortexcpp-beta +DefaultGroupName=cortexcpp-beta +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-beta.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-beta"; Filename: "{app}\cortex-beta.exe" + +; Define the uninstall run section to execute commands before uninstallation +[UninstallRun] +Filename: "{app}\cortex-beta.exe"; Parameters: "stop"; StatusMsg: "Stopping cortexcpp-beta 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-beta.exe" engines install cortex.llamacpp -s "%s"', [ExpandedAppDir, TempFolder]); + Exec('powershell.exe', '-Command ' + CortexInstallCmd, '', 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-beta'); + UserCortexConfig := ExpandConstant('{%USERPROFILE}\.cortexrc-beta'); + + if DirExists(UserCortexFolder) or FileExists(UserCortexConfig) then + begin + ShouldDelete := MsgBox('Do you want to delete the application data in cortexcpp-beta and the .cortexrc-beta 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; diff --git a/engine/templates/windows/local-installer-nightly.iss b/engine/templates/windows/local-installer-nightly.iss new file mode 100644 index 000000000..3cf9a56f1 --- /dev/null +++ b/engine/templates/windows/local-installer-nightly.iss @@ -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, '', 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; diff --git a/engine/templates/windows/local-installer.iss b/engine/templates/windows/local-installer.iss new file mode 100644 index 000000000..86a9cf280 --- /dev/null +++ b/engine/templates/windows/local-installer.iss @@ -0,0 +1,108 @@ +; Define the application name, version, and other details +[Setup] +AppName=cortexcpp +AppVersion=1.0 +DefaultDirName={localappdata}\cortexcpp +DefaultGroupName=cortexcpp +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.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"; Filename: "{app}\cortex.exe" + +; Define the uninstall run section to execute commands before uninstallation +[UninstallRun] +Filename: "{app}\cortex.exe"; Parameters: "stop"; StatusMsg: "Stopping cortexcpp 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.exe" engines install cortex.llamacpp -s "%s"', [ExpandedAppDir, TempFolder]); + Exec('powershell.exe', '-Command ' + CortexInstallCmd, '', 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'); + UserCortexConfig := ExpandConstant('{%USERPROFILE}\.cortexrc'); + + if DirExists(UserCortexFolder) or FileExists(UserCortexConfig) then + begin + ShouldDelete := MsgBox('Do you want to delete the application data in cortexcpp and the .cortexrc 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;