Files
simple-object-server/publish.sh
Your Name 50160b8d6c
Some checks failed
Build-Test-Publish / build (push) Has been cancelled
'Generic Commit'
2025-06-14 22:31:44 +12:00

66 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
echo "Publishing simple-object-server to gitea.jde.nz/public/simple-object-server:latest"
PROJECT="simple-object-server"
# 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() {
title "error: $1"
exit 1
}
# Create buildx builder if it doesn't exist
docker buildx create --name ${PROJECT}-multiarch --use \
--driver-opt env.BUILDKIT_MAX_PARALLELISM=4 \
2>/dev/null || docker buildx use ${PROJECT}-multiarch
function build() {
local PLATFORM="$1"
# convert linux/amd64 to linux-amd64, windows/amd64 to windows-amd64, etc.
local OSARCH="${PLATFORM//\//-}"
title "Building ${PROJECT} for ${PLATFORM}"
docker buildx build \
-t "gitea.jde.nz/public/${PROJECT}-build:latest" \
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
--build-arg PROJECT="${PROJECT}" \
--build-arg CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
--output "${SCRIPT_DIR}/output/${OSARCH}" \
--platform "${PLATFORM}" \
"${SCRIPT_DIR}"
mv "${SCRIPT_DIR}/output/${OSARCH}/${PROJECT}" "${SCRIPT_DIR}/output/${PROJECT}-${OSARCH}"
rm -rf "${SCRIPT_DIR}/output/${OSARCH}"
}
CMAKE_BUILD_TYPE="Release"
rm -rf "${SCRIPT_DIR}/output"
mkdir -p "${SCRIPT_DIR}/output"
build "linux/amd64"
build "linux/arm64"
# Temporarily disabled - Windows cross-compilation needs different approach
# build "windows/amd64"