Created
April 26, 2023 19:25
-
-
Save kepocnhh/c4ea04b8f9ce22387bdcf6ee3e9f02a9 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
VARIANT='snapshot' | |
gradle clean && \ | |
gradle "lib:assemble${VARIANT}MavenMetadata" && \ | |
gradle "lib:assemble${VARIANT}Jar" && \ | |
gradle "lib:assemble${VARIANT}Pom" | |
if test $? -ne 0; then | |
echo 'Assemble error!'; exit 1; fi | |
FILE="lib/build/xml/maven-metadata.xml" | |
if [[ ! -f "$FILE" ]]; then echo "File \"$FILE\" does not exist!"; exit 1; fi | |
if [[ ! -s "$FILE" ]]; then echo "File \"$FILE\" is empty!"; exit 1; fi | |
GROUP_ID="$(yq -p=xml -o=xml .metadata.groupId "$FILE")" | |
ARTIFACT_ID="$(yq -p=xml -o=xml .metadata.artifactId "$FILE")" | |
VERSION="$(yq -p=xml -o=xml -e .metadata.versioning.versions.version "$FILE")" || exit 1 | |
echo "Enter Maven snapshot username:" | |
read MAVEN_SNAPSHOT_USER | |
echo "Enter Maven snapshot password:" | |
read -s MAVEN_SNAPSHOT_PASSWORD | |
for it in MAVEN_SNAPSHOT_USER MAVEN_SNAPSHOT_PASSWORD GROUP_ID ARTIFACT_ID VERSION; do | |
if test -z "${!it}"; then echo "Argument \"$it\" is empty!"; exit 1; fi; done | |
LOCAL="lib/build/xml" | |
REMOTE="https://s01.oss.sonatype.org/content/repositories/snapshots/${GROUP_ID//.//}/${ARTIFACT_ID}" | |
FILE="maven-metadata.xml" | |
if [[ ! -f "$LOCAL/$FILE" ]]; then echo "File \"$FILE\" does not exist!"; exit 1; fi | |
if [[ ! -s "$LOCAL/$FILE" ]]; then echo "File \"$FILE\" is empty!"; exit 1; fi | |
curl --user "$MAVEN_SNAPSHOT_USER:$MAVEN_SNAPSHOT_PASSWORD" --upload-file "$LOCAL/$FILE" "$REMOTE/$FILE" | |
if test $? -ne 0; then echo "Upload \"$FILE\" error!"; exit 1; fi | |
LOCAL="lib/build/libs" | |
for it in 'jar' 'pom'; do | |
FILE="${ARTIFACT_ID}-${VERSION}.$it" | |
if [[ ! -f "$LOCAL/$FILE" ]]; then echo "File \"$FILE\" does not exist!"; exit 1; fi | |
if [[ ! -s "$LOCAL/$FILE" ]]; then echo "File \"$FILE\" is empty!"; exit 1; fi | |
curl --user "$MAVEN_SNAPSHOT_USER:$MAVEN_SNAPSHOT_PASSWORD" --upload-file "$LOCAL/$FILE" "$REMOTE/${VERSION}/$FILE" | |
if test $? -ne 0; then echo "Upload \"$FILE\" error!"; exit 1; fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment