Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit c9a44ae

Browse files
authored
Macos add local installer (#1335)
Co-authored-by: Hien To <tominhhien97@gmail.com>
1 parent 2fb7a92 commit c9a44ae

File tree

7 files changed

+114
-11
lines changed

7 files changed

+114
-11
lines changed

.github/workflows/beta-build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ jobs:
4949
channel: beta
5050
arch: amd64
5151
upload_url: ${{ needs.create-draft-release.outputs.upload_url }}
52+
cortex-llamacpp-version: ${{ needs.get-cortex-llamacpp-latest-version.outputs.cortex_llamacpp_latest_version }}
5253

5354
build-macos-arm64:
5455
uses: ./.github/workflows/template-build-macos.yml
@@ -63,6 +64,7 @@ jobs:
6364
channel: beta
6465
arch: arm64
6566
upload_url: ${{ needs.create-draft-release.outputs.upload_url }}
67+
cortex-llamacpp-version: ${{ needs.get-cortex-llamacpp-latest-version.outputs.cortex_llamacpp_latest_version }}
6668

6769
build-windows-x64:
6870
uses: ./.github/workflows/template-build-windows-x64.yml

.github/workflows/nightly-build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jobs:
5858
cmake-flags: "-DCORTEX_VARIANT=nightly -DCORTEX_CPP_VERSION='v${{ needs.get-update-version.outputs.new_version }}' -DCMAKE_TOOLCHAIN_FILE=/Users/runner/work/cortex.cpp/cortex.cpp/engine/vcpkg/scripts/buildsystems/vcpkg.cmake"
5959
channel: nightly
6060
arch: amd64
61+
cortex-llamacpp-version: ${{ needs.get-cortex-llamacpp-latest-version.outputs.cortex_llamacpp_latest_version }}
6162

6263
build-macos-arm64:
6364
uses: ./.github/workflows/template-build-macos.yml
@@ -71,6 +72,7 @@ jobs:
7172
cmake-flags: "-DCORTEX_VARIANT=nightly -DCORTEX_CPP_VERSION='v${{ needs.get-update-version.outputs.new_version }}' -DMAC_ARM64=ON -DCMAKE_TOOLCHAIN_FILE=/Users/runner/work/cortex.cpp/cortex.cpp/engine/vcpkg/scripts/buildsystems/vcpkg.cmake"
7273
channel: nightly
7374
arch: arm64
75+
cortex-llamacpp-version: ${{ needs.get-cortex-llamacpp-latest-version.outputs.cortex_llamacpp_latest_version }}
7476

7577
build-windows-x64:
7678
uses: ./.github/workflows/template-build-windows-x64.yml

.github/workflows/stable-build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ jobs:
4949
channel: stable
5050
arch: amd64
5151
upload_url: ${{ needs.create-draft-release.outputs.upload_url }}
52+
cortex-llamacpp-version: ${{ needs.get-cortex-llamacpp-latest-version.outputs.cortex_llamacpp_latest_version }}
5253

5354
build-macos-arm64:
5455
uses: ./.github/workflows/template-build-macos.yml
@@ -63,6 +64,7 @@ jobs:
6364
channel: stable
6465
arch: arm64
6566
upload_url: ${{ needs.create-draft-release.outputs.upload_url }}
67+
cortex-llamacpp-version: ${{ needs.get-cortex-llamacpp-latest-version.outputs.cortex_llamacpp_latest_version }}
6668

6769
build-windows-x64:
6870
uses: ./.github/workflows/template-build-windows-x64.yml

.github/workflows/template-build-macos.yml

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ on:
4949
type: string
5050
default: 'arm64'
5151
description: 'The architecture to use for this job'
52+
cortex-llamacpp-version:
53+
required: true
54+
type: string
55+
default: '0.0.0'
56+
description: 'The version of cortex-llamacpp to use for this job'
5257
secrets:
5358
DELTA_AWS_S3_BUCKET_NAME:
5459
required: false
@@ -78,7 +83,7 @@ on:
7883
required: false
7984

8085
jobs:
81-
build-mac-x64:
86+
build-mac:
8287
runs-on: ${{ inputs.runs-on }}
8388
permissions:
8489
contents: write
@@ -169,7 +174,7 @@ jobs:
169174
QUILL_NOTARY_ISSUER: ${{ secrets.NOTARY_ISSUER }}
170175
QUILL_NOTARY_KEY: "/tmp/notary-key.p8"
171176

172-
- name: Build Installers
177+
- name: Build network Installers
173178
shell: bash
174179
run: |
175180
cd engine
@@ -185,8 +190,33 @@ jobs:
185190
productbuild --synthesize --package Distribution.pkg Distribution.xml
186191
sed -i '' 's/require-scripts="false"/require-scripts="true"/' Distribution.xml
187192
cat Distribution.xml
188-
productbuild --distribution Distribution.xml --sign "Developer ID Installer: ${{ secrets.DEVELOPER_ID }}" --package-path . ${{ steps.set-output-params.outputs.package_name }}.pkg
189-
xcrun notarytool submit ${{ steps.set-output-params.outputs.package_name }}.pkg --apple-id ${{ secrets.APPLE_ID }} --password ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} --team-id ${{ secrets.APPLE_TEAM_ID }} --wait
193+
productbuild --distribution Distribution.xml --sign "Developer ID Installer: ${{ secrets.DEVELOPER_ID }}" --package-path . ${{ steps.set-output-params.outputs.package_name }}-network.pkg
194+
xcrun notarytool submit ${{ steps.set-output-params.outputs.package_name }}-network.pkg --apple-id ${{ secrets.APPLE_ID }} --password ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} --team-id ${{ secrets.APPLE_TEAM_ID }} --wait
195+
196+
- name: Build local Installers
197+
shell: bash
198+
run: |
199+
mkdir -p engine/templates/macos/Scripts/dependencies
200+
cd engine/templates/macos/Scripts/dependencies
201+
wget https://github.com/janhq/cortex.llamacpp/releases/download/v${{ inputs.cortex-llamacpp-version }}/cortex.llamacpp-${{ inputs.cortex-llamacpp-version }}-mac-${{ inputs.arch }}.tar.gz
202+
203+
cd ../../
204+
chmod +x create_pkg_local.sh
205+
./create_pkg_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 }} ${{ steps.set-output-params.outputs.uninstaller_file_name }}
206+
cp ${{ steps.set-output-params.outputs.package_name }}.pkg ../../
207+
208+
- name: Codesign and notary for macos installer
209+
run: |
210+
cd engine
211+
productsign --sign "Developer ID Installer: ${{ secrets.DEVELOPER_ID }}" ${{ steps.set-output-params.outputs.package_name }}.pkg ${{ steps.set-output-params.outputs.package_name }}$-signed.pkg
212+
rm ${{ steps.set-output-params.outputs.package_name }}.pkg
213+
mv ${{ steps.set-output-params.outputs.package_name }}$-signed.pkg Distribution.pkg
214+
productbuild --synthesize --package Distribution.pkg Distribution.xml
215+
sed -i '' 's/require-scripts="false"/require-scripts="true"/' Distribution.xml
216+
cat Distribution.xml
217+
productbuild --distribution Distribution.xml --sign "Developer ID Installer: ${{ secrets.DEVELOPER_ID }}" --package-path . ${{ steps.set-output-params.outputs.package_name }}-local.pkg
218+
xcrun notarytool submit ${{ steps.set-output-params.outputs.package_name }}-local.pkg --apple-id ${{ secrets.APPLE_ID }} --password ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} --team-id ${{ secrets.APPLE_TEAM_ID }} --wait
219+
190220

