From 366f5c2d0e8c463c9da378f3ae6e1702cb8d7b32 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 2 Jun 2025 00:44:23 +1200 Subject: [PATCH] 'Generic Commit' --- dropshell-install.sh | 22 +++++ ...osetup.sh => dropshell-server-autosetup.sh | 0 install.sh | 49 ---------- source/publish.sh | 91 +++---------------- 4 files changed, 37 insertions(+), 125 deletions(-) create mode 100755 dropshell-install.sh rename server_autosetup.sh => dropshell-server-autosetup.sh (100%) delete mode 100755 install.sh diff --git a/dropshell-install.sh b/dropshell-install.sh new file mode 100755 index 0000000..8c58b95 --- /dev/null +++ b/dropshell-install.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -euo pipefail + +# download and install dropshell + +# 1. Determine architecture +# ----------------------------------------------------------------------------- + +ARCH=$(uname -m) + +TARGET_PATH="${HOME}/.local/bin/dropshell" +[ ! -f "${TARGET_PATH}" ] || rm -f "${TARGET_PATH}" +mkdir -p "$(dirname "${TARGET_PATH}")" +curl -L -s -o "${TARGET_PATH}" "https://getbin.xyz/dropshell.${ARCH}" || die "Failed to download dropshell for ${ARCH}" +chmod +x "${TARGET_PATH}" +echo "dropshell installed successfully to $TARGET_PATH" +echo " " + +echo "Please:" +echo "1. run '${TARGET_PATH} edit' to edit the configuration." +echo "2. run '${TARGET_PATH} install' to install dropshell components on this computer." +echo "3. run 'source ~/.bashrc' to add to your path and autocomplete for the current shell." diff --git a/server_autosetup.sh b/dropshell-server-autosetup.sh similarity index 100% rename from server_autosetup.sh rename to dropshell-server-autosetup.sh diff --git a/install.sh b/install.sh deleted file mode 100755 index 7cafff5..0000000 --- a/install.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -set -e - -# download and install dropshell - -# 1. Determine architecture -# ----------------------------------------------------------------------------- - -ARCH=$(uname -m) -if [[ "$ARCH" == "x86_64" ]]; then - BIN=dropshell.x86_64 -elif [[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]]; then - BIN=dropshell.aarch64 -else - echo "Unsupported architecture: $ARCH" >&2 - exit 1 -fi - - -# 2. Download the appropriate binary to a temp directory -# ----------------------------------------------------------------------------- -TMPDIR=$(mktemp -d) -trap 'rm -rf "$TMPDIR"' EXIT -URL="https://gitea.jde.nz/public/dropshell/releases/download/latest/$BIN" -echo "Downloading $BIN from $URL..." - -TARGET_PATH="${HOME}/.local/bin/dropshell" - -mkdir -p "${HOME}/.local/bin" - -curl -fsSL -o "$TARGET_PATH" "$URL" - -if [ ! -f "$TARGET_PATH" ]; then - echo "Failed to download dropshell" >&2 - exit 1 -fi - -chmod +x "$TARGET_PATH" - -if [ ! -f "${HOME}/.local/bin/ds" ]; then - ln -s "$TARGET_PATH" "${HOME}/.local/bin/ds" -fi - -echo "dropshell installed successfully to $TARGET_PATH" - -echo "Please:" -echo "1. run '${TARGET_PATH} edit' to edit the configuration." -echo "2. run '${TARGET_PATH} install' to install dropshell components on this computer." -echo "3. run 'source ~/.bashrc' to add to your path and autocomplete for the current shell." diff --git a/source/publish.sh b/source/publish.sh index 7b8b254..95405fe 100755 --- a/source/publish.sh +++ b/source/publish.sh @@ -9,74 +9,21 @@ echo "Script directory: $SCRIPT_DIR" TOKEN="${GITEA_TOKEN_DEPLOY:-${GITEA_TOKEN}}" [ -z "$TOKEN" ] && { echo "Neither GITEA_TOKEN_DEPLOY nor GITEA_TOKEN environment variable set!" >&2; exit 1; } -"$SCRIPT_DIR/multibuild.sh" -#BUILD_DIR=$SCRIPT_DIR/build - OLD_PWD="$PWD" cd "$SCRIPT_DIR" || exit 1 +TEMP_DIR=$(mktemp -d) +trap 'rm -rf "$TEMP_DIR" && cd "$OLD_PWD"' EXIT -# Check for required binaries -REQUIRED_BINARIES=("dropshell.x86_64" "dropshell.aarch64") -for binary in "${REQUIRED_BINARIES[@]}"; do - if [ ! -f "output/$binary" ]; then - echo "output/$binary not found!" >&2 - echo "Please run multibuild.sh first." >&2 - exit 1 - fi -done - -TAG=$("$SCRIPT_DIR/output/dropshell.x86_64" --version) -[ -z "$TAG" ] && echo "Failed to get version from dropshell.x86_64" >&2 && exit 1 - +ARCH=$(uname -m) +TAG=$("$SCRIPT_DIR/output/dropshell.${ARCH}" --version) +[ -z "$TAG" ] && echo "Failed to get version from dropshell.${ARCH}" >&2 && exit 1 echo "Publishing dropshell version $TAG" -# make sure we've commited. -git add "$SCRIPT_DIR/../" && git commit -m "dropshell release $TAG" && git push - -# Find repo info from .git/config -REPO_URL=$(git config --get remote.origin.url) -if [[ ! $REPO_URL =~ gitea ]]; then - echo "Remote origin is not a Gitea repository: $REPO_URL" >&2 +function die() { + echo "$@" >&2 exit 1 -fi - -# Extract base URL, owner, and repo -# Example: https://gitea.example.com/username/reponame.git -BASE_URL=$(echo "$REPO_URL" | sed -E 's#(https?://[^/]+)/.*#\1#') -OWNER=$(echo "$REPO_URL" | sed -E 's#.*/([^/]+)/[^/]+(\.git)?$#\1#') -REPO=$(echo "$REPO_URL" | sed -E 's#.*/([^/]+)(\.git)?$#\1#') - -API_URL="$BASE_URL/api/v1/repos/$OWNER/$REPO" - -# Create release -RELEASE_DATA=$(cat <&1) - -# Extract the release ID from the captured output -RELEASE_ID=$(echo "$CURL_OUTPUT" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2) - -if [ -z "$RELEASE_ID" ]; then - echo "Failed to create release on Gitea." >&2 - echo "Release ID returned: $RELEASE_ID" >&2 - echo "Curl Output/Error:" >&2 - echo "$CURL_OUTPUT" >&2 - exit 1 -fi # Function to find file in specified locations find_file() { @@ -94,25 +41,17 @@ find_file() { return 1 } +curl -L -s -o "${TEMP_DIR}/sos" "https://getbin.xyz/sos" || die "Failed to download sos" +chmod +x "${TEMP_DIR}/sos" + + # Upload binaries and install.sh -for FILE in dropshell.x86_64 dropshell.aarch64 install.sh server_autosetup.sh; do +for FILE in dropshell.x86_64 dropshell.aarch64 dropshell-install.sh dropshell-server-autosetup.sh; do # Pass the locations directly to the find_file function filetoupload=$(find_file "$FILE" "output" "../" ".") - if [ -z "$filetoupload" ]; then - echo "File $FILE not found in expected locations!" >&2 - continue - fi + [ -z "$filetoupload" ] && die "File $FILE not found in expected locations!" - # Auto-detect content type - ctype=$(file --mime-type -b "$filetoupload") - - curl -X POST "$API_URL/releases/$RELEASE_ID/assets?name=$FILE" \ - -H "Content-Type: $ctype" \ - -H "Authorization: token $TOKEN" \ - --data-binary @"$filetoupload" - echo "Uploaded $FILE to release $TAG as $ctype." + "${TEMP_DIR}/sos" upload getbin.xyz "$filetoupload" "$FILE:latest" "$FILE:TAG" done -echo "Published dropshell version $TAG to $REPO_URL (tag $TAG) with binaries." - -cd "$OLD_PWD" || exit 1 \ No newline at end of file +echo "Published dropshell $TAG to getbin.xyz"