diff --git a/.github/scripts/update_generation_config.sh b/.github/scripts/update_generation_config.sh index fff56bf5ddf..a0b95de6c0d 100644 --- a/.github/scripts/update_generation_config.sh +++ b/.github/scripts/update_generation_config.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -e +set -ex # This script should be run at the root of the repository. # This script is used to update googleapis_commitish, gapic_generator_version, # and libraries_bom_version in generation configuration at the time of running @@ -15,8 +15,10 @@ set -e function get_latest_released_version() { local group_id=$1 local artifact_id=$2 - json_content=$(curl -s "https://search.maven.org/solrsearch/select?q=g:${group_id}+AND+a:${artifact_id}&core=gav&rows=500&wt=json") - latest=$(jq -r '.response.docs[] | select(.v | test("^[0-9]+(\\.[0-9]+)*$")) | .v' <<< "${json_content}" | sort -V | tail -n 1) + group_id_url_path="$(sed 's|\.|/|g' <<< "${group_id}")" + url="https://repo1.maven.org/maven2/${group_id_url_path}/${artifact_id}/maven-metadata.xml" + xml_content=$(curl -s --fail "${url}") + latest=$(xmllint --xpath 'metadata/versioning/latest/text()' - <<< "${xml_content}") if [[ -z "${latest}" ]]; then echo "The latest version of ${group_id}:${artifact_id} is empty." echo "The returned json from maven.org is invalid: ${json_content}" @@ -172,4 +174,4 @@ if [ -z "${pr_num}" ]; then else git push gh pr edit "${pr_num}" --title "${title}" --body "${title}" -fi +fi \ No newline at end of file diff --git a/.github/workflows/update_generation_config.yaml b/.github/workflows/update_generation_config.yaml index cd2d5fd5a8e..7b14069ced8 100644 --- a/.github/workflows/update_generation_config.yaml +++ b/.github/workflows/update_generation_config.yaml @@ -18,7 +18,6 @@ on: schedule: - cron: '0 2 * * *' workflow_dispatch: - jobs: update-generation-config: runs-on: ubuntu-24.04 @@ -30,6 +29,9 @@ jobs: with: fetch-depth: 0 token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} + - name: Install Dependencies + shell: bash + run: sudo apt-get update && sudo apt-get install -y libxml2-utils - name: Update params in generation config to latest shell: bash run: | @@ -40,5 +42,4 @@ jobs: --base_branch "${base_branch}" \ --repo ${{ github.repository }} env: - GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} - + GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} \ No newline at end of file