build_darwin.sh 1.1 KB

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