From c327972776edd205124035abf47b07bb161cef42 Mon Sep 17 00:00:00 2001 From: "Sun, Xuehao" Date: Mon, 19 Aug 2024 11:00:39 +0800 Subject: [PATCH] chore: Add skopeo to manual freeze images workflow (#620) Signed-off-by: Sun, Xuehao --- .github/workflows/manual-freeze-images.yml | 5 +++++ .github/workflows/scripts/freeze_images.sh | 21 ++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/manual-freeze-images.yml b/.github/workflows/manual-freeze-images.yml index c240fb1de..491ca9800 100644 --- a/.github/workflows/manual-freeze-images.yml +++ b/.github/workflows/manual-freeze-images.yml @@ -21,6 +21,11 @@ jobs: with: python-version: "3.10" + - name: install skopeo + run: | + sudo apt update + sudo apt -y install skopeo + - name: Set up Git run: | git config --global user.name "NeuralChatBot" diff --git a/.github/workflows/scripts/freeze_images.sh b/.github/workflows/scripts/freeze_images.sh index fcc142588..0bdfa9fb2 100644 --- a/.github/workflows/scripts/freeze_images.sh +++ b/.github/workflows/scripts/freeze_images.sh @@ -3,11 +3,15 @@ # Copyright (C) 2024 Intel Corporation # SPDX-License-Identifier: Apache-2.0 +declare -A dict +dict["langchain/langchain"]="docker://docker.io/langchain/langchain" +# dict["ghcr.io/huggingface/text-generation-inference"]="docker://ghcr.io/huggingface/text-generation-inference" + function get_latest_version() { repo_image=$1 - versions=$(curl -s "https://registry.hub.docker.com/v2/repositories/$repo_image/tags/" | jq '."results"[]["name"]' | tr -d '"') - echo "version list: $versions" - latest_version=$(printf "%s\n" "${versions[@]}" | grep -v "latest" | sort -V | tail -n 1) + versions=$(skopeo list-tags ${dict[$repo_image]} | jq -r '.Tags[]') + printf "version list:\n$versions\n" + latest_version=$(printf "%s\n" "${versions[@]}" | grep -E '^[\.rc0-9\-]+$' | sort -V | tail -n 1) echo "latest version: $latest_version" replace_image_version $repo_image $latest_version } @@ -15,7 +19,12 @@ function get_latest_version() { function replace_image_version() { repo_image=$1 version=$2 - find . -name "Dockerfile" | xargs sed -i "s|$repo_image:latest|$repo_image:$version|g" + if [[ -z "$version" ]]; then + echo "version is empty" + else + echo "replace $repo_image:latest with $repo_image:$version" + find . -name "Dockerfile" | xargs sed -i "s|$repo_image:latest|$repo_image:$version|g" + fi } function check_branch_name() { @@ -29,13 +38,11 @@ function check_branch_name() { function main() { check_branch_name - repo_image_list="langchain/langchain" - for repo_image in $repo_image_list; do + for repo_image in "${!dict[@]}"; do echo "::group::check $repo_image" get_latest_version $repo_image echo "::endgroup::" done - freeze_tag_in_markdown } main