191221
- name: Package
192222
run: |
@@ -202,16 +232,23 @@ jobs:
202232
- name: Upload Artifact
203233
uses: actions/upload-artifact@v4
204234
with:
205-
name: cortex-${{ inputs.new_version }}-mac-${{ inputs.arch}}-installer
206-
path: ./engine/${{ steps.set-output-params.outputs.package_name }}.pkg
235+
name: cortex-${{ inputs.new_version }}-mac-${{ inputs.arch}}-network-installer
236+
path: ./engine/${{ steps.set-output-params.outputs.package_name }}-network.pkg
237+
238+
- name: Upload Artifact
239+
uses: actions/upload-artifact@v4
240+
with:
241+
name: cortex-${{ inputs.new_version }}-mac-${{ inputs.arch}}-local-installer
242+
path: ./engine/${{ steps.set-output-params.outputs.package_name }}-local.pkg
207243

208244
- name: upload to aws s3 if public provider is aws
209245
if: inputs.public_provider == 'aws-s3'
210246
run: |
211247
aws s3 cp ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/temp-latest/mac-${{ inputs.arch}}-cortex-nightly.tar.gz
212248
213249
aws s3 cp ./engine/cortex.tar.gz s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/mac-${{ inputs.arch}}/cortex-nightly.tar.gz
214-
aws s3 cp ./engine/${{ steps.set-output-params.outputs.package_name }}.pkg s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/mac-${{ inputs.arch}}/cortex-${{ inputs.new_version }}-mac-${{ inputs.arch}}-installer.pkg
250+
aws s3 cp ./engine/${{ steps.set-output-params.outputs.package_name }}-network.pkg s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/mac-${{ inputs.arch}}/cortex-${{ inputs.new_version }}-mac-${{ inputs.arch}}-network-installer.pkg
251+
aws s3 cp ./engine/${{ steps.set-output-params.outputs.package_name }}-local.pkg s3://${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}/cortex/v${{ inputs.new_version }}/mac-${{ inputs.arch}}/cortex-${{ inputs.new_version }}-mac-${{ inputs.arch}}-local-installer.pkg
215252
env:
216253
AWS_ACCESS_KEY_ID: ${{ secrets.DELTA_AWS_ACCESS_KEY_ID }}
217254
AWS_SECRET_ACCESS_KEY: ${{ secrets.DELTA_AWS_SECRET_ACCESS_KEY }}
@@ -236,6 +273,17 @@ jobs:
236273
uses: actions/upload-release-asset@v1.0.1
237274
with:
238275
upload_url: ${{ inputs.upload_url }}
239-
asset_path: ./engine/${{ steps.set-output-params.outputs.package_name }}.pkg
240-
asset_name: cortex-${{ inputs.new_version }}-mac-${{ inputs.arch}}-installer.pkg
276+
asset_path: ./engine/${{ steps.set-output-params.outputs.package_name }}-network.pkg
277+
asset_name: cortex-${{ inputs.new_version }}-mac-${{ inputs.arch}}-network-installer.pkg
278+
asset_content_type: application/octet-stream
279+
280+
- name: Upload release assert if public provider is github
281+
if: inputs.public_provider == 'github'
282+
env:
283+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
284+
uses: actions/upload-release-asset@v1.0.1
285+
with:
286+
upload_url: ${{ inputs.upload_url }}
287+
asset_path: ./engine/${{ steps.set-output-params.outputs.package_name }}-local.pkg
288+
asset_name: cortex-${{ inputs.new_version }}-mac-${{ inputs.arch}}-local-installer.pkg
241289
asset_content_type: application/octet-stream

