build_darwin.sh 1.2 KB

1234567891011121314151617181920212223242526
  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. CGO_ENABLED=1 GOARCH=arm64 go build -ldflags "$GO_LDFLAGS" -o dist/ollama-darwin-arm64
  7. CGO_ENABLED=1 GOARCH=amd64 go build -ldflags "$GO_LDFLAGS" -o dist/ollama-darwin-amd64
  8. lipo -create -output dist/ollama dist/ollama-darwin-arm64 dist/ollama-darwin-amd64
  9. rm dist/ollama-darwin-amd64 dist/ollama-darwin-arm64
  10. codesign --deep --force --options=runtime --sign "$APPLE_IDENTITY" --timestamp dist/ollama
  11. chmod +x dist/ollama
  12. # build and sign the mac app
  13. npm install --prefix app
  14. npm run --prefix app make:sign
  15. cp app/out/make/zip/darwin/universal/Ollama-darwin-universal-${VERSION:-0.0.0}.zip dist/Ollama-darwin.zip
  16. # sign the binary and rename it
  17. codesign -f --timestamp -s "$APPLE_IDENTITY" --identifier ai.ollama.ollama --options=runtime dist/ollama
  18. ditto -c -k --keepParent dist/ollama dist/temp.zip
  19. xcrun notarytool submit dist/temp.zip --wait --timeout 10m --apple-id $APPLE_ID --password $APPLE_PASSWORD --team-id $APPLE_TEAM_ID
  20. mv dist/ollama dist/ollama-darwin
  21. rm dist/temp.zip