Skip to content
Merged
17 changes: 14 additions & 3 deletions .github/workflows/versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- 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
2 changes: 1 addition & 1 deletion gapic-libraries-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@
<version>2.6.1-SNAPSHOT</version><!-- {x-version-update:grafeas:current} -->
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-notification</artifactId>
<version>0.123.22-beta-SNAPSHOT</version><!-- {x-version-update:google-cloud-notification:current} -->
</dependency>
Expand Down
47 changes: 47 additions & 0 deletions generation/check_existing_release_versions.sh
Original file line number Diff line number Diff line change
@@ -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}
1 change: 1 addition & 0 deletions java-notification/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.cloud</groupId>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of consistency, adding this groupId element. "com.google.cloud" is the groupID of this artifact:
https://search.maven.org/artifact/com.google.cloud/google-cloud-notification

<artifactId>google-cloud-notification</artifactId>
<version>0.123.22-beta-SNAPSHOT</version><!-- {x-version-update:google-cloud-notification:current} -->
<packaging>jar</packaging>
Expand Down