Update publish
This commit is contained in:
43
publish.sh
43
publish.sh
@@ -1,10 +1,8 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
ARCH=$(uname -m)
|
ARCH=$(uname -m)
|
||||||
PROJECT="dehydrate"
|
PROJECT="$(basename "${SCRIPT_DIR}")"
|
||||||
OUTPUT="${SCRIPT_DIR}/output"
|
OUTPUT="${SCRIPT_DIR}/output"
|
||||||
|
|
||||||
|
|
||||||
@@ -36,38 +34,23 @@ heading "Building ${PROJECT}"
|
|||||||
# build release version
|
# build release version
|
||||||
export CMAKE_BUILD_TYPE="Release"
|
export CMAKE_BUILD_TYPE="Release"
|
||||||
"${SCRIPT_DIR}/build.sh"
|
"${SCRIPT_DIR}/build.sh"
|
||||||
|
|
||||||
[ -f "${OUTPUT}/${PROJECT}" ] || die "Build failed."
|
[ -f "${OUTPUT}/${PROJECT}" ] || die "Build failed."
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------
|
# install getpkg
|
||||||
SOS="${SCRIPT_DIR}/../sos/sos"
|
GETPKG_PATH="${HOME}/.local/bin/getpkg/getpkg"
|
||||||
[ -f "${SOS}" ] || die "Failed to find sos"
|
if [ ! -f "${GETPKG_PATH}" ]; then
|
||||||
|
heading "Installing getpkg"
|
||||||
|
curl https://getbin.xyz/getpkg-install | bash
|
||||||
|
if [ ! -f "${GETPKG_PATH}" ]; then
|
||||||
|
die "getpkg failed to install to ${GETPKG_PATH}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
#--------------------------------------------------------------------------------
|
#--------------------------------------------------------------------------------
|
||||||
heading "Uploading ${PROJECT} to getbin.xyz"
|
heading "Publishing ${PROJECT} as tool to ${PROJECT}:${ARCH} (on getpkg.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.xyz"
|
|
||||||
|
|
||||||
# Create tool directory structure
|
|
||||||
TOOLDIR="${OUTPUT}/tool"
|
TOOLDIR="${OUTPUT}/tool"
|
||||||
mkdir "${TOOLDIR}"
|
mkdir "${TOOLDIR}"
|
||||||
cp "${OUTPUT}/${PROJECT}" "${TOOLDIR}/${PROJECT}"
|
cp "${OUTPUT}/${PROJECT}" "${TOOLDIR}/${PROJECT}"
|
||||||
|
"${GETPKG_PATH}" server set-token getpkg.xyz "${SOS_WRITE_TOKEN}"
|
||||||
# Use getpkg to publish the tool
|
"${GETPKG_PATH}" publish "${PROJECT}:${ARCH}" "${TOOLDIR}"
|
||||||
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
|
|
||||||
|
Reference in New Issue
Block a user