forked from rocket-pool/smartnode-install
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-release.sh
247 lines (200 loc) · 9.69 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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
#!/bin/bash
# This script will build all of the artifacts involved in a new Rocket Pool smartnode release
# (except for the macOS daemons, which need to be built manually on a macOS system) and put
# them into a convenient folder for ease of uploading.
# NOTE: You MUST put this in a directory that has the `smartnode` and `smartnode-install`
# repositories cloned as subdirectories.
# =================
# === Functions ===
# =================
# Print a failure message to stderr and exit
fail() {
MESSAGE=$1
RED='\033[0;31m'
RESET='\033[;0m'
>&2 echo -e "\n${RED}**ERROR**\n$MESSAGE${RESET}\n"
exit 1
}
# Builds all of the CLI binaries
build_cli() {
cd smartnode || fail "Directory ${PWD}/smartnode/rocketpool-cli does not exist or you don't have permissions to access it."
echo -n "Building CLI binaries... "
docker run --rm -v $PWD:/smartnode rocketpool/smartnode-builder:latest /smartnode/rocketpool-cli/build.sh || fail "Error building CLI binaries."
mv rocketpool-cli/rocketpool-cli-* ../$VERSION
echo "done!"
cd ..
}
# Builds the .tar.xz file packages with the RP configuration files
build_install_packages() {
cd smartnode-install || fail "Directory ${PWD}/smartnode-install does not exist or you don't have permissions to access it."
rm -f rp-smartnode-install.tar.xz
echo -n "Building Smartnode installer packages... "
tar cfJ rp-smartnode-install.tar.xz install || fail "Error building installer package."
mv rp-smartnode-install.tar.xz ../$VERSION
cp install.sh ../$VERSION
cp install-update-tracker.sh ../$VERSION
echo "done!"
echo -n "Building update tracker package... "
tar cfJ rp-update-tracker.tar.xz rp-update-tracker || fail "Error building update tracker package."
mv rp-update-tracker.tar.xz ../$VERSION
echo "done!"
cd ..
}
# Builds the daemon binaries and Docker Smartnode images, and pushes them to Docker Hub
# NOTE: You must install qemu first; e.g. sudo apt-get install -y qemu qemu-user-static
build_daemon() {
cd smartnode || fail "Directory ${PWD}/smartnode does not exist or you don't have permissions to access it."
echo -n "Building Daemon binary... "
./daemon-build.sh || fail "Error building daemon binary."
cp rocketpool/rocketpool-daemon-* ../$VERSION
echo "done!"
echo "Building Docker Smartnode image..."
docker buildx build --platform=linux/amd64 -t rocketpool/smartnode:$VERSION-amd64 -f docker/rocketpool-dockerfile --load . || fail "Error building amd64 Docker Smartnode image."
docker buildx build --platform=linux/arm64 -t rocketpool/smartnode:$VERSION-arm64 -f docker/rocketpool-dockerfile --load . || fail "Error building arm64 Docker Smartnode image."
echo "done!"
echo -n "Pushing to Docker Hub... "
docker push rocketpool/smartnode:$VERSION-amd64 || fail "Error pushing amd64 Docker Smartnode image to Docker Hub."
docker push rocketpool/smartnode:$VERSION-arm64 || fail "Error pushing arm Docker Smartnode image to Docker Hub."
rm -f rocketpool/rocketpool-daemon-*
echo "done!"
cd ..
}
# Builds the Docker prune provisioner image and pushes it to Docker Hub
build_docker_prune_provision() {
cd smartnode || fail "Directory ${PWD}/smartnode does not exist or you don't have permissions to access it."
echo "Building Docker Prune Provisioner image..."
docker buildx build --platform=linux/amd64 -t rocketpool/eth1-prune-provision:$VERSION-amd64 -f docker/rocketpool-prune-provision --load . || fail "Error building amd64 Docker Prune Provision image."
docker buildx build --platform=linux/arm64 -t rocketpool/eth1-prune-provision:$VERSION-arm64 -f docker/rocketpool-prune-provision --load . || fail "Error building arm64 Docker Prune Provision image."
echo "done!"
echo -n "Pushing to Docker Hub... "
docker push rocketpool/eth1-prune-provision:$VERSION-amd64 || fail "Error pushing amd64 Docker Prune Provision image to Docker Hub."
docker push rocketpool/eth1-prune-provision:$VERSION-arm64 || fail "Error pushing arm Docker Prune Provision image to Docker Hub."
echo "done!"
cd ..
}
# Builds the Docker Manifests and pushes them to Docker Hub
build_docker_manifest() {
echo -n "Building Docker manifest... "
rm -f ~/.docker/manifests/docker.io_rocketpool_smartnode-$VERSION
docker manifest create rocketpool/smartnode:$VERSION --amend rocketpool/smartnode:$VERSION-amd64 --amend rocketpool/smartnode:$VERSION-arm64
echo "done!"
echo -n "Pushing to Docker Hub... "
docker manifest push --purge rocketpool/smartnode:$VERSION
echo "done!"
}
# Builds the 'latest' Docker Manifests and pushes them to Docker Hub
build_latest_docker_manifest() {
echo -n "Building 'latest' Docker manifest... "
rm -f ~/.docker/manifests/docker.io_rocketpool_smartnode-latest
docker manifest create rocketpool/smartnode:latest --amend rocketpool/smartnode:$VERSION-amd64 --amend rocketpool/smartnode:$VERSION-arm64
echo "done!"
echo -n "Pushing to Docker Hub... "
docker manifest push --purge rocketpool/smartnode:latest
echo "done!"
}
# Builds the Docker Manifest for the prune provisioner and pushes it to Docker Hub
build_docker_prune_provision_manifest() {
echo -n "Building Docker Prune Provision manifest... "
rm -f ~/.docker/manifests/docker.io_rocketpool_eth1-prune-provision-$VERSION
docker manifest create rocketpool/eth1-prune-provision:$VERSION --amend rocketpool/eth1-prune-provision:$VERSION-amd64 --amend rocketpool/eth1-prune-provision:$VERSION-arm64
echo "done!"
echo -n "Pushing to Docker Hub... "
docker manifest push --purge rocketpool/eth1-prune-provision:$VERSION
echo "done!"
}
# Builds the Docker prune starter image and pushes it to Docker Hub
build_docker_prune_starter() {
cd NethermindPruneStarter || fail "Directory ${PWD}/smartnode does not exist or you don't have permissions to access it."
echo "Building Docker Prune Starter image..."
docker buildx build --platform=linux/amd64 -t rocketpool/nm-prune-starter:$VERSION-amd64 -f docker/rocketpool-nm-prune-starter --load . || fail "Error building amd64 Docker Prune Starter image."
docker buildx build --platform=linux/arm64 -t rocketpool/nm-prune-starter:$VERSION-arm64 -f docker/rocketpool-nm-prune-starter --load . || fail "Error building arm64 Docker Prune Starter image."
echo "done!"
echo -n "Pushing to Docker Hub... "
docker push rocketpool/nm-prune-starter:$VERSION-amd64 || fail "Error pushing amd64 Docker Prune Starter image to Docker Hub."
docker push rocketpool/nm-prune-starter:$VERSION-arm64 || fail "Error pushing arm Docker Prune Starter image to Docker Hub."
echo "done!"
cd ..
}
# Builds the Docker Manifest for the nm prune starter and pushes it to Docker Hub
build_docker_prune_starter_manifest() {
echo -n "Building Docker Prune Starter manifest... "
rm -f ~/.docker/manifests/docker.io_rocketpool_nm-prune-starter-$VERSION
docker manifest create rocketpool/nm-prune-starter:$VERSION --amend rocketpool/nm-prune-starter:$VERSION-amd64 --amend rocketpool/nm-prune-starter:$VERSION-arm64
docker manifest create rocketpool/nm-prune-starter:latest --amend rocketpool/nm-prune-starter:$VERSION-amd64 --amend rocketpool/nm-prune-starter:$VERSION-arm64
echo "done!"
echo -n "Pushing to Docker Hub... "
docker manifest push --purge rocketpool/nm-prune-starter:$VERSION
docker manifest push --purge rocketpool/nm-prune-starter:latest
echo "done!"
}
# Print usage
usage() {
echo "Usage: build-release.sh [options] -v <version number>"
echo "This script assumes it is in a directory that contains subdirectories for all of the Rocket Pool repositories."
echo "Options:"
echo $'\t-a\tBuild all of the artifacts, except for the prune provisioner'
echo $'\t-c\tBuild the CLI binaries for all platforms'
echo $'\t-p\tBuild the Smartnode installer packages'
echo $'\t-d\tBuild the Daemon binaries and Docker Smartnode images, and push them to Docker Hub'
echo $'\t-x\tBuild the Docker POW Proxy image and push it to Docker Hub'
echo $'\t-n\tBuild the Docker manifests (Smartnode and POW Proxy), and push them to Docker Hub'
echo $'\t-r\tBuild the Docker Prune Provisioner image and push it to Docker Hub'
echo $'\t-f\tBuild the Docker manifest for the Prune Provisioner and push it to Docker Hub'
echo $'\t-t\tBuild the Docker Prune Starter image and push it to Docker Hub'
echo $'\t-s\tBuild the Docker manifest for the Prune Starter and push it to Docker Hub'
exit 0
}
# =================
# === Main Body ===
# =================
# Parse arguments
while getopts "acpdnlrftsv:" FLAG; do
case "$FLAG" in
a) CLI=true PACKAGES=true DAEMON=true MANIFEST=true LATEST_MANIFEST=true ;;
c) CLI=true ;;
p) PACKAGES=true ;;
d) DAEMON=true ;;
n) MANIFEST=true ;;
l) LATEST_MANIFEST=true ;;
r) PRUNE=true ;;
t) STARTER=true ;;
s) PRUNE_STARTER_MANIFEST=true ;;
f) PRUNE_MANIFEST=true ;;
v) VERSION="$OPTARG" ;;
*) usage ;;
esac
done
if [ -z "$VERSION" ]; then
usage
fi
# Cleanup old artifacts
rm -f ./$VERSION/*
mkdir -p ./$VERSION
# Build the artifacts
if [ "$CLI" = true ]; then
build_cli
fi
if [ "$PACKAGES" = true ]; then
build_install_packages
fi
if [ "$DAEMON" = true ]; then
build_daemon
fi
if [ "$MANIFEST" = true ]; then
build_docker_manifest
fi
if [ "$LATEST_MANIFEST" = true ]; then
build_latest_docker_manifest
fi
if [ "$PRUNE" = true ]; then
build_docker_prune_provision
fi
if [ "$PRUNE_MANIFEST" = true ]; then
build_docker_prune_provision_manifest
fi
if [ "$STARTER" = true ]; then
build_docker_prune_starter
fi
if [ "$PRUNE_STARTER_MANIFEST" = true ]; then
build_docker_prune_starter_manifest
fi