feat: api serve frontend, build workflow, router readyness

This commit is contained in:
Floriansylvain
2025-12-24 01:05:58 +01:00
parent aee595dee9
commit 4a6209a8db
13 changed files with 174 additions and 74 deletions
+41
View File
@@ -0,0 +1,41 @@
#!/bin/sh
OUTPUT_DIR=./bin
GO_FILE_PATH="./cmd/server/main.go"
PROGRAM_NAME=RenewCMS
WEB_DIR="./web"
echo "Starting frontend build in $WEB_DIR..."
if [ -d "$WEB_DIR" ]; then
(cd "$WEB_DIR" && bun run build)
if [ $? -ne 0 ]; then
echo "Frontend build failed. Aborting process."
exit 1
fi
else
echo "Error: Directory $WEB_DIR not found."
exit 1
fi
echo "Frontend build completed successfully."
echo "----------------------------------------"
GOOS=$(go env GOOS)
GOARCH=$(go env GOARCH)
output_name="$OUTPUT_DIR/${PROGRAM_NAME}_${GOOS}_${GOARCH}"
if [ "$GOOS" = "windows" ]; then
output_name+='.exe'
fi
echo "Detected platform: $GOOS/$GOARCH"
echo "Building for $GOOS/$GOARCH..."
env GOOS=$GOOS GOARCH=$GOARCH go build -o "$output_name" "$GO_FILE_PATH"
if [ $? -eq 0 ]; then
echo "Compilation successful: $output_name"
else
echo "Compilation for $GOOS/$GOARCH failed."
exit 1
fi
+27
View File
@@ -0,0 +1,27 @@
#!/bin/sh
OUTPUT_DIR=./bin
GO_FILE_PATH="./cmd/server/main.go"
PROGRAM_NAME=RenewCMS
platforms=("windows/amd64" "windows/arm64" "linux/amd64" "linux/arm64" "darwin/amd64" "darwin/arm64")
for platform in "${platforms[@]}"
do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
output_name="$OUTPUT_DIR/${PROGRAM_NAME}_${GOOS}_${GOARCH}"
if [ "$GOOS" = "windows" ]; then
output_name+='.exe'
fi
echo "Building for $GOOS/$GOARCH..."
env GOOS=$GOOS GOARCH=$GOARCH go build -o "$output_name" "$GO_FILE_PATH"
if [ $? -ne 0 ]; then
echo "Compilation for $GOOS/$GOARCH failed."
exit $?
fi
done
echo "Compilation successful for all platforms."