-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·58 lines (45 loc) · 1.26 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
# Variables
APP_NAME="doubutsu-uranai"
# Pick the latest tag from git
VERSION=$(git describe --tags --abbrev=0)
OUTPUT_DIR="dist"
# Remove output directory if it exists
if [ -d "$OUTPUT_DIR" ]; then
rm -rf "$OUTPUT_DIR"
fi
# List of target platforms and architectures
TARGETS="darwin amd64
darwin arm64
freebsd amd64
linux amd64
linux arm
linux arm64
"
# Create output directory
mkdir -p "$OUTPUT_DIR"
echo "Building binaries for $APP_NAME version $VERSION..."
go install mvdan.cc/garble@latest
# Loop through each target
echo "$TARGETS" | while read -r PLATFORM ARCH; do
# Skip empty lines
if [ -z "$PLATFORM" ] || [ -z "$ARCH" ]; then
continue
fi
OUTPUT_FILE="$OUTPUT_DIR/${APP_NAME}-${PLATFORM}-${ARCH}"
# Set environment variables and build
if ! GOOS=$PLATFORM GOARCH=$ARCH garble build -o "$OUTPUT_FILE"; then
echo "Failed to build for $PLATFORM $ARCH"
exit 1
fi
echo "Built: $OUTPUT_FILE"
done
# Generate checksums
CHECKSUM_FILE="$OUTPUT_DIR/${APP_NAME}_${VERSION}_checksums.txt"
echo "Generating checksums..."
if ! shasum -a 256 "$OUTPUT_DIR"/* > "$CHECKSUM_FILE"; then
echo "Failed to generate checksums"
exit 1
fi
echo "Checksums written to $CHECKSUM_FILE"
echo "Build and packaging completed!"