Skip to content

Commit 3841f59

Browse files
committed
update sandbox
1 parent a1b1a7d commit 3841f59

File tree

4 files changed

+127
-11
lines changed

4 files changed

+127
-11
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,6 @@ By contributing to this project, you agree that:
185185
If you have any questions, feel free to reach out:
186186

187187
- GitHub Issues: [github.com/workany-ai/workany/issues](https://github.com/workany-ai/workany/issues)
188-
- Email: support@workany.ai
188+
- Email: hello@workany.ai
189189

190190
Thank you for your contributions!

scripts/build.sh

Lines changed: 120 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,11 +623,21 @@ build_mac_intel() {
623623
# Add target if not exists
624624
rustup target add "$target" 2>/dev/null || true
625625

626-
pnpm tauri build --target "$target"
626+
# IMPORTANT: When signing is enabled, we must disable Tauri's built-in notarization
627+
# because Resources/cli-bundle binaries need to be signed AFTER Tauri copies them.
628+
if [ "$SKIP_SIGNING" != "true" ] && [ "$BUNDLE_CLI" = "true" ]; then
629+
log_info "Disabling Tauri notarization (will notarize manually after signing cli-bundle)..."
630+
TAURI_SKIP_NOTARIZATION=true pnpm tauri build --target "$target"
631+
else
632+
pnpm tauri build --target "$target"
633+
fi
627634

628635
# Sign cli-bundle in app bundle Resources (after Tauri build)
629636
sign_cli_bundle_in_app "$target"
630637

638+
# Notarize the app (after all binaries are signed)
639+
notarize_app "$target"
640+
631641
# Recreate DMG with bundle included
632642
recreate_dmg "$target"
633643

@@ -718,6 +728,90 @@ sign_cli_bundle_in_app() {
718728
fi
719729
}
720730

731+
# Notarize the app bundle (after all signing is complete)
732+
notarize_app() {
733+
local target="$1"
734+
735+
if [ "$SKIP_SIGNING" = "true" ]; then
736+
return 0
737+
fi
738+
739+
if [ "$BUNDLE_CLI" != "true" ]; then
740+
# If no cli-bundle, Tauri already handled notarization
741+
return 0
742+
fi
743+
744+
log_info "Notarizing app bundle..."
745+
746+
local app_path=""
747+
case "$target" in
748+
aarch64-apple-darwin)
749+
app_path="$PROJECT_ROOT/src-tauri/target/$target/release/bundle/macos/WorkAny.app"
750+
;;
751+
x86_64-apple-darwin)
752+
app_path="$PROJECT_ROOT/src-tauri/target/$target/release/bundle/macos/WorkAny.app"
753+
;;
754+
current)
755+
local arch=$(uname -m)
756+
if [ "$arch" = "arm64" ]; then
757+
app_path="$PROJECT_ROOT/src-tauri/target/aarch64-apple-darwin/release/bundle/macos/WorkAny.app"
758+
else
759+
app_path="$PROJECT_ROOT/src-tauri/target/x86_64-apple-darwin/release/bundle/macos/WorkAny.app"
760+
fi
761+
;;
762+
*)
763+
return 0
764+
;;
765+
esac
766+
767+
if [ ! -d "$app_path" ]; then
768+
log_warn "App bundle not found at $app_path"
769+
return 0
770+
fi
771+
772+
# Create a zip for notarization
773+
local temp_zip=$(mktemp).zip
774+
log_info "Creating zip for notarization..."
775+
ditto -c -k --keepParent "$app_path" "$temp_zip"
776+
777+
# Submit for notarization
778+
local notarize_output
779+
if [ -n "$APPLE_ID" ] && [ -n "$APPLE_PASSWORD" ] && [ -n "$APPLE_TEAM_ID" ]; then
780+
log_info "Submitting to Apple notary service (this may take a few minutes)..."
781+
notarize_output=$(xcrun notarytool submit "$temp_zip" \
782+
--apple-id "$APPLE_ID" \
783+
--password "$APPLE_PASSWORD" \
784+
--team-id "$APPLE_TEAM_ID" \
785+
--wait 2>&1) || true
786+
else
787+
# Try keychain profile as fallback
788+
log_info "Submitting to Apple notary service using keychain profile..."
789+
notarize_output=$(xcrun notarytool submit "$temp_zip" \
790+
--keychain-profile "notarytool-profile" \
791+
--wait 2>&1) || {
792+
log_warn "Notarization failed. Set APPLE_ID, APPLE_PASSWORD, APPLE_TEAM_ID or configure keychain profile."
793+
rm -f "$temp_zip"
794+
return 0
795+
}
796+
fi
797+
798+
rm -f "$temp_zip"
799+
800+
if echo "$notarize_output" | grep -q "status: Accepted"; then
801+
log_info "App notarization successful!"
802+
803+
# Staple the notarization ticket to the app
804+
log_info "Stapling notarization ticket to app..."
805+
xcrun stapler staple "$app_path" || {
806+
log_warn "Failed to staple app, but notarization was successful"
807+
}
808+
else
809+
log_error "App notarization failed:"
810+
echo "$notarize_output"
811+
return 1
812+
fi
813+
}
814+
721815
# Recreate DMG after modifying app bundle
722816
recreate_dmg() {
723817
local target="$1"
@@ -841,11 +935,22 @@ build_mac_arm() {
841935
# Add target if not exists
842936
rustup target add "$target" 2>/dev/null || true
843937

844-
pnpm tauri build --target "$target"
938+
# IMPORTANT: When signing is enabled, we must disable Tauri's built-in notarization
939+
# because Resources/cli-bundle binaries need to be signed AFTER Tauri copies them.
940+
# Flow: Tauri build -> sign cli-bundle in Resources -> re-sign app -> manual notarize
941+
if [ "$SKIP_SIGNING" != "true" ] && [ "$BUNDLE_CLI" = "true" ]; then
942+
log_info "Disabling Tauri notarization (will notarize manually after signing cli-bundle)..."
943+
TAURI_SKIP_NOTARIZATION=true pnpm tauri build --target "$target"
944+
else
945+
pnpm tauri build --target "$target"
946+
fi
845947

846948
# Sign cli-bundle in app bundle Resources (after Tauri build)
847949
sign_cli_bundle_in_app "$target"
848950

951+
# Notarize the app (after all binaries are signed)
952+
notarize_app "$target"
953+
849954
# Recreate DMG with bundle included
850955
recreate_dmg "$target"
851956

@@ -864,11 +969,23 @@ build_current() {
864969
bundle_cli_tools "current"
865970
update_tauri_config
866971

867-
pnpm tauri build
972+
# IMPORTANT: When signing is enabled, we must disable Tauri's built-in notarization
973+
if [ "$SKIP_SIGNING" != "true" ] && [ "$BUNDLE_CLI" = "true" ]; then
974+
log_info "Disabling Tauri notarization (will notarize manually after signing cli-bundle)..."
975+
TAURI_SKIP_NOTARIZATION=true pnpm tauri build
976+
else
977+
pnpm tauri build
978+
fi
868979

869980
# Sign cli-bundle in app bundle Resources
870981
sign_cli_bundle_in_app "current"
871982

983+
# Notarize the app (after all binaries are signed)
984+
notarize_app "current"
985+
986+
# Recreate DMG with bundle included
987+
recreate_dmg "current"
988+
872989
log_info "Build completed!"
873990
log_info "Output: src-tauri/target/release/bundle/"
874991
}

src-api/src/app/api/sandbox.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,10 @@ sandbox.get('/debug/codex-paths', async (c) => {
106106
const pathsToCheck = [
107107
path.join(execDir, `codex${targetTriple}`),
108108
path.join(execDir, 'codex'),
109+
// Tauri resources location
110+
path.join(execDir, '..', 'Resources', '_up_', 'src-api', 'dist', 'cli-bundle', 'node'),
109111
path.join(execDir, '..', 'Resources', 'cli-bundle', 'node'),
110112
path.join(execDir, 'cli-bundle', 'node'),
111-
// Legacy paths
112-
path.join(execDir, '..', 'Resources', 'codex-bundle', 'node'),
113-
path.join(execDir, 'codex-bundle', 'node'),
114113
'/usr/local/bin/codex',
115114
];
116115

src-api/src/extensions/sandbox/codex.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ function getBundledNodePath(): string | undefined {
7979
if (os === 'darwin') {
8080
// Check multiple locations for cli-bundle (macOS app bundle structure)
8181
const searchPaths = [
82+
// Contents/Resources/_up_/src-api/dist/cli-bundle (Tauri resources location)
83+
path.join(execDir, '..', 'Resources', '_up_', 'src-api', 'dist', 'cli-bundle', 'node'),
8284
// Contents/MacOS/cli-bundle (where build.sh copies it)
8385
path.join(execDir, 'cli-bundle', 'node'),
8486
// Contents/Resources/cli-bundle (standard resource location)
8587
path.join(execDir, '..', 'Resources', 'cli-bundle', 'node'),
86-
// Legacy codex-bundle format in Resources
87-
path.join(execDir, '..', 'Resources', 'codex-bundle', 'node'),
8888
];
8989

9090
for (const nodePath of searchPaths) {
@@ -144,12 +144,12 @@ function getBundledCodexPath(): string | undefined {
144144

145145
// Check for unified cli-bundle in multiple locations
146146
const cliBundlePaths = [
147+
// Contents/Resources/_up_/src-api/dist/cli-bundle (Tauri resources location)
148+
path.join(resourcesDir, '_up_', 'src-api', 'dist', 'cli-bundle', 'node'),
147149
// Contents/MacOS/cli-bundle (where build.sh copies it)
148150
path.join(execDir, 'cli-bundle', 'node'),
149151
// Contents/Resources/cli-bundle (standard resource location)
150152
path.join(resourcesDir, 'cli-bundle', 'node'),
151-
// Legacy codex-bundle format
152-
path.join(resourcesDir, 'codex-bundle', 'node'),
153153
];
154154

155155
for (const cliNodePath of cliBundlePaths) {

0 commit comments

Comments
 (0)