mirror of
https://gh-proxy.org/https://github.com/klinsmaya/new-api.git
synced 2026-11-08 01:17:09 +08:00
moejs ships a default.pgo recorded from plugin workloads. Go only uses a profile found in the main package directory, so the Docker image, the release workflow and the Electron builds now pass it with -pgo.
43 lines
1.4 KiB
Bash
Executable File
Vendored
43 lines
1.4 KiB
Bash
Executable File
Vendored
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
echo "Building New API Electron App..."
|
|
|
|
echo "Step 1: Building frontend..."
|
|
cd ../web
|
|
bun install --frozen-lockfile
|
|
DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(git describe --tags --always) bun run build
|
|
cd ../electron
|
|
|
|
echo "Step 2: Building Go backend..."
|
|
cd ..
|
|
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
echo "Building for macOS..."
|
|
CGO_ENABLED=1 go build -pgo="$(go list -m -f '{{.Dir}}' github.com/Calcium-Ion/moejs)/default.pgo" -ldflags="-s -w" -o new-api
|
|
cd electron
|
|
npm install
|
|
npm run build:mac
|
|
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|
echo "Building for Linux..."
|
|
CGO_ENABLED=1 go build -pgo="$(go list -m -f '{{.Dir}}' github.com/Calcium-Ion/moejs)/default.pgo" -ldflags="-s -w" -o new-api
|
|
cd electron
|
|
npm install
|
|
npm run build:linux
|
|
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "win32" ]]; then
|
|
echo "Building for Windows..."
|
|
CGO_ENABLED=1 go build -pgo="$(go list -m -f '{{.Dir}}' github.com/Calcium-Ion/moejs)/default.pgo" -ldflags="-s -w" -o new-api.exe
|
|
cd electron
|
|
npm install
|
|
npm run build:win
|
|
else
|
|
echo "Unknown OS, building for current platform..."
|
|
CGO_ENABLED=1 go build -pgo="$(go list -m -f '{{.Dir}}' github.com/Calcium-Ion/moejs)/default.pgo" -ldflags="-s -w" -o new-api
|
|
cd electron
|
|
npm install
|
|
npm run build
|
|
fi
|
|
|
|
echo "Build complete! Check electron/dist/ for output."
|