Use jq for version extraction in auto-update script
This commit is contained in:
parent
121bdf1b00
commit
5f554a5b76
1 changed files with 4 additions and 10 deletions
|
|
@ -48,22 +48,16 @@ get_latest_version() {
|
||||||
log "Checking for the latest Forgejo version..."
|
log "Checking for the latest Forgejo version..."
|
||||||
|
|
||||||
# Fetch the latest version from the Forgejo API with error handling
|
# Fetch the latest version from the Forgejo API with error handling
|
||||||
local api_response
|
|
||||||
api_response=$(curl -s --max-time 10 https://codeberg.org/api/v1/repos/forgejo/forgejo/releases/latest)
|
|
||||||
|
|
||||||
# Log the full API response for debugging
|
|
||||||
log "API Response: $api_response"
|
|
||||||
|
|
||||||
# Extract version using grep and sed
|
|
||||||
local latest_version
|
local latest_version
|
||||||
latest_version=$(echo "$api_response" | grep -oP '(?<="tag_name":"v)[0-9.]+')
|
latest_version=$(curl -s --max-time 10 https://codeberg.org/api/v1/repos/forgejo/forgejo/releases/latest | \
|
||||||
|
jq -r '.tag_name' | \
|
||||||
|
sed 's/^v//')
|
||||||
|
|
||||||
if [ -z "$latest_version" ]; then
|
if [ -z "$latest_version" ]; then
|
||||||
log "ERROR: Failed to extract version from API response."
|
log "ERROR: Failed to retrieve the latest version from Codeberg API."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log "Extracted latest version: $latest_version"
|
|
||||||
echo "$latest_version"
|
echo "$latest_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue