From 84fd96e74ea67dacfeccf86e544373d19589c6f9 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 26 May 2025 22:34:52 +1200 Subject: [PATCH] dropshell release 2025.0526.2234 --- source/publish.sh | 63 ++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/source/publish.sh b/source/publish.sh index 2a22d18..0445a3d 100755 --- a/source/publish.sh +++ b/source/publish.sh @@ -6,16 +6,8 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" echo "Script directory: $SCRIPT_DIR" # Check for GITEA_TOKEN_DEPLOY or GITEA_TOKEN -if [ -n "$GITEA_TOKEN_DEPLOY" ]; then - TOKEN="$GITEA_TOKEN_DEPLOY" - echo "Using GITEA_TOKEN_DEPLOY" -elif [ -n "$GITEA_TOKEN" ]; then - TOKEN="$GITEA_TOKEN" - echo "Using GITEA_TOKEN" -else - echo "Neither GITEA_TOKEN_DEPLOY nor GITEA_TOKEN environment variable set!" >&2 - exit 1 -fi +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 @@ -23,18 +15,15 @@ BUILD_DIR=$SCRIPT_DIR/build OLD_PWD=$PWD cd $SCRIPT_DIR - -if [ ! -f "output/dropshell.x86_64" ]; then - echo "output/dropshell.x86_64 not found!" >&2 - echo "Please run multibuild.sh first." >&2 - exit 1 -fi - -if [ ! -f "output/dropshell.aarch64" ]; then - echo "output/dropshell.aarch64 not found!" >&2 - echo "Please run multibuild.sh first." >&2 - exit 1 -fi +# 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 @@ -89,23 +78,35 @@ if [ -z "$RELEASE_ID" ]; then exit 1 fi +# Function to find file in specified locations +find_file() { + local filename="$1" + shift # remove filename from args + local locations=("$@") # grab the rest of the args as locations + + for loc in "${locations[@]}"; do + if [ -f "$loc/$filename" ]; then + echo "$loc/$filename" + return 0 # Found the file, return success + fi + done + echo "" # Return empty string if not found + return 1 +} + # Upload binaries and install.sh for FILE in dropshell.x86_64 dropshell.aarch64 install.sh server_autosetup.sh; do - if [ -f "output/$FILE" ]; then - filetoupload="output/$FILE" - elif [ -f "../$FILE" ]; then - filetoupload="../$FILE" - elif [ -f "$FILE" ]; then - filetoupload="$FILE" - else - echo "File $FILE not found!" >&2 + # 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 # Auto-detect content type ctype=$(file --mime-type -b "$filetoupload") - curl -s -X POST "$API_URL/releases/$RELEASE_ID/assets?name=$FILE" \ + curl -X POST "$API_URL/releases/$RELEASE_ID/assets?name=$FILE" \ -H "Content-Type: $ctype" \ -H "Authorization: token $TOKEN" \ --data-binary @"$filetoupload"