mirror of
https://code.forgejo.org/actions/forgejo-release.git
synced 2025-10-13 16:11:56 +03:00
forgejo-release.sh: Handle dependency globally
This ensures checks are consistent where needed. setup_api was retained in case of changes that might need to be made in the future.
This commit is contained in:
parent
324005b6c0
commit
8cfa95b448
1 changed files with 26 additions and 15 deletions
|
@ -42,7 +42,31 @@ get_arch() {
|
|||
echo "$arch"
|
||||
}
|
||||
|
||||
check_dependencies() {
|
||||
missing=""
|
||||
for cmd in curl jq; do
|
||||
if ! command -v "$cmd" >/dev/null 2>&1; then
|
||||
missing="$missing $cmd"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -n "$missing" ]; then
|
||||
echo "Missing required tools:$missing" >&2
|
||||
echo "Attempting to install (if supported)..." >&2
|
||||
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
apt-get -qq update && apt-get install -y -qq $missing
|
||||
elif command -v apk >/dev/null 2>&1; then
|
||||
apk add --no-cache $missing
|
||||
else
|
||||
echo "No supported package manager found; please install manually." >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
setup_tea() {
|
||||
check_dependencies
|
||||
if command -v tea >/dev/null 2>&1; then
|
||||
TEA_BIN=$(command -v tea)
|
||||
elif ! [ -f "$TEA_BIN" ]; then
|
||||
|
@ -181,21 +205,8 @@ upload() {
|
|||
}
|
||||
|
||||
setup_api() {
|
||||
# Check if jq and curl are available
|
||||
if command -v jq >/dev/null 2>&1 && command -v curl >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "jq and/or curl missing, attempting to install..." >&2
|
||||
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
apt-get -qq update && apt-get install -y -qq jq curl
|
||||
elif command -v apk >/dev/null 2>&1; then
|
||||
apk add --no-cache jq curl
|
||||
else
|
||||
echo "No supported package manager found. Please install jq and curl manually." >&2
|
||||
return 1
|
||||
fi
|
||||
# Retained for future expansion, but dependency checking now handled globally
|
||||
check_dependencies
|
||||
}
|
||||
|
||||
api() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue