diff --git a/.github/scripts/update_generation_config.sh b/.github/scripts/update_generation_config.sh index 91434688c..fff56bf5d 100644 --- a/.github/scripts/update_generation_config.sh +++ b/.github/scripts/update_generation_config.sh @@ -15,8 +15,15 @@ set -e function get_latest_released_version() { local group_id=$1 local artifact_id=$2 - latest=$(curl -s "https://search.maven.org/solrsearch/select?q=g:${group_id}+AND+a:${artifact_id}&core=gav&rows=500&wt=json" | jq -r '.response.docs[] | select(.v | test("^[0-9]+(\\.[0-9]+)*$")) | .v' | sort -V | tail -n 1) - echo "${latest}" + 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) + 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}" + exit 1 + else + echo "${latest}" + fi } # Update a key to a new value in the generation config. diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 941f2f3b4..b91fa381f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -59,23 +59,15 @@ jobs: env: JOB_TYPE: test windows: - # Building using Java 11 and run the tests with Java 8 runtime runs-on: windows-latest steps: - name: Support longpaths run: git config --system core.longpaths true - uses: actions/checkout@v4 - - uses: actions/setup-java@v4 - with: - java-version: 8 - distribution: temurin - - name: "Set jvm system property environment variable for surefire plugin (unit tests)" - run: echo "SUREFIRE_JVM_OPT=-Djvm=${JAVA_HOME}\bin\java" >> $GITHUB_ENV - shell: bash - uses: actions/setup-java@v4 with: distribution: temurin - java-version: 11 + java-version: 8 - run: java -version - run: .kokoro/build.bat env: diff --git a/.github/workflows/update_generation_config.yaml b/.github/workflows/update_generation_config.yaml index 3cf773992..f7b089f34 100644 --- a/.github/workflows/update_generation_config.yaml +++ b/.github/workflows/update_generation_config.yaml @@ -28,6 +28,7 @@ jobs: steps: - uses: actions/checkout@v4 with: + fetch-depth: 0 token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} - name: Update params in generation config to latest shell: bash @@ -36,7 +37,8 @@ jobs: [ -z "$(git config user.email)" ] && git config --global user.email "cloud-java-bot@google.com" [ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot" bash .github/scripts/update_generation_config.sh \ - --base_branch "${base_branch}"\ + --base_branch "${base_branch}" \ --repo ${{ github.repository }} env: GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} +