.github/workflows/template-noti-discord.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ jobs:
2929
- Windows:
3030
- Network Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/windows-amd64/cortex-{{ VERSION }}-windows-amd64-network-installer.exe
3131
- Local Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/windows-amd64/cortex-{{ VERSION }}-windows-amd64-local-installer.exe
32-
- macOS Intel: https://delta.jan.ai/cortex/v{{ VERSION }}/mac-amd64/cortex-{{ VERSION }}-mac-amd64-installer.pkg
33-
- macOS Apple Silicon: https://delta.jan.ai/cortex/v{{ VERSION }}/mac-arm64/cortex-{{ VERSION }}-mac-arm64-installer.pkg
32+
- macOS Intel:
33+
- Network Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/mac-amd64/cortex-{{ VERSION }}-mac-amd64-network-installer.pkg
34+
- Local Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/mac-amd64/cortex-{{ VERSION }}-mac-amd64-local-installer.pkg
35+
- macOS Apple Silicon:
36+
- Network Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/mac-arm64/cortex-{{ VERSION }}-mac-arm64-network-installer.pkg
37+
- Local Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/mac-arm64/cortex-{{ VERSION }}-mac-arm64-local-installer.pkg
3438
- Linux Deb:
3539
- Network Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/linux-amd64/cortex-{{ VERSION }}-linux-amd64-network-installer.deb
3640
- Local Installer: https://delta.jan.ai/cortex/v{{ VERSION }}/linux-amd64/cortex-{{ VERSION }}-linux-amd64-local-installer.deb
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
PACKAGE_NAME=$1
2+
VERSION=$2
3+
SOURCE_BINARY_PATH=$3
4+
DESTINATION_BINARY_NAME=$4
5+
DATA_FOLDER_NAME=$5
6+
CONFIGURATION_FILE_NAME=$6
7+
UNINSTALLER_FILE_NAME=$7
8+
9+
mkdir installer
10+
mkdir Scripts
11+
12+
cp $SOURCE_BINARY_PATH installer/$DESTINATION_BINARY_NAME
13+
14+
export DESTINATION_BINARY_NAME
15+
cp postinstall_local Scripts/postinstall
16+
sed -i '' "3s/.*/DESTINATION_BINARY_NAME=$DESTINATION_BINARY_NAME/" Scripts/postinstall
17+
sed -i '' "4s/.*/DATA_FOLDER_NAME=$DATA_FOLDER_NAME/" Scripts/postinstall
18+
sed -i '' "5s/.*/CONFIGURATION_FILE_NAME=$CONFIGURATION_FILE_NAME/" Scripts/postinstall
19+
chmod +x Scripts/postinstall
20+
21+
export DATA_FOLDER_NAME CONFIGURATION_FILE_NAME UNINSTALLER_FILE_NAME
22+
cp cortex-uninstall.sh installer/$UNINSTALLER_FILE_NAME
23+
sed -i '' "2s/.*/DESTINATION_BINARY_NAME=$DESTINATION_BINARY_NAME/" installer/$UNINSTALLER_FILE_NAME
24+
sed -i '' "3s/.*/DATA_FOLDER_NAME=$DATA_FOLDER_NAME/" installer/$UNINSTALLER_FILE_NAME
25+
sed -i '' "4s/.*/CONFIGURATION_FILE_NAME=$CONFIGURATION_FILE_NAME/" installer/$UNINSTALLER_FILE_NAME
26+
sed -i '' "5s/.*/UNINSTALLER_FILE_NAME=$UNINSTALLER_FILE_NAME/" installer/$UNINSTALLER_FILE_NAME
27+
28+
pkgbuild --identifier ai.cortexcpp.pkg --version $VERSION --scripts Scripts --install-location /usr/local/bin --root ./installer ${PACKAGE_NAME}.pkg
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env sh
2+
set -e
3+
DESTINATION_BINARY_NAME=cortex
4+
DATA_FOLDER_NAME=.cortex
5+
CONFIGURATION_FILE_NAME=.cortexrc
6+
7+
USER_TO_RUN_AS=$(stat -f "%Su" /dev/console)
8+
9+
echo "Download cortex.llamacpp engines by default for user $USER_TO_RUN_AS"
10+
sudo -u $USER_TO_RUN_AS /usr/local/bin/$DESTINATION_BINARY_NAME engines install cortex.llamacpp -s ./dependencies
11+
12+
sudo chown -R $USER_TO_RUN_AS:staff "/Users/$USER_TO_RUN_AS/$DATA_FOLDER_NAME"
13+
sudo chown $USER_TO_RUN_AS:staff "/Users/$USER_TO_RUN_AS/$CONFIGURATION_FILE_NAME"
14+
15+
rm -rf ./dependencies
16+
17+
exit 0

0 commit comments

Comments
 (0)