build_darwin.sh 1.16 KB
Newer Older
Jeffrey Morgan's avatar
Jeffrey Morgan committed
1
2
3
4
#!/bin/bash

mkdir -p dist

Michael Yang's avatar
Michael Yang committed
5
GO_LDFLAGS="-X github.com/jmorganca/ollama/version.Version=$VERSION"
Michael Yang's avatar
Michael Yang committed
6
GO_LDFLAGS="$GO_LDFLAGS -X github.com/jmorganca/ollama/server.mode=release"
Michael Yang's avatar
Michael Yang committed
7

8
# build universal binary
Michael Yang's avatar
Michael Yang committed
9
10
CGO_ENABLED=1 GOARCH=arm64 go build -ldflags "$GO_LDFLAGS" -o dist/ollama-darwin-arm64
CGO_ENABLED=1 GOARCH=amd64 go build -ldflags "$GO_LDFLAGS" -o dist/ollama-darwin-amd64
11
12
lipo -create -output dist/ollama dist/ollama-darwin-arm64 dist/ollama-darwin-amd64
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
Jeffrey Morgan's avatar
Jeffrey Morgan committed
15
16

# build and sign the mac app
Jeffrey Morgan's avatar
Jeffrey Morgan committed
17
npm install --prefix app
Jeffrey Morgan's avatar
Jeffrey Morgan committed
18
npm run --prefix app make:sign
Jeffrey Morgan's avatar
Jeffrey Morgan committed
19
cp app/out/make/zip/darwin/universal/Ollama-darwin-universal-${VERSION:-0.0.0}.zip dist/Ollama-darwin.zip
Jeffrey Morgan's avatar
Jeffrey Morgan committed
20

21
22
23
24
# sign the binary and rename it
codesign -f --timestamp -s "$APPLE_IDENTITY" --identifier ai.ollama.ollama --options=runtime dist/ollama
ditto -c -k --keepParent dist/ollama dist/temp.zip
xcrun notarytool submit dist/temp.zip --wait --timeout 10m --apple-id $APPLE_ID --password $APPLE_PASSWORD --team-id $APPLE_TEAM_ID
Jeffrey Morgan's avatar
Jeffrey Morgan committed
25
mv dist/ollama dist/ollama-darwin
26
rm dist/temp.zip