build_darwin.sh 1.1 KB

123456789101112131415161718192021222324252627282930
  1. #!/bin/sh
  2. set -eu
  3. export VERSION=${VERSION:-0.0.0}
  4. export GOFLAGS="'-ldflags=-w -s \"-X=github.com/jmorganca/ollama/version.Version=$VERSION\" \"-X=github.com/jmorganca/ollama/server.mode=release\"'"
  5. mkdir -p dist
  6. for TARGETARCH in arm64 amd64; do
  7. GOOS=darwin GOARCH=$TARGETARCH go generate ./...
  8. GOOS=darwin GOARCH=$TARGETARCH go build -o dist/ollama-darwin-$TARGETARCH
  9. done
  10. lipo -create -output dist/ollama dist/ollama-darwin-*
  11. rm -f dist/ollama-darwin-*
  12. codesign --deep --force --options=runtime --sign "$APPLE_IDENTITY" --timestamp dist/ollama
  13. chmod +x dist/ollama
  14. # build and sign the mac app
  15. npm install --prefix app
  16. npm run --prefix app make:sign
  17. cp app/out/make/zip/darwin/universal/Ollama-darwin-universal-$VERSION.zip dist/Ollama-darwin.zip
  18. # sign the binary and rename it
  19. codesign -f --timestamp -s "$APPLE_IDENTITY" --identifier ai.ollama.ollama --options=runtime dist/ollama
  20. ditto -c -k --keepParent dist/ollama dist/temp.zip
  21. xcrun notarytool submit dist/temp.zip --wait --timeout 10m --apple-id $APPLE_ID --password $APPLE_PASSWORD --team-id $APPLE_TEAM_ID
  22. mv dist/ollama dist/ollama-darwin
  23. rm -f dist/temp.zip