diff --git a/.github/workflows/versions.yaml b/.github/workflows/versions.yaml index 3803c64a8b13..54ab9f741ff7 100644 --- a/.github/workflows/versions.yaml +++ b/.github/workflows/versions.yaml @@ -18,10 +18,21 @@ on: branches: - main pull_request: -name: unmanaged versions check +name: versions check jobs: - check: + unmanaged-versions-check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - run: ./generation/check_non_release_please_versions.sh \ No newline at end of file + - run: ./generation/check_non_release_please_versions.sh + + # For Release Please pull requests, the artifacts being published must not + # have the duplicate versions in Maven Central + existing-versions-check: + runs-on: ubuntu-latest + if: github.repository_owner == 'googleapis' && github.head_ref == 'release-please--branches--main' + steps: + - run: sudo apt-get update -y + - run: sudo apt-get install libxml2-utils + - uses: actions/checkout@v3 + - run: ./generation/check_existing_release_versions.sh diff --git a/gapic-libraries-bom/pom.xml b/gapic-libraries-bom/pom.xml index 71a3e21c93be..cc14938e99cd 100644 --- a/gapic-libraries-bom/pom.xml +++ b/gapic-libraries-bom/pom.xml @@ -984,7 +984,7 @@ 2.6.1-SNAPSHOT - com.google.cloud + com.google.cloud google-cloud-notification 0.123.22-beta-SNAPSHOT diff --git a/generation/check_existing_release_versions.sh b/generation/check_existing_release_versions.sh new file mode 100755 index 000000000000..1e7c1ad84872 --- /dev/null +++ b/generation/check_existing_release_versions.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Using Google Mirror to avoid unnecessary load to https://repo1.maven.org/maven2 +MAVEN_SITE=https://maven-central.storage-download.googleapis.com/maven2 + +set -e + +function find_existing_version_pom() { + local pom_file=$1 + if [ -z "${pom_file}" ]; then + echo "Empty pom file name" + exit 1 + fi + local group_id=$(xmllint --xpath '/*[local-name()="project"]/*[local-name()="groupId"]/text()' \ + "${pom_file}") + local artifact_id=$(xmllint --xpath '/*[local-name()="project"]/*[local-name()="artifactId"]/text()' \ + "${pom_file}") + local version=$(xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' \ + "${pom_file}") + echo -n "Checking ${group_id}:${artifact_id}:${version}:" + if [ -z "${group_id}" ] || [ -z "${artifact_id}" ] || [ -z "${version}" ]; then + echo "Couldn't parse the pom file: $pom_file" + exit 1 + fi + if [[ "${version}" == *SNAPSHOT* ]] && [ "${artifact_id}" != "google-cloud-java" ]; then + echo " Release Please pull request contains SNAPSHOT version. Please investigate." + return_code=1 + fi + local group_id_dir="${group_id//\.//}" + local URL="${MAVEN_SITE}/${group_id_dir}/${artifact_id}/${version}/${artifact_id}-${version}.pom" + local status_code=$(curl --silent --head -o /dev/null -w "%{http_code}" $URL) + if [ "${status_code}" == "404" ]; then + echo " The version does not exists. Good" + else + echo " The version already exists at ${URL}. Please investigate." + return_code=1 + fi + +} + +return_code=0 + +for pom_file in $(find . -maxdepth 3 -name pom.xml|sort --dictionary-order); do + find_existing_version_pom "${pom_file}" +done + +exit ${return_code} diff --git a/java-notification/pom.xml b/java-notification/pom.xml index 4b3ab124a06a..b4e3d36bf7c7 100644 --- a/java-notification/pom.xml +++ b/java-notification/pom.xml @@ -3,6 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + com.google.cloud google-cloud-notification 0.123.22-beta-SNAPSHOT jar