From 8dfd6a1ab12f15a3a69f9d177875a1a2c3356859 Mon Sep 17 00:00:00 2001 From: nicholasSUSE Date: Mon, 3 Mar 2025 12:36:36 -0300 Subject: [PATCH] latest version strategy for pull-scripts --- scripts/pull-scripts | 14 ++++++++++++++ scripts/version | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/pull-scripts b/scripts/pull-scripts index a5e314aa26..acb8d75d6b 100755 --- a/scripts/pull-scripts +++ b/scripts/pull-scripts @@ -8,13 +8,27 @@ source ./version # Source the version file to set environment variables if ls ../bin/charts-build-scripts 1>/dev/null 2>/dev/null; then # Use awk to split the version output correctly and extract the version number CURRENT_SCRIPT_VERSION="v$(../bin/charts-build-scripts --version | awk '{print $3}')" + + # If the version is "latest", fetch the latest release version + if [[ "${CHARTS_BUILD_SCRIPT_VERSION}" == "latest" ]]; then + CHARTS_BUILD_SCRIPT_VERSION=$(curl --silent "https://api.github.com/repos/rancher/charts-build-scripts/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + echo "Resolved latest version to ${CHARTS_BUILD_SCRIPT_VERSION}" + fi + echo "Current version: ${CURRENT_SCRIPT_VERSION}, Expected version: ${CHARTS_BUILD_SCRIPT_VERSION}" # Exit if the current version matches the expected version if [[ "${CURRENT_SCRIPT_VERSION}" == "${CHARTS_BUILD_SCRIPT_VERSION}" ]]; then + echo "target version already present" exit 0 fi fi +# If the version is "latest", fetch the latest release version +if [[ "${CHARTS_BUILD_SCRIPT_VERSION}" == "latest" ]]; then + CHARTS_BUILD_SCRIPT_VERSION=$(curl --silent "https://api.github.com/repos/rancher/charts-build-scripts/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + echo "Resolved latest version to ${CHARTS_BUILD_SCRIPT_VERSION}" +fi + echo "Downloading charts-build-scripts version ${CHARTS_BUILD_SCRIPTS_REPO}@${CHARTS_BUILD_SCRIPT_VERSION}" # Remove existing ../bin directory and change to the parent dir. diff --git a/scripts/version b/scripts/version index 8d661b19eb..23b0ed5a91 100755 --- a/scripts/version +++ b/scripts/version @@ -2,4 +2,4 @@ set -e CHARTS_BUILD_SCRIPTS_REPO=https://github.com/rancher/charts-build-scripts.git -CHARTS_BUILD_SCRIPT_VERSION="${CHARTS_BUILD_SCRIPT_VERSION:-v1.4.6}" +CHARTS_BUILD_SCRIPT_VERSION="${CHARTS_BUILD_SCRIPT_VERSION:-latest}"