mirror of
https://git.asonix.dog/asonix/relay.git
synced 2024-11-25 19:11:08 +00:00
61 lines
1.3 KiB
Bash
Executable file
61 lines
1.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
TAG=$1
|
|
|
|
function require() {
|
|
if [ "$1" = "" ]; then
|
|
echo "input '$2' required"
|
|
print_help
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
function print_help() {
|
|
echo "build.sh"
|
|
echo ""
|
|
echo "Usage:"
|
|
echo " build.sh [tag]"
|
|
echo ""
|
|
echo "Args:"
|
|
echo " tag: The git tag to create and publish"
|
|
}
|
|
|
|
function build_image() {
|
|
repo=$1
|
|
tag=$2
|
|
arch=$3
|
|
|
|
sudo docker build \
|
|
--pull \
|
|
--build-arg TAG="${tag}" \
|
|
-f "Dockerfile.${arch}" \
|
|
-t "${repo}:${tag}-${arch}" \
|
|
-t "${repo}:latest-${arch}" \
|
|
.
|
|
|
|
sudo docker push "${repo}:${tag}-${arch}"
|
|
sudo docker push "${repo}:latest-${arch}"
|
|
}
|
|
|
|
require "$TAG" "tag"
|
|
|
|
if ! sudo docker run --rm -it arm64v8/ubuntu:19.10 /bin/bash -c 'echo "docker is configured correctly"'; then
|
|
echo "docker is not configured to run on qemu-emulated architectures"
|
|
sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
|
fi
|
|
|
|
set -xe
|
|
|
|
git checkout main
|
|
git commit -m "Version $TAG" || true
|
|
git tag $TAG
|
|
|
|
git push origin $TAG
|
|
git push
|
|
|
|
build_image "asonix/relay" "$TAG" "arm64v8"
|
|
build_image "asonix/relay" "$TAG" "arm32v7"
|
|
build_image "asonix/relay" "$TAG" "amd64"
|
|
|
|
./manifest.sh "asonix/relay" "$TAG"
|
|
./manifest.sh "asonix/relay" "latest"
|