build_darwin.sh 1.19 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
9
10
11
12
GOARCH=arm64 go generate ./...
GOARCH=arm64 go build -ldflags "$GO_LDFLAGS" -o dist/ollama-darwin-arm64
GOARCH=amd64 go generate ./...
GOARCH=amd64 go build -ldflags "$GO_LDFLAGS" -o dist/ollama-darwin-amd64
13
14
lipo -create -output dist/ollama dist/ollama-darwin-arm64 dist/ollama-darwin-amd64
rm dist/ollama-darwin-amd64 dist/ollama-darwin-arm64
15
codesign --deep --force --options=runtime --sign "$APPLE_IDENTITY" --timestamp dist/ollama
16
chmod +x dist/ollama
Jeffrey Morgan's avatar
Jeffrey Morgan committed
17
18

# build and sign the mac app
Jeffrey Morgan's avatar
Jeffrey Morgan committed
19
npm install --prefix app
Jeffrey Morgan's avatar
Jeffrey Morgan committed
20
npm run --prefix app make:sign
Jeffrey Morgan's avatar
Jeffrey Morgan committed
21
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
22

23
24
25
26
# 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
27
mv dist/ollama dist/ollama-darwin
28
rm dist/temp.zip