mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-07-13 17:35:06 +02:00
fix storyteller release selection for multi-stream tags (#15736)
Add optional tag prefix filtering to GitHub/GitLab release helpers and use web-v2 for Storyteller install/update so latest non-web tags no longer break deployment.
This commit is contained in:
committed by
GitHub
parent
d6d8d20c76
commit
734bb75b12
+2
-2
@@ -32,7 +32,7 @@ function update_script() {
|
||||
|
||||
NODE_VERSION="24" NODE_MODULE="corepack,yarn" setup_nodejs
|
||||
|
||||
if check_for_gl_release "storyteller" "storyteller-platform/storyteller"; then
|
||||
if check_for_gl_release "storyteller" "storyteller-platform/storyteller" "" "" "web-v2"; then
|
||||
msg_info "Stopping Service"
|
||||
systemctl stop storyteller
|
||||
msg_ok "Stopped Service"
|
||||
@@ -41,7 +41,7 @@ function update_script() {
|
||||
cp /opt/storyteller/.env /opt/storyteller_env.bak
|
||||
msg_ok "Backed up Data"
|
||||
|
||||
CLEAN_INSTALL=1 fetch_and_deploy_gl_release "storyteller" "storyteller-platform/storyteller" "tarball" "latest" "/opt/storyteller"
|
||||
CLEAN_INSTALL=1 fetch_and_deploy_gl_release "storyteller" "storyteller-platform/storyteller" "tarball" "latest" "/opt/storyteller" "" "web-v2"
|
||||
|
||||
msg_info "Restoring Configuration"
|
||||
mv /opt/storyteller_env.bak /opt/storyteller/.env
|
||||
|
||||
@@ -28,7 +28,7 @@ NODE_VERSION="24" NODE_MODULE="corepack,yarn" setup_nodejs
|
||||
|
||||
fetch_and_deploy_gh_release "readium" "readium/cli" "prebuild" "latest" "/opt/readium" "readium_linux_$(arch_resolve "x86_64" "arm64").tar.gz"
|
||||
ln -sf /opt/readium/readium /usr/local/bin/readium
|
||||
fetch_and_deploy_gl_release "storyteller" "storyteller-platform/storyteller" "tarball" "latest" "/opt/storyteller"
|
||||
fetch_and_deploy_gl_release "storyteller" "storyteller-platform/storyteller" "tarball" "latest" "/opt/storyteller" "" "web-v2"
|
||||
|
||||
msg_info "Setting up Storyteller"
|
||||
cd /opt/storyteller
|
||||
|
||||
+56
-9
@@ -2833,6 +2833,7 @@ check_for_gh_release() {
|
||||
local source="$2"
|
||||
local pinned_version_in="${3:-}" # optional
|
||||
local pin_reason="${4:-}" # optional reason shown to user
|
||||
local tag_prefix="${5:-}" # optional tag prefix filter (e.g. web-v2)
|
||||
local app_lc=""
|
||||
app_lc="$(echo "${app,,}" | tr -d ' ')"
|
||||
local current_file="$HOME/.${app_lc}"
|
||||
@@ -2888,7 +2889,7 @@ check_for_gh_release() {
|
||||
rm -f "$gh_check_json"
|
||||
fi
|
||||
|
||||
if [[ -z "$pinned_version_in" ]]; then
|
||||
if [[ -z "$pinned_version_in" && -z "$tag_prefix" ]]; then
|
||||
http_code=$(curl -sSL --max-time 20 -w "%{http_code}" -o "$gh_check_json" \
|
||||
-H 'Accept: application/vnd.github+json' \
|
||||
-H 'X-GitHub-Api-Version: 2022-11-28' \
|
||||
@@ -2916,7 +2917,7 @@ check_for_gh_release() {
|
||||
rm -f "$gh_check_json"
|
||||
fi
|
||||
|
||||
# If no releases yet (pinned version OR /latest failed), fetch up to 100
|
||||
# If no releases yet (pinned version, tag prefix, OR /latest failed), fetch up to 100
|
||||
if [[ -z "$releases_json" ]]; then
|
||||
http_code=$(curl -sSL --max-time 20 -w "%{http_code}" -o "$gh_check_json" \
|
||||
-H 'Accept: application/vnd.github+json' \
|
||||
@@ -2954,9 +2955,18 @@ check_for_gh_release() {
|
||||
rm -f "$gh_check_json"
|
||||
fi
|
||||
|
||||
mapfile -t raw_tags < <(jq -r '.[] | select(.draft==false and .prerelease==false) | .tag_name' <<<"$releases_json")
|
||||
if [[ -n "$tag_prefix" ]]; then
|
||||
mapfile -t raw_tags < <(jq -r --arg p "$tag_prefix" \
|
||||
'.[] | select(.draft==false and .prerelease==false) | select(.tag_name | startswith($p)) | .tag_name' <<<"$releases_json")
|
||||
else
|
||||
mapfile -t raw_tags < <(jq -r '.[] | select(.draft==false and .prerelease==false) | .tag_name' <<<"$releases_json")
|
||||
fi
|
||||
if ((${#raw_tags[@]} == 0)); then
|
||||
msg_error "No stable releases found for ${app}"
|
||||
if [[ -n "$tag_prefix" ]]; then
|
||||
msg_error "No stable releases matching prefix '${tag_prefix}' found for ${app}"
|
||||
else
|
||||
msg_error "No stable releases found for ${app}"
|
||||
fi
|
||||
return 250
|
||||
fi
|
||||
|
||||
@@ -3960,6 +3970,7 @@ fetch_and_deploy_gh_release() {
|
||||
local version="${var_appversion:-${4:-latest}}"
|
||||
local target="${5:-/opt/$app}"
|
||||
local asset_pattern="${6:-}"
|
||||
local tag_prefix="${7:-}"
|
||||
|
||||
# Validate app name to prevent /root/. directory issues
|
||||
if [[ -z "$app" ]]; then
|
||||
@@ -3989,7 +4000,13 @@ fetch_and_deploy_gh_release() {
|
||||
TOOLS_GH_REL_JSON="$gh_rel_json"
|
||||
|
||||
local api_url="https://api.github.com/repos/$repo/releases"
|
||||
[[ "$version" != "latest" ]] && api_url="$api_url/tags/$version" || api_url="$api_url/latest"
|
||||
if [[ "$version" != "latest" ]]; then
|
||||
api_url="$api_url/tags/$version"
|
||||
elif [[ -n "$tag_prefix" ]]; then
|
||||
api_url="$api_url?per_page=100"
|
||||
else
|
||||
api_url="$api_url/latest"
|
||||
fi
|
||||
local header=()
|
||||
[[ -n "${GITHUB_TOKEN:-}" ]] && header=(-H "Authorization: token $GITHUB_TOKEN")
|
||||
|
||||
@@ -4052,6 +4069,14 @@ fetch_and_deploy_gh_release() {
|
||||
|
||||
local json tag_name
|
||||
json=$(<"$gh_rel_json")
|
||||
if [[ "$version" == "latest" && -n "$tag_prefix" ]]; then
|
||||
json=$(echo "$json" | jq --arg p "$tag_prefix" \
|
||||
'[.[] | select(.draft==false and .prerelease==false) | select(.tag_name | startswith($p))][0] // empty')
|
||||
if [[ -z "$json" || "$json" == "null" ]]; then
|
||||
msg_error "No stable release matching prefix '${tag_prefix}' found for $repo on GitHub"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
tag_name=$(echo "$json" | jq -r '.tag_name // .name // empty')
|
||||
# Only strip leading 'v' when followed by a digit (e.g. v1.2.3), not words like "version/..."
|
||||
[[ "$tag_name" =~ ^v[0-9] ]] && version="${tag_name:1}" || version="$tag_name"
|
||||
@@ -9484,6 +9509,7 @@ check_for_gl_release() {
|
||||
local source="$2"
|
||||
local pinned_version_in="${3:-}" # optional
|
||||
local pin_reason="${4:-}" # optional reason shown to user
|
||||
local tag_prefix="${5:-}" # optional tag prefix filter (e.g. web-v2)
|
||||
local app_lc="${app,,}"
|
||||
local current_file="$HOME/.${app_lc}"
|
||||
|
||||
@@ -9560,9 +9586,18 @@ check_for_gl_release() {
|
||||
rm -f "$gl_check_json"
|
||||
fi
|
||||
|
||||
mapfile -t raw_tags < <(jq -r '.[] | .tag_name' <<<"$releases_json")
|
||||
if [[ -n "$tag_prefix" ]]; then
|
||||
mapfile -t raw_tags < <(jq -r --arg p "$tag_prefix" \
|
||||
'.[] | select(.tag_name | startswith($p)) | .tag_name' <<<"$releases_json")
|
||||
else
|
||||
mapfile -t raw_tags < <(jq -r '.[] | .tag_name' <<<"$releases_json")
|
||||
fi
|
||||
if ((${#raw_tags[@]} == 0)); then
|
||||
msg_error "No releases found for ${app} on GitLab"
|
||||
if [[ -n "$tag_prefix" ]]; then
|
||||
msg_error "No releases matching prefix '${tag_prefix}' found for ${app} on GitLab"
|
||||
else
|
||||
msg_error "No releases found for ${app} on GitLab"
|
||||
fi
|
||||
return 250
|
||||
fi
|
||||
|
||||
@@ -9757,6 +9792,7 @@ fetch_and_deploy_gl_release() {
|
||||
local version="${var_appversion:-${4:-latest}}"
|
||||
local target="${5:-/opt/$app}"
|
||||
local asset_pattern="${6:-}"
|
||||
local tag_prefix="${7:-}"
|
||||
|
||||
if [[ -z "$app" ]]; then
|
||||
app="${repo##*/}"
|
||||
@@ -9788,6 +9824,8 @@ fetch_and_deploy_gl_release() {
|
||||
local api_url
|
||||
if [[ "$version" != "latest" ]]; then
|
||||
api_url="$api_base/$version"
|
||||
elif [[ -n "$tag_prefix" ]]; then
|
||||
api_url="$api_base?per_page=100&order_by=released_at&sort=desc"
|
||||
else
|
||||
api_url="$api_base?per_page=1&order_by=released_at&sort=desc"
|
||||
fi
|
||||
@@ -9842,9 +9880,18 @@ fetch_and_deploy_gl_release() {
|
||||
json=$(<"$gl_rel_json")
|
||||
|
||||
if [[ "$version" == "latest" ]]; then
|
||||
json=$(echo "$json" | jq '.[0] // empty')
|
||||
if [[ -n "$tag_prefix" ]]; then
|
||||
json=$(echo "$json" | jq --arg p "$tag_prefix" \
|
||||
'[.[] | select(.tag_name | startswith($p))][0] // empty')
|
||||
else
|
||||
json=$(echo "$json" | jq '.[0] // empty')
|
||||
fi
|
||||
if [[ -z "$json" || "$json" == "null" ]]; then
|
||||
msg_error "No releases found for $repo on GitLab"
|
||||
if [[ -n "$tag_prefix" ]]; then
|
||||
msg_error "No release matching prefix '${tag_prefix}' found for $repo on GitLab"
|
||||
else
|
||||
msg_error "No releases found for $repo on GitLab"
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user