build_darwin.sh 1.2 KB

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