Skip to content

Commit 62d436d

Browse files
committed
refactor: darwin release layout
1 parent 1bd7cb5 commit 62d436d

File tree

10 files changed

+77
-20
lines changed

10 files changed

+77
-20
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Build and binary files
22
build/
3+
artifacts/
34
*.exe
45
*.exe~
56
*.dll

runner/Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
BRIDGE_VERSION ?= v1.0.6-rc1
22

3+
VERSION ?= $(shell git rev-parse --short HEAD)
34
ifeq ($(OS), Windows_NT)
45
OS := windows
56
ARCH ?= x86_64
@@ -25,7 +26,7 @@ else
2526
UNZIP := unzip -q
2627
endif
2728

28-
.PHONY: build link xcopy download clean
29+
.PHONY: build link xcopy download clean package
2930

3031
build:
3132
go build -o ./build/nexa$(EXE) ./cmd/nexa-launcher
@@ -55,5 +56,17 @@ download: clean
5556
https://nexa-model-hub-bucket.s3.us-west-1.amazonaws.com/public/nexasdk/$(BRIDGE_VERSION)/$(OS)_$(ARCH)/nexasdk-bridge.zip
5657
cd build && $(UNZIP) nexasdk-bridge.zip && $(RM_FILE) nexasdk-bridge.zip
5758

59+
package: build
60+
-$(RM_DIR) artifacts
61+
@echo "====> Creating installer package for $(OS)_$(ARCH)"
62+
@if [ "$(OS)" = "windows" ]; then \
63+
bash release/package_windows.sh $(VERSION); \
64+
elif [ "$(OS)" = "macos" ]; then \
65+
release/package_darwin.sh $(VERSION) $(ARCH); \
66+
elif [ "$(OS)" = "linux" ]; then \
67+
bash release/package_linux.sh $(VERSION); \
68+
fi
69+
5870
clean:
5971
-$(RM_DIR) build
72+
-$(RM_DIR) artifacts
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/osascript
2+
tell application "Terminal"
3+
activate
4+
do script "nexa"
5+
end tell
File renamed without changes.

runner/release/darwin/scripts/prepackage.sh renamed to runner/release/darwin/prepackage.sh

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ fi
99

1010
echo "--- Preparing file structure for version ${VERSION} ---"
1111

12-
APP_BASE="staging/Applications"
13-
APP_NAME="NexaCLI"
14-
APP_PATH="${APP_BASE}/${APP_NAME}.app"
12+
APP_PATH="staging/Applications/NexaCLI.app"
1513

1614
echo "Creating directories..."
1715
mkdir -p "${APP_PATH}/Contents/MacOS"
@@ -20,22 +18,8 @@ mkdir -p "${APP_PATH}/Contents/Resources"
2018
echo "Moving build artifacts..."
2119
mv artifacts/* "${APP_PATH}/Contents/Resources/"
2220

23-
echo "Copying support files..."
24-
cp runner/release/darwin/scripts/uninstall.sh "${APP_PATH}/Contents/Resources/"
25-
chmod +x "${APP_PATH}/Contents/Resources/uninstall.sh"
26-
cp runner/release/darwin/nexa-icon.icns "${APP_PATH}/Contents/Resources/"
27-
28-
echo "Creating Info.plist..."
29-
sed "s/\${VERSION}/${VERSION}/g" runner/release/darwin/Info.plist > "${APP_PATH}/Contents/Info.plist"
30-
31-
echo "Creating launcher script..."
32-
cat << EOF > "${APP_PATH}/Contents/MacOS/launcher"
33-
#!/usr/bin/osascript
34-
tell application "Terminal"
35-
activate
36-
do script "nexa"
37-
end tell
38-
EOF
21+
22+
3923

4024
echo "Setting permissions..."
4125
chmod +x "${APP_PATH}/Contents/MacOS/launcher"
File renamed without changes.

runner/release/package_darwin.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#! /bin/sh
2+
3+
set -e
4+
5+
TARGET_DIR="artifacts"
6+
TARGET_APP_PATH="${TARGET_DIR}/Applications/NexaCLI.app"
7+
TARGET_RESOURCES_PATH="${TARGET_APP_PATH}/Contents/Resources"
8+
9+
main() {
10+
local VERSION=$1
11+
local ARCH=$2
12+
if [ -z "$VERSION" ]; then
13+
echo "Usage: $0 <version> <arch>"
14+
exit 1
15+
fi
16+
17+
# copy files to target directory
18+
mkdir -p ${TARGET_DIR}
19+
cp -r release/darwin/Applications ${TARGET_DIR}
20+
cp -r build/* ${TARGET_RESOURCES_PATH}
21+
22+
# replace version in Info.plist
23+
sed -i '' "s/\${VERSION}/$VERSION/g" "${TARGET_APP_PATH}/Contents/Info.plist"
24+
25+
# fix dylib Linkages (RPATH)
26+
install_name_tool -add_rpath "@loader_path" "${TARGET_RESOURCES_PATH}/nexa-cli"
27+
28+
# setting permissions
29+
chmod +x "${TARGET_APP_PATH}/Contents/MacOS/launcher"
30+
chmod +x "${TAEGET_RESOURCES_PATH/nexa"
31+
chmod +x "${TAEGET_RESOURCES_PATH/nexa-cli"
32+
if [ -d "${TAEGET_RESOURCES_PATH/nexa_mlx/python_runtime/bin" ]; then
33+
chmod -R +x "${TAEGET_RESOURCES_PATH/nexa_mlx/python_runtime/bin"
34+
fi
35+
36+
# Import Code Signing Certificates
37+
38+
# Sign binaries and libraries
39+
40+
# Build PKG
41+
pkgbuild --root "${TARGET_DIR}" \
42+
--scripts "release/darwin/scripts" \
43+
--identifier "com.nexaai.nexa-sdk" \
44+
--version "${VERSION}" \
45+
--install-location / \
46+
"${TARGET_DIR}/nexa-cli_macos_${ARCH}-unsigned.pkg"
47+
48+
# Productsign PKG
49+
50+
# Notarize & Staple PKG
51+
52+
}
53+
54+
main "$@"

0 commit comments

Comments
 (0)