-
Notifications
You must be signed in to change notification settings - Fork 405
/
Copy pathrebuild.sh
executable file
·65 lines (57 loc) · 2.28 KB
/
rebuild.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
59
60
61
62
63
64
65
#!/usr/bin/env bash
set -e
if [[ -z "${TMPDIR}" ]]; then
TMPDIR="/tmp"
fi
if [[ -z "${BUILD_PLATFORMS}" ]]; then
BUILD_PLATFORMS="linux windows darwin"
fi
for os in $BUILD_PLATFORMS; do
for arch in amd64 arm64; do
# don't build for arm on windows
if [[ "$os" == "windows" && "$arch" == "arm64" ]]; then
continue
fi
echo "[INFO] Building for $os/$arch"
if [[ $RACE == "yes" ]]; then
echo "Building devpod with race detector"
CGO_ENABLED=1 GOOS=$os GOARCH=$arch go build -race -ldflags "-s -w" -o test/devpod-cli-$os-$arch
else
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -ldflags "-s -w" -o test/devpod-cli-$os-$arch
fi
done
done
echo "[INFO] Built binaries for all platforms in test/ directory"
if [[ -z "${SKIP_INSTALL}" ]]; then
if command -v sudo &> /dev/null; then
go build -o test/devpod && sudo mv test/devpod /usr/local/bin/
else
go install .
fi
fi
echo "[INFO] Built devpod binary and moved to /usr/local/bin"
if [[ $BUILD_PLATFORMS == *"linux"* ]]; then
cp test/devpod-cli-linux-amd64 test/devpod-linux-amd64
cp test/devpod-cli-linux-arm64 test/devpod-linux-arm64
fi
if [ -d "desktop/src-tauri/bin" ]; then
if [[ $BUILD_PLATFORMS == *"linux"* ]]; then
cp test/devpod-cli-linux-amd64 desktop/src-tauri/bin/devpod-cli-x86_64-unknown-linux-gnu
cp test/devpod-cli-linux-arm64 desktop/src-tauri/bin/devpod-cli-aarch64-unknown-linux-gnu
fi
if [[ $BUILD_PLATFORMS == *"windows"* ]]; then
cp test/devpod-cli-windows-amd64 desktop/src-tauri/bin/devpod-cli-x86_64-pc-windows-msvc.exe
fi
if [[ $BUILD_PLATFORMS == *"darwin"* ]]; then
cp test/devpod-cli-darwin-amd64 desktop/src-tauri/bin/devpod-cli-x86_64-apple-darwin
cp test/devpod-cli-darwin-arm64 desktop/src-tauri/bin/devpod-cli-aarch64-apple-darwin
fi
echo "[INFO] Copied binaries to desktop/src-tauri/bin"
fi
if [[ $BUILD_PLATFORMS == *"linux"* ]]; then
rm -R $TMPDIR/devpod-cache 2>/dev/null || true
mkdir -p $TMPDIR/devpod-cache
cp test/devpod-cli-linux-amd64 $TMPDIR/devpod-cache/devpod-linux-amd64
cp test/devpod-cli-linux-arm64 $TMPDIR/devpod-cache/devpod-linux-arm64
echo "[INFO] Copied binaries to $TMPDIR/devpod-cache"
fi