@@ -51,45 +51,58 @@ jobs:
51
51
3.8
52
52
3.9
53
53
54
- - name : Install pipenv
55
- run : pip install pipenv
54
+ - name : Install pipenv and pip-versions
55
+ run : pip install pipenv pip-versions
56
56
57
57
- name : Update Pipfiles in accordance with Codeflare-SDK latest release
58
58
run : |
59
- # list all Pipfile paths having Codeflare-SDK listed
60
- paths+=($(grep -rl 'codeflare-sdk = "~=.*"'))
61
- # Extracting only directories from file paths, excluding a `.gitworkflow` directory
62
- directories=()
63
- exclude_directories=(
64
- ".git/objects/pack"
65
- ".github/workflows/",
66
- )
67
- for path in "${paths[@]}"; do
68
- current_dir=$(dirname "$path")
69
- #Check if current_dir is not in exclude_directories list
70
- if [[ ! "${exclude_directories[@]}" =~ "$current_dir" ]]; then
71
- #Check if Pipfile exists in current_dir
72
- if [ -f "$current_dir/Pipfile" ];then
73
- directories+=("$current_dir")
59
+ package_name=codeflare-sdk
60
+ # Get the list of available versions for the package
61
+ versions=$(pipenv run pip-versions list $package_name)
62
+ # Check if the desired version exists in the list
63
+ if echo "$versions" | grep -q "${CODEFLARE_RELEASE_VERSION}"; then
64
+ echo "Version ${CODEFLARE_RELEASE_VERSION} is available for $package_name"
65
+ # list all Pipfile paths having Codeflare-SDK listed
66
+ paths+=($(grep -rl "${package_name} = \"~=.*\""))
67
+ # Extracting only directories from file paths, excluding a `.gitworkflow` directory
68
+ directories=()
69
+ exclude_directories=(
70
+ ".git/objects/pack"
71
+ ".github/workflows/",
72
+ )
73
+ for path in "${paths[@]}"; do
74
+ current_dir=$(dirname "$path")
75
+ #Check if current_dir is not in exclude_directories list
76
+ if [[ ! "${exclude_directories[@]}" =~ "$current_dir" ]]; then
77
+ #Check if Pipfile exists in current_dir
78
+ if [ -f "$current_dir/Pipfile" ];then
79
+ directories+=("$current_dir")
80
+ fi
74
81
fi
75
- fi
76
- done
77
- # Remove duplicates
78
- directories=($(echo "${directories[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
79
- # Print the directories for verification
80
- echo "Directories (Start updating Pipfile in these below directories in accordance with Codeflare-SDK latest release):"
81
- for dir in "${directories[@]}"; do
82
- echo "- $dir"
83
- done
84
- # iterate over the directories and update Pipfile
85
- counter=0
86
- total=${#directories[@]}
87
- for dir in "${directories[@]}"; do
88
- counter=$((counter+1))
89
- echo "--Processing directory $counter '$dir' of total $total"
90
- cd "$dir" && pipenv install codeflare-sdk~="${CODEFLARE_RELEASE_VERSION}" && pipenv --rm && cd -
91
- echo "$((total-counter)) directories remaining.."
92
- done
82
+ done
83
+ # Remove duplicates
84
+ directories=($(echo "${directories[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
85
+ # Print the directories for verification
86
+ echo "Directories (Start updating Pipfile in these below directories in accordance with Codeflare-SDK latest release):"
87
+ for dir in "${directories[@]}"; do
88
+ echo "- $dir"
89
+ done
90
+ # iterate over the directories and update Pipfile
91
+ counter=0
92
+ total=${#directories[@]}
93
+ for dir in "${directories[@]}"; do
94
+ counter=$((counter+1))
95
+ echo "--Processing directory $counter '$dir' of total $total"
96
+ cd "$dir" && pipenv install ${package_name}~="${CODEFLARE_RELEASE_VERSION}" && pipenv --rm && cd -
97
+ echo "$((total-counter)) directories remaining.."
98
+ done
99
+ else
100
+ versions_list=$(echo "$versions" | tr '\n' ' \, ')
101
+ versions="${versions_list%,}"
102
+ echo "Version '${CODEFLARE_RELEASE_VERSION}' is not available for $package_name"
103
+ echo "Available versions for $package_name: $versions"
104
+ exit 1
105
+ fi
93
106
94
107
- name : Push changes
95
108
run : |
0 commit comments