build_darwin.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/sh
  2. set -e
  3. . $(dirname $0)/env.sh
  4. mkdir -p dist
  5. for TARGETARCH in arm64 amd64; do
  6. rm -rf llm/llama.cpp/build
  7. GOOS=darwin GOARCH=$TARGETARCH go generate ./...
  8. CGO_ENABLED=1 GOOS=darwin GOARCH=$TARGETARCH go build -trimpath -o dist/ollama-darwin-$TARGETARCH
  9. CGO_ENABLED=1 GOOS=darwin GOARCH=$TARGETARCH go build -trimpath -cover -o dist/ollama-darwin-$TARGETARCH-cov
  10. done
  11. lipo -create -output dist/ollama dist/ollama-darwin-arm64 dist/ollama-darwin-amd64
  12. rm -f dist/ollama-darwin-arm64 dist/ollama-darwin-amd64
  13. if [ -n "$APPLE_IDENTITY" ]; then
  14. codesign --deep --force --options=runtime --sign "$APPLE_IDENTITY" --timestamp dist/ollama
  15. else
  16. echo "Skipping code signing - set APPLE_IDENTITY"
  17. fi
  18. chmod +x dist/ollama
  19. # build and optionally sign the mac app
  20. npm install --prefix macapp
  21. if [ -n "$APPLE_IDENTITY" ]; then
  22. npm run --prefix macapp make:sign
  23. else
  24. npm run --prefix macapp make
  25. fi
  26. cp macapp/out/make/zip/darwin/universal/Ollama-darwin-universal-$VERSION.zip dist/Ollama-darwin.zip
  27. # sign the binary and rename it
  28. if [ -n "$APPLE_IDENTITY" ]; then
  29. codesign -f --timestamp -s "$APPLE_IDENTITY" --identifier ai.ollama.ollama --options=runtime dist/ollama
  30. else
  31. echo "WARNING: Skipping code signing - set APPLE_IDENTITY"
  32. fi
  33. ditto -c -k --keepParent dist/ollama dist/temp.zip
  34. if [ -n "$APPLE_IDENTITY" ]; then
  35. xcrun notarytool submit dist/temp.zip --wait --timeout 10m --apple-id $APPLE_ID --password $APPLE_PASSWORD --team-id $APPLE_TEAM_ID
  36. fi
  37. mv dist/ollama dist/ollama-darwin
  38. rm -f dist/temp.zip