build_darwin.sh 1.1 KB

12345678910111213141516171819202122232425262728293031
  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. rm -rf llm/llama.cpp/*/build
  10. done
  11. lipo -create -output dist/ollama dist/ollama-darwin-*
  12. rm -f dist/ollama-darwin-*
  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.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 -f dist/temp.zip