Skip to content

Commit

Permalink
latest version strategy for pull-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasSUSE committed Mar 3, 2025
1 parent 8ad1e56 commit 7f4a737
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions scripts/pull-scripts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ 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
Expand Down
2 changes: 1 addition & 1 deletion scripts/version
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

0 comments on commit 7f4a737

Please sign in to comment.