diff --git a/.github/workflows/generateAutoConfigs.yaml b/.github/workflows/generateAutoConfigs.yaml index fe409bb944..f801d2d50d 100644 --- a/.github/workflows/generateAutoConfigs.yaml +++ b/.github/workflows/generateAutoConfigs.yaml @@ -5,7 +5,7 @@ on: branch_name: description: PR branch name required: true - default: "renovate/main-gcp-libraries-bom.version" + default: "renovate/gcp-libraries-bom.version" forked_repo: description: Fork name (enter none if repo branch) required: true diff --git a/spring-cloud-generator/scripts/generate-library-list.sh b/spring-cloud-generator/scripts/generate-library-list.sh index 2e9be5243d..76da87599e 100755 --- a/spring-cloud-generator/scripts/generate-library-list.sh +++ b/spring-cloud-generator/scripts/generate-library-list.sh @@ -23,45 +23,58 @@ cd ${SPRING_GENERATOR_DIR} filename=${SPRING_GENERATOR_DIR}/scripts/resources/library_list.txt echo "# api_shortname, googleapis-folder, distribution_name:version, monorepo_folder" > "$filename" -# loop through folders +# loop through configs for the monorepo (google-cloud-java) +# Note that this logic will not work for non-cloud APIs count=0 -for d in ./google-cloud-java/*java-*/; do - # parse variables from .repo-metadata.json - language=$(cat $d/.repo-metadata.json | jq -r .language) - api_shortname=$(cat $d/.repo-metadata.json | jq -r .api_shortname) - distribution_name=$(cat $d/.repo-metadata.json | jq -r .distribution_name) - library_type=$(cat $d/.repo-metadata.json | jq -r .library_type) - release_level=$(cat $d/.repo-metadata.json | jq -r .release_level) - monorepo_folder=$(basename $d) - group_id=$(echo $distribution_name | cut -f1 -d:) - artifact_id=$(echo $distribution_name | cut -f2 -d:) - # filter to in-scope libraries - if [[ $library_type != *GAPIC_AUTO* ]] ; then - echo "$d: non auto type: $library_type" - continue - fi - if [[ $group_id != "com.google.cloud" ]] ; then - echo "$d: group_id not in scope: $group_id" - continue - fi - if [[ $release_level != "stable" ]] ; then - echo "$d: release_level: $release_level" - continue - fi - # checks if library is in the manual modules exclusion list - if [[ $(cat ${SPRING_GENERATOR_DIR}/scripts/resources/manual_modules_exclusion_list.txt | tail -n+2 | grep $artifact_id | wc -l) -ne 0 ]] ; then - echo "$artifact_id is already present in manual modules." - continue - fi +configs=$(yq eval '.libraries[]' -o=json ./google-cloud-java/generation_config.yaml) +# Properly format the configs as a JSON array +# This includes adding commas between objects and wrapping everything in square brackets +json_array="[ $(echo "$configs" | tr '\n' ' ' | sed 's/} {/}, {/g') ]" - # parse proto path from generation_config.yaml, find by api_shortname - # then sort and keep latest stable version - library=$(yq -r '.libraries[] | select(.api_shortname == "'"$api_shortname"'")' ./google-cloud-java/generation_config.yaml) - proto_paths_stable=$(echo "$library" | yq -r '.GAPICs[] | select(.proto_path | test("/v[0-9]+$")) | .proto_path') - proto_paths_latest=$(echo "$proto_paths_stable" | sort -d -r | head -n 1) +# Parse each object in the JSON array +while IFS= read -r config; do + # Extract library_name if present, otherwise use api_shortname + unique_module_name=$(echo "$config" | jq -r '.library_name // .api_shortname') + # Display the unique module name + echo "Unique Module Name: $unique_module_name" + distribution_name=$(echo "$config" | jq -r '.distribution_name // ""') + if [ -z "$distribution_name" ]; then + distribution_name="com.google.cloud:google-cloud-${unique_module_name}" + fi + echo "Distribution name: $distribution_name" + library_type=$(echo "$config" | jq -r '.library_type // "GAPIC_AUTO"') # default to GAPIC_AUTO per https://github.com/googleapis/sdk-platform-java/blob/v2.40.0/library_generation/model/library_config.py#L57 + echo "library_type: $library_type" + release_level=$(echo "$config" | jq -r '.release_level // "preview"') # default to preview per https://github.com/googleapis/sdk-platform-java/blob/v2.40.0/library_generation/model/library_config.py#L58 + echo "release_level: $release_level" + monorepo_folder="java/${unique_module_name}" + echo "monorepo folder: $monorepo_folder" + group_id=$(echo $distribution_name | cut -f1 -d:) + artifact_id=$(echo $distribution_name | cut -f2 -d:) + # filter to in-scope libraries + if [[ $library_type != *GAPIC_AUTO* ]] ; then + echo "$d: non auto type: $library_type" + continue + fi + if [[ $group_id != "com.google.cloud" ]] ; then + echo "$d: group_id not in scope: $group_id" + continue + fi + if [[ $release_level != "stable" ]] ; then + echo "$d: release_level: $release_level" + continue + fi + # checks if library is in the manual modules exclusion list + if [[ $(cat ${SPRING_GENERATOR_DIR}/scripts/resources/manual_modules_exclusion_list.txt | tail -n+2 | grep $artifact_id | wc -l) -ne 0 ]] ; then + echo "$artifact_id is already present in manual modules." + continue + fi + proto_paths_stable=$(echo "$config" | yq -r '.GAPICs[] | select(.proto_path | test("/v[0-9]+$")) | .proto_path') + echo "proto_paths_stable : $proto_paths_stable" + proto_paths_latest=$(echo "$proto_paths_stable" | sort -d -r | head -n 1) + echo "proto_paths_latest : $proto_paths_latest" - echo "$api_shortname, $proto_paths_latest, $distribution_name, $monorepo_folder" >> $filename + echo "$unique_module_name, $proto_paths_latest, $distribution_name, $monorepo_folder" >> $filename count=$((count+1)) -done +done < <(echo "$json_array" | jq -c '.[]') echo "Total in-scope client libraries: $count"