Skip to content

Commit

Permalink
Updated compile-macos.sh to include build tags and frontend build as …
Browse files Browse the repository at this point in the history
…well
  • Loading branch information
adrianrudnik committed Nov 4, 2023
1 parent 6ac5b2b commit cea3c48
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions service/bin/compile-macos.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/zsh -ex
#!/bin/zsh -e

# Requirements:
# - brew install imagemagick
Expand All @@ -22,27 +22,43 @@ fi
SCRIPT_DIR=${0:a:h}
cd ${SCRIPT_DIR}/..

# Ensure the frontend is correctly built
source $NVM_DIR/nvm.sh;
rm -rf internal/webservice/.frontend
cd ../frontend
nvm use
npm install
npm run build
mv dist ../service/internal/webservice/.frontend
cd ../service

rm -rf dist/os/darwin
mkdir -p dist/{deploy,os/darwin}

# Load personal settings
source ${SCRIPT_DIR}/settings.sh

APP_ID="app.ablegram.ablegram"
APP_BUILD=$(date +%s)

BUILD_DATE=$(date +%s)
BUILD_COMMIT=$(git rev-parse --short HEAD)

# build AMD64
CGO_ENABLED=1 \
GOARCH=amd64 \
GOOS=darwin \
go build -ldflags '-s' -o ablegram_darwin_amd64 .
go build \
-ldflags="-s -w -X=main.AppVersion=${APP_VERSION} -X=main.BuildCommit=${BUILD_COMMIT} -X=main.BuildDate=${BUILD_DATE}" \
-o ablegram_darwin_amd64 \
.

# build ARM64
CGO_ENABLED=1 \
GOARCH=arm64 \
GOOS=darwin \
go build -ldflags '-s' -o ablegram_darwin_arm64 .
go build \
-ldflags="-s -w -X=main.AppVersion=${APP_VERSION} -X=main.BuildCommit=${BUILD_COMMIT} -X=main.BuildDate=${BUILD_DATE}" \
-o ablegram_darwin_arm64 \
.

# merge to universal binary
lipo \
Expand Down Expand Up @@ -78,8 +94,8 @@ iconutil -c icns dist/os/darwin/Ablegram.app/Contents/Resources/icon.iconset -o
rm -rf dist/os/darwin/Ablegram.app/Contents/Resources/icon.iconset

# build and place the plist
export APP_ID APP_VERSION APP_BUILD
envsubst '${APP_ID} ${APP_VERSION} ${APP_BUILD}' < os/macOS/plist-template.xml > dist/os/darwin/Ablegram.app/Contents/Info.plist
export APP_ID APP_VERSION BUILD_DATE
envsubst '${APP_ID} ${APP_VERSION} ${BUILD_DATE}' < os/macOS/plist-template.xml > dist/os/darwin/Ablegram.app/Contents/Info.plist

# remove extended attributes
xattr -cr dist/os/darwin/Ablegram.app
Expand Down

0 comments on commit cea3c48

Please sign in to comment.