Files
simple-object-server/.runner/publish.sh
Your Name ce3a0455a3
Some checks failed
Build-Test-Publish / Build (push) Failing after 24s
:-'Generic Commit'
2025-05-30 19:39:14 +12:00

66 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# Exit on error
set -e
# DIRECTORIES
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
MAIN_DIR=$(cd "${SCRIPT_DIR}/.." && pwd)
EXE_DIR="${MAIN_DIR}/output"
# FUNCTIONS
function title() {
echo "----------------------------------------"
# Center the text
local text="$1"
local line_length=40
local text_length=${#text}
local padding=$(( (line_length - text_length) / 2 ))
printf "%*s%s%*s\n" $padding "" "$text" $padding ""
echo "----------------------------------------"
}
function die() {
echo " "
title "$1"
echo " "
exit 1
}
#--------------------------------
# MAIN
#--------------------------------
PREV_DIR=$(pwd)
cd "$MAIN_DIR"
# build the executables
./build.sh all
# push the Docker image to the registry
if [ ! -f "${EXE_DIR}/simple_object_storage.amd64" ]; then
die "amd64 executable not found"
fi
if [ ! -f "${EXE_DIR}/simple_object_storage.arm64" ]; then
die "arm64 executable not found"
fi
# if the builder doesn't exist, create it
if ! docker buildx ls | grep -q "sos-builder"; then
docker buildx create --name sos-builder --use
else
docker buildx use sos-builder
fi
echo "Building multi-platform Docker image"
docker buildx build --push -t gitea.jde.nz/public/simple-object-storage:latest --platform linux/amd64,linux/arm64 .
echo "Build completed successfully!"
# switch back to the default builder
docker buildx use default
cd "$PREV_DIR"