-
Notifications
You must be signed in to change notification settings - Fork 5
/
build-release.sh
executable file
·74 lines (67 loc) · 2.18 KB
/
build-release.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
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Builds the binaries
build_binary() {
echo -n "Building binaries... "
docker run --rm -v $PWD:/treegen rocketpool/smartnode-builder:latest /treegen/build_binaries.sh
echo "done!"
}
# Build the images
build_docker() {
echo -n "Building Docker images... "
docker buildx build --platform=linux/amd64 -t rocketpool/treegen:$VERSION-amd64 --load .
docker buildx build --platform=linux/arm64 -t rocketpool/treegen:$VERSION-arm64 --load .
docker push rocketpool/treegen:$VERSION-amd64
docker push rocketpool/treegen:$VERSION-arm64
echo "done!"
}
# Build the manifest
build_manifest() {
echo -n "Building Docker manifest... "
rm -f ~/.docker/manifests/docker.io_rocketpool_treegen-$VERSION
rm -f ~/.docker/manifests/docker.io_rocketpool_treegen-latest
docker manifest create rocketpool/treegen:$VERSION --amend rocketpool/treegen:$VERSION-amd64 --amend rocketpool/treegen:$VERSION-arm64
docker manifest create rocketpool/treegen:latest --amend rocketpool/treegen:$VERSION-amd64 --amend rocketpool/treegen:$VERSION-arm64
echo "done!"
echo -n "Pushing to Docker Hub... "
docker manifest push --purge rocketpool/treegen:$VERSION
docker manifest push --purge rocketpool/treegen:latest
echo "done!"
}
# Print usage
usage() {
echo "Usage: build-release.sh [options] -v <version number>"
echo "This script builds treegen's artifacts."
echo "Options:"
echo $'\t-a\tBuild all of the artifacts.'
echo $'\t-b\tBuild the native binaries for most Linux distributions'
echo $'\t-d\tBuild the Alpine-based Docker containers'
echo $'\t-m\tBuild the Docker manifest'
exit 0
}
# =================
# === Main Body ===
# =================
# Get the version
while getopts "abdmv:" FLAG; do
case "$FLAG" in
a) BINARIES=true DOCKER=true MANIFEST=true ;;
b) BINARIES=true ;;
d) DOCKER=true ;;
m) MANIFEST=true ;;
v) VERSION="$OPTARG" ;;
*) usage ;;
esac
done
if [ -z "$VERSION" ]; then
usage
fi
# Build the artifacts
if [ "$BINARIES" = true ]; then
build_binary
fi
if [ "$DOCKER" = true ]; then
build_docker
fi
if [ "$MANIFEST" = true ]; then
build_manifest
fi