From e2883c45e0f649fd80eec3fd520d7f6df69b3e51 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 14 Jun 2025 23:26:33 +1200 Subject: [PATCH] 'Generic Commit' --- README.md | 8 ++++++++ install.sh | 36 ++++++++++++++++++++++++++++++++++++ publish.sh | 33 +++++++++++++++++++++++++++------ 3 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 install.sh diff --git a/README.md b/README.md index ddf99e1..2b6f748 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,14 @@ A simple object storage system that stores files with metadata and provides a REST API for access. + +## Install + +To install the latest version of simple-object-server, run: +```bash +curl https://getbin.xyz/simple-object-server-install:latest | bash +``` + ## Features - Store files with metadata (label:tag pairs and custom fields) diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..8a94c46 --- /dev/null +++ b/install.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Get script directory +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" + +PROJECT="simple-object-server" + +# Set target directory - use ~/.local/bin by default, /usr/local/bin if root +if [ "$(id -u)" = "0" ]; then + TARGET_DIR="/usr/local/bin" +else + TARGET_DIR="${HOME}/.local/bin" + # Create ~/.local/bin if it doesn't exist + mkdir -p "${TARGET_DIR}" +fi + +if ! command -v wget >/dev/null 2>&1; then + echo "wget is not installed. Please install wget and try again." + exit 1 +fi + +ARCH=$(uname -m) +if [ "${ARCH}" = "x86_64" ]; then + ARCH="amd64" +elif [ "${ARCH}" = "aarch64" ]; then + ARCH="arm64" +else + echo "Unsupported architecture: ${ARCH}" + exit 1 +fi + +wget https://getbin.xyz/simple-object-server:${ARCH} -O "${TARGET_DIR}/simple-object-server" +chmod +x "${TARGET_DIR}/simple-object-server" + diff --git a/publish.sh b/publish.sh index 0a6bb89..ad2c391 100755 --- a/publish.sh +++ b/publish.sh @@ -7,7 +7,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" echo "Publishing simple-object-server to gitea.jde.nz/public/simple-object-server:latest" PROJECT="simple-object-server" - +[[ -n $SOS_WRITE_TOKEN ]] || die "SOS_WRITE_TOKEN not specified" # FUNCTIONS function title() { @@ -28,9 +28,12 @@ function die() { } # Create buildx builder if it doesn't exist -docker buildx create --name ${PROJECT}-multiarch --use \ - --driver-opt env.BUILDKIT_MAX_PARALLELISM=4 \ - 2>/dev/null || docker buildx use ${PROJECT}-multiarch +if ! docker buildx ls | grep -q "${PROJECT}-multiarch"; then + docker buildx create --name ${PROJECT}-multiarch --use \ + --driver-opt env.BUILDKIT_MAX_PARALLELISM=4 +else + docker buildx use ${PROJECT}-multiarch +fi function build() { local PLATFORM="$1" @@ -47,6 +50,8 @@ function build() { --build-arg CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}" \ --output "${SCRIPT_DIR}/output/${OSARCH}" \ --platform "${PLATFORM}" \ + --cache-from type=local,src=/tmp/.buildx-cache \ + --cache-to type=local,dest=/tmp/.buildx-cache,mode=max \ "${SCRIPT_DIR}" mv "${SCRIPT_DIR}/output/${OSARCH}/${PROJECT}" "${SCRIPT_DIR}/output/${PROJECT}-${OSARCH}" @@ -57,9 +62,25 @@ CMAKE_BUILD_TYPE="Release" rm -rf "${SCRIPT_DIR}/output" mkdir -p "${SCRIPT_DIR}/output" +mkdir -p /tmp/.buildx-cache build "linux/amd64" build "linux/arm64" -# Temporarily disabled - Windows cross-compilation needs different approach -# build "windows/amd64" +[ -f "${SCRIPT_DIR}/output/${PROJECT}-linux-amd64" ] || die "${PROJECT}-linux-amd64 not found" +[ -f "${SCRIPT_DIR}/output/${PROJECT}-linux-arm64" ] || die "${PROJECT}-linux-arm64 not found" + +# uplaod to getbin.xyz + +# # download the sos binary +SOS="${SCRIPT_DIR}/temp/sos" +mkdir -p "${SCRIPT_DIR}/temp" +trap 'rm -rf "${SCRIPT_DIR}/temp"' EXIT + +curl -L -o "${SOS}" "https://getbin.xyz/sos" +chmod +x "${SOS}" + +"${SOS}" upload "getbin.xyz" "${SCRIPT_DIR}/output/${PROJECT}-linux-amd64" "${PROJECT}:amd64" +"${SOS}" upload "getbin.xyz" "${SCRIPT_DIR}/output/${PROJECT}-linux-arm64" "${PROJECT}:arm64" + +"${SOS}" upload "getbin.xyz" "${SCRIPT_DIR}/install.sh" "simple-object-server-install:latest"