-
Notifications
You must be signed in to change notification settings - Fork 1.1k
ci: adding a non-required check to ensure no existing version on release PR #8788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c3ba90a
ci: adding a check to ensure no existing version
suztomo 42e1ecd
chore: release please
suztomo f0ec55c
change permission
suztomo 717932e
ci: adding the check
suztomo 9e9bf52
test
suztomo 2075c1b
ci: install libxml2-utils
suztomo 8c94d33
run only for Release Please pull request
suztomo 0261f54
ok to have google-cloud-java snapshot
suztomo 0c82d17
reorder groupId and artifactId
suztomo 98d5f22
no need to reorder
suztomo ed3dddc
finish til end
suztomo a51d5bf
check parser check
suztomo f39f10d
parse test
suztomo 06e463c
format in gapic-libraries-bom
suztomo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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