-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·113 lines (88 loc) · 2.91 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·113 lines (88 loc) · 2.91 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
set -e
VERSION="${VERSION:-0.1.0}"
BUILD_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$BUILD_DIR"
echo "=== Building CloudPass v$VERSION ==="
echo ">>> Cleaning up..."
rm -rf ui/build
rm -rf api/internal/web/build
echo ">>> Building UI..."
cd ui
npm ci --silent
npm run build
cd ..
echo ">>> Copying UI to embed directory..."
mkdir -p api/internal/web/build
cp -r ui/build/* api/internal/web/build/
echo ">>> Building Go API..."
cd api
echo ">>> Building binaries..."
build() {
local os=$1
local arch=$2
local ext=""
[ "$os" = "windows" ] && ext=".exe"
echo "Building for $os/$arch..."
GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -ldflags="-s -w" -o "../cloudpass-$os-$arch$ext" ./cmd/server
}
build linux arm64
build linux amd64
build darwin amd64
build darwin arm64
build windows amd64
cd ..
echo ">>> Creating release archives..."
# Create release directory structure for each platform
create_release() {
local target=$1
local os=$2
local arch=$3
local ext=""
[ "$os" = "windows" ] && ext=".exe"
local release_dir="release-$target"
mkdir -p "$release_dir/scripts"
# Copy binary
cp "cloudpass-$os-$arch$ext" "$release_dir/cloudpass$ext"
# Copy config
cp config.yaml "$release_dir/"
# Copy README
cp README.md "$release_dir/"
# Copy scripts (only platform-specific)
if [ "$os" = "windows" ]; then
cp scripts/install.ps1 "$release_dir/scripts/"
cp scripts/uninstall.ps1 "$release_dir/scripts/"
else
cp scripts/install.sh "$release_dir/scripts/"
cp scripts/uninstall.sh "$release_dir/scripts/"
cp scripts/update.sh "$release_dir/scripts/"
chmod +x "$release_dir/scripts/"*.sh
fi
}
# Create releases for each platform
create_release "linux-arm64" linux arm64
create_release "linux-amd64" linux amd64
create_release "darwin-amd64" darwin amd64
create_release "darwin-arm64" darwin arm64
create_release "windows-amd64" windows amd64
# Create archives - archive the FOLDER itself so extraction creates the folder
echo ">>> Creating tarballs..."
tar -czvf "cloudpass-$VERSION-linux-arm64.tar.gz" release-linux-arm64
tar -czvf "cloudpass-$VERSION-linux-amd64.tar.gz" release-linux-amd64
tar -czvf "cloudpass-$VERSION-darwin-arm64.tar.gz" release-darwin-arm64
tar -czvf "cloudpass-$VERSION-darwin-amd64.tar.gz" release-darwin-amd64
echo ">>> Creating zip..."
zip -q -r "cloudpass-$VERSION-windows-amd64.zip" release-windows-amd64
# Setup local binary BEFORE cleaning up
echo ">>> Setup local binary..."
cp cloudpass-linux-amd64 cloudpass
chmod +x cloudpass
# Cleanup release directories
rm -rf release-linux-arm64 release-linux-amd64 release-darwin-amd64 release-darwin-arm64 release-windows-amd64
# Cleanup individual binaries
rm -f cloudpass-linux-*
rm -f cloudpass-darwin-*
rm -f cloudpass-windows-*
echo "=== Build Complete ==="
echo "Archives created:"
ls -la cloudpass-*.tar.gz cloudpass-*.zip