diff --git a/.gitea/workflows/BuildTestPublish.yaml b/.gitea/workflows/BuildTestPublish.yaml index 7039fd0..a69fcf1 100644 --- a/.gitea/workflows/BuildTestPublish.yaml +++ b/.gitea/workflows/BuildTestPublish.yaml @@ -13,6 +13,7 @@ jobs: matrix: platform: - linux/amd64 + - linux/arm64 runs-on: ${{ matrix.platform }} steps: - name: Checkout diff --git a/publish.sh b/publish.sh index 661730a..7ed2fcc 100755 --- a/publish.sh +++ b/publish.sh @@ -2,19 +2,57 @@ set -euo pipefail -#set projec to the folder this script is in. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -PROJECT=$(basename "$SCRIPT_DIR") -SOS_DIR="${SCRIPT_DIR}/../sos" -# run sos to upload sos -"${SOS_DIR}/sos" upload "getbin.xyz" "${SCRIPT_DIR}/${PROJECT}" "${PROJECT}:latest" +ARCH=$(uname -m) +PROJECT="sos" -# publish the tool -GETPKG="${SCRIPT_DIR}/../getpkg/output/getpkg" -[ -f "${GETPKG}" ] || die "Failed to find getpkg" +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}" -"${GETPKG}" publish "${PROJECT}" "${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}"