Files
getpkg/getpkg/publish.sh
Your Name ce10325a7f
Some checks failed
Build-Test-Publish / build (push) Failing after 11s
'Generic Commit'
2025-06-22 09:42:54 +12:00

75 lines
2.1 KiB
Bash
Executable File

set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
ARCH=$(uname -m)
PROJECT="getpkg"
OUTPUT="${SCRIPT_DIR}/output"
function heading() {
# print a heading with a line of dashe
echo "--------------------------------"
echo "$1"
echo "--------------------------------"
}
#--------------------------------------------------------------------------------
heading "Publishing ${PROJECT}"
function die() {
title "error: $1"
exit 1
}
[[ -n $SOS_WRITE_TOKEN ]] || die "SOS_WRITE_TOKEN not specified"
# clear output dir
rm -rf "${OUTPUT}"
mkdir -p "${OUTPUT}"
#--------------------------------------------------------------------------------
heading "Building ${PROJECT}"
# build release version
export CMAKE_BUILD_TYPE="Release"
docker build \
-t "${PROJECT}-build" \
-f "${SCRIPT_DIR}/Dockerfile.dropshell-build" \
--build-arg PROJECT="${PROJECT}" \
--build-arg CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \
--output "${OUTPUT}" \
"${SCRIPT_DIR}"
[ -f "${OUTPUT}/${PROJECT}" ] || die "Build failed."
#--------------------------------------------------------------------------------
heading "Downloading SOS"
# download the sos binary
TEMP_DIR="${OUTPUT}/temp"
SOS="${TEMP_DIR}/sos"
mkdir -p "${TEMP_DIR}"
trap 'rm -rf "${TEMP_DIR}"' EXIT
curl -L -o "${SOS}" "https://getbin.xyz/sos"
[ -f "${SOS}" ] || die "Failed to download sos"
chmod +x "${SOS}"
#--------------------------------------------------------------------------------
heading "Uploading ${PROJECT} to getbin.xyz"
# upload arch-specific binary
"${SOS}" upload "getbin.xyz" "${OUTPUT}/${PROJECT}" "${PROJECT}:latest-${ARCH}"
# 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"
#--------------------------------------------------------------------------------
heading "Publishing ${PROJECT} as tool to getpkg:${ARCH} (on getpkg.xyz)"
TOOLDIR="${OUTPUT}/tool"
mkdir "${TOOLDIR}"
cp "${OUTPUT}/${PROJECT}" "${TOOLDIR}/${PROJECT}"
"${OUTPUT}/${PROJECT}" publish "getpkg:${ARCH}" "${TOOLDIR}"