diff --git a/.forgejo/workflows/build_release.yml b/.forgejo/workflows/build_release.yml index e04aa70cc..847a3fd13 100755 --- a/.forgejo/workflows/build_release.yml +++ b/.forgejo/workflows/build_release.yml @@ -315,7 +315,33 @@ jobs: fi discover_jq } + ensure_curl() { + if command -v curl >/dev/null 2>&1; then + return 0 + fi + run_as_root() { + if [ "$(id -u)" -eq 0 ]; then + "$@" + elif command -v sudo >/dev/null 2>&1; then + sudo "$@" + else + return 1 + fi + } + if command -v dnf >/dev/null 2>&1; then + run_as_root dnf install -y curl + elif command -v apt-get >/dev/null 2>&1; then + run_as_root apt-get update + run_as_root apt-get install -y curl + elif command -v apk >/dev/null 2>&1; then + run_as_root apk add --no-cache curl + elif command -v pacman >/dev/null 2>&1; then + run_as_root pacman -Sy --noconfirm curl + fi + command -v curl >/dev/null 2>&1 + } ensure_jq || { echo "jq not found; install jq on the runner (dnf install -y jq)."; exit 1; } + ensure_curl || { echo "curl not found; install curl on the runner (dnf install -y curl)."; exit 1; } api_base="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases" payload_file="$(mktemp)" @@ -437,7 +463,33 @@ jobs: fi discover_jq } + ensure_curl() { + if command -v curl >/dev/null 2>&1; then + return 0 + fi + run_as_root() { + if [ "$(id -u)" -eq 0 ]; then + "$@" + elif command -v sudo >/dev/null 2>&1; then + sudo "$@" + else + return 1 + fi + } + if command -v dnf >/dev/null 2>&1; then + run_as_root dnf install -y curl + elif command -v apt-get >/dev/null 2>&1; then + run_as_root apt-get update + run_as_root apt-get install -y curl + elif command -v apk >/dev/null 2>&1; then + run_as_root apk add --no-cache curl + elif command -v pacman >/dev/null 2>&1; then + run_as_root pacman -Sy --noconfirm curl + fi + command -v curl >/dev/null 2>&1 + } ensure_jq || { echo "jq not found; install jq on the runner (dnf install -y jq)."; exit 1; } + ensure_curl || { echo "curl not found; install curl on the runner (dnf install -y curl)."; exit 1; } release_api="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}" assets_file="$(mktemp)"