| 1 |
#!/usr/bin/env bash |
| 2 |
|
| 3 |
set -eux |
| 4 |
|
| 5 |
PATCH_FILE="other/bootstrap_daemon/docker/release.patch" |
| 6 |
trap 'rm -f "$PATCH_FILE"' EXIT |
| 7 |
|
| 8 |
RELEASE=0 |
| 9 |
while [[ $# -gt 0 ]]; do |
| 10 |
case $1 in |
| 11 |
--release) |
| 12 |
RELEASE=1 |
| 13 |
shift |
| 14 |
;; |
| 15 |
*) |
| 16 |
echo "Unknown option $1" |
| 17 |
exit 1 |
| 18 |
;; |
| 19 |
esac |
| 20 |
done |
| 21 |
|
| 22 |
if [[ $RELEASE -eq 1 ]]; then |
| 23 |
git fetch upstream |
| 24 |
RELEASE_BRANCH=$(git branch -r | grep "upstream/release/" | sort -V | tail -n1 | sed 's/^[[:space:]]*//' || true) |
| 25 |
if [[ -n "$RELEASE_BRANCH" ]]; then |
| 26 |
echo "Generating release patch from $RELEASE_BRANCH" |
| 27 |
git diff "HEAD..$RELEASE_BRANCH" -- toxcore/tox.h CMakeLists.txt >"$PATCH_FILE" |
| 28 |
else |
| 29 |
echo "No release branch found in upstream" |
| 30 |
fi |
| 31 |
fi |
| 32 |
|
| 33 |
docker_build() { |
| 34 |
DOCKER_BUILDKIT=1 docker build --progress=plain -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node . |
| 35 |
} |
| 36 |
|
| 37 |
# Run Docker build once. If it succeeds, we're good. |
| 38 |
if docker_build; then |
| 39 |
exit 0 |
| 40 |
fi |
| 41 |
|
| 42 |
# We're not good. Run it again, but now capture the output. |
| 43 |
OUTPUT=$(docker_build 2>&1 || true) |
| 44 |
|
| 45 |
if echo "$OUTPUT" | grep '/usr/local/bin/tox-bootstrapd: FAILED'; then |
| 46 |
# This is a checksum warning, so we need to update it. |
| 47 |
echo "$OUTPUT" | grep -Eo '[0-9a-f]{64} /usr/local/bin/tox-bootstrapd' | tail -n1 >other/bootstrap_daemon/docker/tox-bootstrapd.sha256 |
| 48 |
fi |
| 49 |
|
| 50 |
# Run once last time to complete the build. |
| 51 |
docker_build |