11#! /bin/bash
22
33# This script will build all of the artifacts involved in a new Smart Node release.
4- # NOTE: You MUST put this in a directory that has the `smartnode` repository cloned as a subdirectory.
54
65# =================
76# === Functions ===
@@ -19,78 +18,57 @@ fail() {
1918
2019# Builds all of the CLI binaries
2120build_cli () {
22- cd smartnode || fail " Directory ${PWD} /smartnode does not exist or you don't have permissions to access it."
23-
2421 echo -n " Building CLI binaries... "
25- docker buildx build --rm -f docker/cli.dockerfile --output ../$VERSION --target cli . || fail " Error building CLI binaries."
26- # rm -rf rocketpool-cli/build
22+ docker buildx build --rm -f docker/cli.dockerfile --output build/$VERSION --target cli . || fail " Error building CLI binaries."
2723 echo " done!"
28-
29- cd ..
3024}
3125
3226
3327# Builds the smart node distro packages
3428build_distro_packages () {
35- cd smartnode || fail " Directory ${PWD} /smartnode does not exist or you don't have permissions to access it."
36-
3729 echo -n " Building deb packages..."
38- docker buildx build --rm -f install/packages/debian/package.dockerfile --output .. /$VERSION --target package . || fail " Error building deb packages."
39- rm .. /$VERSION /* .build .. /$VERSION /* .buildinfo .. /$VERSION /* .changes
30+ docker buildx build --rm -f install/packages/debian/package.dockerfile --output build /$VERSION --target package . || fail " Error building deb packages."
31+ rm build /$VERSION /* .build build /$VERSION /* .buildinfo build /$VERSION /* .changes
4032 echo " done!"
41-
42- cd ..
4333}
4434
4535
4636# Builds the .tar.xz file packages with the RP configuration files
4737build_install_packages () {
48- cd smartnode || fail " Directory ${PWD} /smartnode does not exist or you don't have permissions to access it."
49- rm -f smartnode-install.tar.xz
50-
5138 echo -n " Building Smart Node installer packages... "
52- tar cfJ smartnode-install.tar.xz install/deploy || fail " Error building installer package."
53- mv smartnode-install.tar.xz ../$VERSION
54- cp install/install.sh ../$VERSION
55- cp install/install-update-tracker.sh ../$VERSION
39+ tar cfJ build/$VERSION /smartnode-install.tar.xz install/deploy || fail " Error building installer package."
40+ cp install/install.sh build/$VERSION
41+ cp install/install-update-tracker.sh build/$VERSION
5642 echo " done!"
5743
5844 echo -n " Building update tracker package... "
59- tar cfJ rp-update-tracker.tar.xz install/rp-update-tracker || fail " Error building update tracker package."
60- mv rp-update-tracker.tar.xz ../$VERSION
45+ tar cfJ build/$VERSION /rp-update-tracker.tar.xz install/rp-update-tracker || fail " Error building update tracker package."
6146 echo " done!"
62-
63- cd ..
6447}
6548
6649
6750# Builds the daemon binaries and Docker Smart Node images, and pushes them to Docker Hub
6851# NOTE: You must install qemu first; e.g. sudo apt-get install -y qemu qemu-user-static
6952build_daemon () {
70- cd smartnode || fail " Directory ${PWD} /smartnode does not exist or you don't have permissions to access it."
71-
7253 echo " Building Smart Node daemon binaries..."
73- docker buildx build --rm --platform=linux/amd64,linux/arm64 -f docker/daemon-build.dockerfile --output .. /$VERSION --target daemon . || fail " Error building Smart Node daemon binaries."
54+ docker buildx build --rm --platform=linux/amd64,linux/arm64 -f docker/daemon-build.dockerfile --output build /$VERSION --target daemon . || fail " Error building Smart Node daemon binaries."
7455 echo " done!"
7556
76- # Copy the daemon binaries to a build folder so the image can access them
77- mkdir -p ./build
78- cp ../$VERSION /linux_amd64/* ./build
79- cp ../$VERSION /linux_arm64/* ./build
80- echo " done!"
57+ # Flatted the folders to make it easier to upload artifacts to github
58+ mv build/$VERSION /linux_amd64/rocketpool-daemon build/$VERSION /rocketpool-daemon-linux-amd64
59+ mv build/$VERSION /linux_arm64/rocketpool-daemon build/$VERSION /rocketpool-daemon-linux-arm64
60+
61+ # Clean up the empty directories
62+ rmdir build/$VERSION /linux_amd64 build/$VERSION /linux_arm64
8163
8264 echo " Building Smart Node Docker image..."
83- docker buildx build --rm --platform=linux/amd64,linux/arm64 -t rocketpool/smartnode:$VERSION -f docker/daemon.dockerfile --push . || fail " Error building Smart Node Docker image."
65+ # If uploading, make and push a manifest
66+ if [ " $UPLOAD " = true ]; then
67+ docker buildx build --rm --platform=linux/amd64,linux/arm64 --build-arg BINARIES_PATH=build/$VERSION -t rocketpool/smartnode:$VERSION -f docker/daemon.dockerfile --push . || fail " Error building Smart Node Docker image."
68+ else
69+ docker buildx build --rm --load --build-arg BINARIES_PATH=build/$VERSION -t rocketpool/smartnode:$VERSION -f docker/daemon.dockerfile . || fail " Error building Smart Node Docker image."
70+ fi
8471 echo " done!"
85-
86- # Cleanup
87- mv ../$VERSION /linux_amd64/* ../$VERSION
88- mv ../$VERSION /linux_arm64/* ../$VERSION
89- rm -rf ../$VERSION /linux_amd64/
90- rm -rf ../$VERSION /linux_arm64/
91- rm -rf ./build
92-
93- cd ..
9472}
9573
9674
@@ -100,9 +78,13 @@ build_latest_docker_manifest() {
10078 docker tag rocketpool/smartnode:$VERSION rocketpool/smartnode:latest
10179 echo " done!"
10280
103- echo -n " Pushing to Docker Hub... "
104- docker push rocketpool/smartnode:latest
105- echo " done!"
81+ if [ " $UPLOAD " = true ]; then
82+ echo -n " Pushing to Docker Hub... "
83+ docker push rocketpool/smartnode:latest
84+ echo " done!"
85+ else
86+ echo " The image tag only exists locally. Rerun with -u to upload to Docker Hub."
87+ fi
10688}
10789
10890
@@ -115,8 +97,9 @@ usage() {
11597 echo $' \t -c\t Build the CLI binaries for all platforms'
11698 echo $' \t -t\t Build the distro packages (.deb)'
11799 echo $' \t -p\t Build the Smart Node installer packages'
118- echo $' \t -d\t Build the Smart Node Daemon image, and push it to Docker Hub'
119- echo $' \t -l\t Tag the Docker image as "latest" and push it to Docker Hub'
100+ echo $' \t -d\t Build the Smart Node Daemon image'
101+ echo $' \t -l\t Tag the Docker image as "latest"'
102+ echo $' \t -u\t When passed with a build, upload the resulting image tags to Docker Hub'
120103 exit 0
121104}
122105
@@ -126,14 +109,15 @@ usage() {
126109# =================
127110
128111# Parse arguments
129- while getopts " actpdlv :" FLAG; do
112+ while getopts " actpdluv :" FLAG; do
130113 case " $FLAG " in
131114 a) CLI=true DISTRO=true PACKAGES=true DAEMON=true ;;
132115 c) CLI=true ;;
133116 t) DISTRO=true ;;
134117 p) PACKAGES=true ;;
135118 d) DAEMON=true ;;
136119 l) LATEST_MANIFEST=true ;;
120+ u) UPLOAD=true ;;
137121 v) VERSION=" $OPTARG " ;;
138122 * ) usage ;;
139123 esac
@@ -143,8 +127,8 @@ if [ -z "$VERSION" ]; then
143127fi
144128
145129# Cleanup old artifacts
146- rm -f . /$VERSION /*
147- mkdir -p . /$VERSION
130+ rm -rf build /$VERSION /*
131+ mkdir -p build /$VERSION
148132
149133# Make a multiarch builder, ignore if it's already there
150134docker buildx create --name multiarch-builder --driver docker-container --use > /dev/null 2>&1
173157
174158# Builds the deb package builder image
175159build_deb_builder () {
176- cd smartnode || fail " Directory ${PWD} /smartnode does not exist or you don't have permissions to access it."
177-
178160 echo -n " Building deb builder..."
179161 docker buildx build --rm --platform=linux/amd64,linux/arm64 -t rocketpool/smartnode-deb-builder:$VERSION -f install/packages/debian/builder.dockerfile --push . || fail " Error building deb builder."
180162 echo " done!"
181-
182- cd ..
183163}
184164
185165
186166# Builds the prune provisioner image and pushes it to Docker Hub
187167build_docker_prune_provision () {
188- cd smartnode || fail " Directory ${PWD} /smartnode does not exist or you don't have permissions to access it."
189-
190168 echo " Building Prune Provisioner image..."
191169 docker buildx build --platform=linux/amd64,linux/arm64 -t rocketpool/eth1-prune-provision:$VERSION -f util-containers/prune-provision.dockerfile --push . || fail " Error building Prune Provision image."
192170 echo " done!"
193-
194- cd ..
195171}
196172
197173
198174# Builds the EC migrator image and pushes it to Docker Hub
199175build_ec_migrator () {
200- cd smartnode || fail " Directory ${PWD} /smartnode does not exist or you don't have permissions to access it."
201-
202176 echo " Building EC Migrator image..."
203177 docker buildx build --platform=linux/amd64,linux/arm64 -t rocketpool/ec-migrator:$VERSION -f util-containers/ec-migrator.dockerfile --push . || fail " Error building EC Migrator image."
204178 echo " done!"
205-
206- cd ..
207179}
208-
209- # Builds the Docker prune starter image and pushes it to Docker Hub
210- # TODO: Move this to the NPS repo
211- build_docker_prune_starter () {
212- cd NethermindPruneStarter || fail " Directory ${PWD} /smartnode does not exist or you don't have permissions to access it."
213-
214- echo " Building Docker Prune Starter image..."
215- docker buildx build --platform=linux/amd64,linux/arm64 -t rocketpool/nm-prune-starter:$VERSION -f docker/rocketpool-nm-prune-starter --push . || fail " Error building Docker Prune Starter image."
216- echo " done!"
217-
218- cd ..
219- }
0 commit comments