-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·52 lines (44 loc) · 2.07 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
#!/bin/bash
set -e
if [ "x$1" = "xrelease" ]; then
# cleanup
rm -rf .build/ build/
# build for macOS
echo ""
echo "----------------------------------------"
echo "Building for macOS..."
swift build --arch arm64 --arch x86_64 -c release
mkdir -p "build/macOS"
rsync -ar ".build/apple/Products/Release/harbor" "build/macOS"
rsync -ar ".build/apple/Products/Release/Harbor_Harbor.bundle" "build/macOS"
tar -C build/macOS -czf build/macOS.tar.gz .
# build for linux
if ! command -v docker &> /dev/null; then
echo "Couldn't build for linux, docker isn't available"
exit -1
fi
echo ""
echo "----------------------------------------"
echo "Building for Linux ARM64..."
docker container rm -f harbor-linux > /dev/null
docker run -it --name harbor-linux --platform linux/arm64/v8 -v $(pwd):/harbor swift:latest /bin/bash -c "cd harbor && swift build -c release"
mkdir -p "build/linux-arm64"
rsync -ar ".build/aarch64-unknown-linux-gnu/release/harbor" "build/linux-arm64"
rsync -ar ".build/aarch64-unknown-linux-gnu/release/Harbor_Harbor.resources" "build/linux-arm64"
tar -C build/linux-arm64 -czf build/linux-arm64.tar.gz .
echo ""
echo "----------------------------------------"
echo "Building for Linux x64..."
docker container rm -f harbor-linux > /dev/null
docker run -it --name harbor-linux --platform linux/amd64 -v $(pwd):/harbor swift:latest /bin/bash -c "cd harbor && swift build -c release"
mkdir -p "build/linux-amd64"
rsync -ar ".build/x86_64-unknown-linux-gnu/release/harbor" "build/linux-amd64"
rsync -ar ".build/x86_64-unknown-linux-gnu/release/Harbor_Harbor.resources" "build/linux-amd64"
tar -C build/linux-amd64 -czf build/linux-amd64.tar.gz .
else
swift build --arch arm64 --arch x86_64 -c debug
mkdir -p "build/macOS"
rsync -ar ".build/apple/Products/Debug/harbor" "build/macOS"
rsync -ar ".build/apple/Products/Debug/Harbor_Harbor.bundle" "build/macOS"
fi
echo "All good!"