From b79fc25443a1b15ee5ec819a31d236946c5e8486 Mon Sep 17 00:00:00 2001 From: crueter Date: Fri, 14 Nov 2025 23:15:08 -0500 Subject: [PATCH] posix-compliant setup_api + more distros Signed-off-by: crueter --- forgejo-release.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/forgejo-release.sh b/forgejo-release.sh index e2285e0..e3a096e 100755 --- a/forgejo-release.sh +++ b/forgejo-release.sh @@ -42,7 +42,7 @@ get_tag() { if api GET "repos/$REPO/tags/$TAG_URL" >"$TAG_FILE"; then echo "tag $TAG exists" else - echo "tag $TAG does not exists" + echo "tag $TAG does not exist" fi fi test -s "$TAG_FILE" @@ -172,9 +172,24 @@ upload() { } setup_api() { - if ! which jq curl; then + needed="jq curl" + for cmd in $needed; do + command -v "$cmd" >/dev/null 2>&1 || missing="$missing $cmd" + done + + # debian/ubuntu + if command -v apt-get >/dev/null 2>&1; then apt-get -qq update - apt-get install -y -qq jq curl + apt-get install -y -qq "$missing" + # arch + elif command -v pacman >/dev/null 2>&1; then + pacman -Syu --noconfirm "$missing" + # alpine + elif command -v apk >/dev/null 2>&1; then + apk add --no-cache "$missing" + # gentoo + elif command -v emerge >/dev/null 2>&1; then + emerge -q "$missing" fi }