Skip to content

Commit 4cd1bab

Browse files
authored
ci: adding a non-required check to ensure no existing version on release PR (#8788)
1 parent f5bcb08 commit 4cd1bab

File tree

4 files changed

+63
-4
lines changed

4 files changed

+63
-4
lines changed

.github/workflows/versions.yaml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,21 @@ on:
1818
branches:
1919
- main
2020
pull_request:
21-
name: unmanaged versions check
21+
name: versions check
2222
jobs:
23-
check:
23+
unmanaged-versions-check:
2424
runs-on: ubuntu-latest
2525
steps:
2626
- uses: actions/checkout@v3
27-
- run: ./generation/check_non_release_please_versions.sh
27+
- run: ./generation/check_non_release_please_versions.sh
28+
29+
# For Release Please pull requests, the artifacts being published must not
30+
# have the duplicate versions in Maven Central
31+
existing-versions-check:
32+
runs-on: ubuntu-latest
33+
if: github.repository_owner == 'googleapis' && github.head_ref == 'release-please--branches--main'
34+
steps:
35+
- run: sudo apt-get update -y
36+
- run: sudo apt-get install libxml2-utils
37+
- uses: actions/checkout@v3
38+
- run: ./generation/check_existing_release_versions.sh

gapic-libraries-bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@
984984
<version>2.6.1-SNAPSHOT</version><!-- {x-version-update:grafeas:current} -->
985985
</dependency>
986986
<dependency>
987-
<groupId>com.google.cloud</groupId>
987+
<groupId>com.google.cloud</groupId>
988988
<artifactId>google-cloud-notification</artifactId>
989989
<version>0.123.22-beta-SNAPSHOT</version><!-- {x-version-update:google-cloud-notification:current} -->
990990
</dependency>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
# Using Google Mirror to avoid unnecessary load to https://repo1.maven.org/maven2
4+
MAVEN_SITE=https://maven-central.storage-download.googleapis.com/maven2
5+
6+
set -e
7+
8+
function find_existing_version_pom() {
9+
local pom_file=$1
10+
if [ -z "${pom_file}" ]; then
11+
echo "Empty pom file name"
12+
exit 1
13+
fi
14+
local group_id=$(xmllint --xpath '/*[local-name()="project"]/*[local-name()="groupId"]/text()' \
15+
"${pom_file}")
16+
local artifact_id=$(xmllint --xpath '/*[local-name()="project"]/*[local-name()="artifactId"]/text()' \
17+
"${pom_file}")
18+
local version=$(xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' \
19+
"${pom_file}")
20+
echo -n "Checking ${group_id}:${artifact_id}:${version}:"
21+
if [ -z "${group_id}" ] || [ -z "${artifact_id}" ] || [ -z "${version}" ]; then
22+
echo "Couldn't parse the pom file: $pom_file"
23+
exit 1
24+
fi
25+
if [[ "${version}" == *SNAPSHOT* ]] && [ "${artifact_id}" != "google-cloud-java" ]; then
26+
echo " Release Please pull request contains SNAPSHOT version. Please investigate."
27+
return_code=1
28+
fi
29+
local group_id_dir="${group_id//\.//}"
30+
local URL="${MAVEN_SITE}/${group_id_dir}/${artifact_id}/${version}/${artifact_id}-${version}.pom"
31+
local status_code=$(curl --silent --head -o /dev/null -w "%{http_code}" $URL)
32+
if [ "${status_code}" == "404" ]; then
33+
echo " The version does not exists. Good"
34+
else
35+
echo " The version already exists at ${URL}. Please investigate."
36+
return_code=1
37+
fi
38+
39+
}
40+
41+
return_code=0
42+
43+
for pom_file in $(find . -maxdepth 3 -name pom.xml|sort --dictionary-order); do
44+
find_existing_version_pom "${pom_file}"
45+
done
46+
47+
exit ${return_code}

java-notification/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
6+
<groupId>com.google.cloud</groupId>
67
<artifactId>google-cloud-notification</artifactId>
78
<version>0.123.22-beta-SNAPSHOT</version><!-- {x-version-update:google-cloud-notification:current} -->
89
<packaging>jar</packaging>

0 commit comments

Comments
 (0)