Files
gp/publish.sh
Your Name 671189120a
Some checks failed
Build-Test-Publish / build (linux/amd64) (push) Failing after 7s
Build-Test-Publish / build (linux/arm64) (push) Failing after 8s
Update publish.sh
2025-08-24 16:11:12 +12:00

59 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
ARCH=$(uname -m)
PROJECT="gp"
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)"
# Generate version timestamp
VERSION=$(date -u +"%Y.%m%d.%H%M")
# Update version in the main sos script
echo "Updating version in main ${PROJECT} script to ${VERSION}..."
sed -i "s/^VERSION=\".*\"/VERSION=\"${VERSION}\"/" "${SCRIPT_DIR}/${PROJECT}"
# Copy the tool to the tool directory
TOOLDIR="${SCRIPT_DIR}/tool"
mkdir -p "${TOOLDIR}"
cp "${SCRIPT_DIR}/${PROJECT}" "${TOOLDIR}/${PROJECT}"
# Print the version of the tool
echo "Version of the tool:"
"${TOOLDIR}/${PROJECT}" version
# Use getpkg to publish the tool - check standard location first
GETPKG="${HOME}/.local/bin/getpkg/getpkg"
if [ ! -f "$GETPKG" ]; then
GETPKG="${SCRIPT_DIR}/../getpkg/output/getpkg"
fi
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}"