-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpackage.sh
executable file
·58 lines (46 loc) · 1.32 KB
/
package.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/bash
set -e
create_package() {
local os=$1
local arch=$2
local version=$3
echo "Packing for OS $os and arch $arch..."
local path="output/micro-ddns-$os-$arch"
if [ ! -d "$path" ]; then
mkdir -p "$path"
fi
local binary="bin/micro-ddns-${os}-${arch}"
if [ "$os" == "windows" ]; then
binary="${binary}.exe"
fi
cp "$binary" "$path/micro-ddns"
if [ "$os" == "windows" ]; then
mv "$path/micro-ddns" "$path/micro-ddns.exe"
fi
if [ ! -d "$path/example" ]; then
mkdir -p "$path/example"
fi
cp "example/homelab.yaml" "$path/example/config.yaml"
if [ "$os" == "linux" ]; then
cp -r "init" "$path"
fi
local tar_name="output/micro-ddns-${os}-${arch}-$version.tar.gz"
tar -czf "$tar_name" -C "$path" .
sha256sum "$tar_name" > "$tar_name.sha256"
gpg --detach-sign --armor "$tar_name"
}
if [ -z "${VERSION}" ]; then
echo "VERSION is required"
exit 1
fi
if [ -z "${PLATFORMS}" ]; then
PLATFORMS="$(go tool dist list | grep 'linux\|windows\|freebsd\|darwin' | tr '\n' ',' | sed 's/,$//')"
fi
IFS=',' read -r -a platforms <<< "$PLATFORMS"
for platform in "${platforms[@]}"
do
IFS='/' read -r -a os_arch <<< "$platform"
create_package "${os_arch[0]}" "${os_arch[1]}" "$VERSION" &
done
wait
rm -rf output/*/