Files
dify-plugin-daemon/.script/build_dify_cli.sh
Harry c2432893b1 feat: enhance build script for cross-platform CLI compilation
- Updated the build_dify_cli.sh script to support building the CLI for multiple platforms (darwin/amd64, darwin/arm64, linux/amd64, linux/arm64).
- Improved output handling by creating a dedicated output directory and providing clear build status messages.
- This update streamlines the build process and enhances usability for developers targeting different operating systems.
2026-01-12 21:02:02 +08:00

36 lines
761 B
Bash
Executable File

#!/bin/bash
set -e
# Use environment variable VERSION if set, otherwise use default
VERSION=${VERSION:-v0.0.1}
# Output directory
OUTPUT_DIR=${OUTPUT_DIR:-dist}
mkdir -p "$OUTPUT_DIR"
# Platforms to build (OS/ARCH)
PLATFORMS=(
"darwin/amd64"
"darwin/arm64"
"linux/amd64"
"linux/arm64"
)
echo "Building dify-cli ${VERSION} for all platforms..."
for PLATFORM in "${PLATFORMS[@]}"; do
GOOS=${PLATFORM%/*}
GOARCH=${PLATFORM#*/}
OUTPUT_NAME="dify-cli-${GOOS}-${GOARCH}"
echo "Building ${OUTPUT_NAME}..."
GOOS=$GOOS GOARCH=$GOARCH go build \
-ldflags "-s -w" \
-o "${OUTPUT_DIR}/${OUTPUT_NAME}" ./cmd/dify_cli
echo "${OUTPUT_NAME}"
done
echo ""
echo "Build complete:"
ls -lh "$OUTPUT_DIR"/dify-cli-*