Files
sos/publish.sh
2025-08-09 19:48:12 +12:00

53 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
ARCH=$(uname -m)
PROJECT="sos"
function heading() {
# print a heading with a line of dashe
echo "--------------------------------"
echo "$1"
echo "--------------------------------"
}
#--------------------------------------------------------------------------------
heading "Publishing ${PROJECT} as tool to ${PROJECT}:${ARCH} (on getpkg.xyz)"
# Copy the tool to the tool directory
TOOLDIR="${SCRIPT_DIR}/tool"
mkdir -p "${TOOLDIR}"
cp "${SCRIPT_DIR}/${PROJECT}" "${TOOLDIR}/${PROJECT}"
# Replace version placeholder with actual timestamp
VERSION=$(date -u +"%Y.%m%d.%H%M")
sed -i "s/__VERSION_PLACEHOLDER__/${VERSION}/g" "${TOOLDIR}/${PROJECT}"
# Print the version of the tool
echo "Version of the tool:"
"${TOOLDIR}/${PROJECT}" version
# Use getpkg to publish the tool
GETPKG="${SCRIPT_DIR}/../getpkg/output/getpkg"
if [ ! -f "$GETPKG" ]; then
GETPKG="${SCRIPT_DIR}/../getpkg/getpkg"
fi
if [ -f "$GETPKG" ]; then
"${GETPKG}" publish "${PROJECT}:${ARCH}" "${TOOLDIR}"
else
echo "Warning: getpkg not found, skipping tool publishing to getpkg.xyz"
fi
#--------------------------------------------------------------------------------
# run sos to upload sos, using the version with the datestamp.
"${SCRIPT_DIR}/sos" upload "getbin.xyz" "${TOOLDIR}/sos" "sos:latest"
#--------------------------------------------------------------------------------
# Clean up tool directory
rm -rf "${TOOLDIR}"