'Generic Commit'
Some checks failed
Build-Test-Publish / build (push) Failing after 9s

This commit is contained in:
Your Name
2025-06-15 18:15:45 +12:00
parent f67a1f8fe3
commit f5346eddc7
10 changed files with 397 additions and 299 deletions

View File

@ -1,59 +1,46 @@
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
TEMP_DIR=$(mktemp -d)
ARCH=$(uname -m)
TEMP_DIR="${SCRIPT_DIR}/temp"
SOS="${TEMP_DIR}/sos"
echo "Publishing ${PROJECT} to gitea.jde.nz/public/${PROJECT}:latest"
die() {
echo -e "Error: $1" >&2
function die() {
title "error: $1"
exit 1
}
function publish_tool() {
local TOOLPATH="$1"
local TOOL;
TOOL=$(basename "$TOOLPATH")
[[ -n $SOS_WRITE_TOKEN ]] || die "SOS_WRITE_TOKEN not specified"
echo "Publishing $TOOL to getbin.xyz"
echo "(from $TOOLPATH)"
# clear output dir
rm -rf "${SCRIPT_DIR}/output"
mkdir -p "${SCRIPT_DIR}/output"
"${TEMP_DIR}/sos" upload "getbin.xyz" "$TOOLPATH" "${TOOL}:latest"
}
# build release version
export CMAKE_BUILD_TYPE="Release"
export PROJECT="dropshell-tool"
function publish_executables() {
OUTPUT_DIR="${SCRIPT_DIR}/output"
docker build \
-t "${PROJECT}-build" \
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
--build-arg PROJECT="${PROJECT}" \
--build-arg CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
--output "${SCRIPT_DIR}/output" \
"${SCRIPT_DIR}"
# Find all dropshell-tool.ARCH files in output/
TOOLS=()
for tool in "${OUTPUT_DIR}"/*dropshell-tool.*; do
[ -f "$tool" ] || continue
tool_name=$(basename "$tool")
TOOLS+=("$tool_name")
done
[ -f ${SCRIPT_DIR}/output/dropshell-tool ] || die "Build failed."
if [ ${#TOOLS[@]} -eq 0 ]; then
echo "No tools found in ${SCRIPT_DIR}/output/. Exiting."
exit 1
fi
# download the sos binary
mkdir -p "${TEMP_DIR}"
trap 'rm -rf "${TEMP_DIR}"' EXIT
curl -L -o "${SOS}" "https://getbin.xyz/sos"
chmod +x "${SOS}"
for TOOL in "${TOOLS[@]}"; do
publish_tool "$OUTPUT_DIR/$TOOL"
done
}
# upload arch-specific binary
"${SOS}" upload "getbin.xyz" "${SCRIPT_DIR}/output/${PROJECT}" "${PROJECT}:latest-${ARCH}"
function getbin() {
local BIN_NAME="$1"
curl -L -s -o "${TEMP_DIR}/${BIN_NAME}" "https://getbin.xyz/${BIN_NAME}" || die "Failed to download ${BIN_NAME}"
chmod +x "${TEMP_DIR}/${BIN_NAME}"
}
getbin "sos"
publish_executables
rm -rf "${TEMP_DIR}"
echo "Done"
# upload generic install script (ok if multiple times as we iterate through arch's)
"${SOS}" upload "getbin.xyz" "${SCRIPT_DIR}/install.sh" "${PROJECT}-install:latest"