Skip to content

Commit e12ebcf

Browse files
committed
fix
1 parent 21e5498 commit e12ebcf

1 file changed

Lines changed: 25 additions & 11 deletions

File tree

.github/workflows/release-thin.yml

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ jobs:
5151
VERSION=$(grep -m1 '<version>' pom.xml | sed 's/.*<version>\(.*\)<\/version>.*/\1/')
5252
test -f "target/databricks-jdbc-${VERSION}-thin.jar"
5353
54+
- name: Snapshot open Central repositories (pre-upload)
55+
env:
56+
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
57+
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
58+
run: |
59+
curl -s -u "$MAVEN_CENTRAL_USERNAME:$MAVEN_CENTRAL_PASSWORD" \
60+
"https://ossrh-staging-api.central.sonatype.com/manual/search/repositories?state=open" \
61+
| grep -o '"key":"[^"]*"' | cut -d':' -f2 | tr -d '"' > pre_keys.txt
62+
echo "Pre-upload open repos:"; cat pre_keys.txt | sed 's/^/ /'
63+
5464
- name: Publish Thin JAR as Separate Artifact to Maven Central
5565
run: |
5666
VERSION=$(grep -m1 '<version>' pom.xml | sed 's/.*<version>\(.*\)<\/version>.*/\1/')
@@ -73,15 +83,19 @@ jobs:
7383
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
7484
run: |
7585
VERSION=$(grep -m1 '<version>' pom.xml | sed 's/.*<version>\(.*\)<\/version>.*/\1/')
76-
echo "Locating open staging repository..."
77-
RESP=$(curl -s -u "$MAVEN_CENTRAL_USERNAME:$MAVEN_CENTRAL_PASSWORD" \
78-
"https://ossrh-staging-api.central.sonatype.com/manual/search/repositories?state=open")
79-
COUNT=$(echo "$RESP" | grep -o '"key":"[^"]*"' | wc -l | tr -d ' ')
80-
if [ "$COUNT" -ne 1 ]; then
81-
echo "Expected exactly 1 open repository, found $COUNT. Refusing to publish to avoid selecting the wrong repo.";
82-
echo "$RESP"; exit 1;
83-
fi
84-
KEY=$(echo "$RESP" | grep -o '"key":"[^"]*"' | tail -1 | cut -d':' -f2 | tr -d '"')
85-
echo "Publishing repo $KEY..."
86+
echo "Finding the newly opened repo for databricks-jdbc-thin ${VERSION}..."
87+
NEWKEY=""
88+
for i in $(seq 1 12); do
89+
curl -s -u "$MAVEN_CENTRAL_USERNAME:$MAVEN_CENTRAL_PASSWORD" \
90+
"https://ossrh-staging-api.central.sonatype.com/manual/search/repositories?state=open" \
91+
| grep -o '"key":"[^"]*"' | cut -d':' -f2 | tr -d '"' > post_keys.txt
92+
for k in $(cat post_keys.txt); do
93+
if ! grep -qx "$k" pre_keys.txt; then NEWKEY="$k"; break; fi
94+
done
95+
if [ -n "$NEWKEY" ]; then break; fi
96+
echo "Waiting for new repo to appear... ($i/12)"; sleep 5;
97+
done
98+
if [ -z "$NEWKEY" ]; then echo "Could not identify newly opened repository for thin upload."; echo "Open repos:"; cat post_keys.txt; exit 1; fi
99+
echo "Publishing repo $NEWKEY..."
86100
curl -s -X POST -u "$MAVEN_CENTRAL_USERNAME:$MAVEN_CENTRAL_PASSWORD" \
87-
"https://ossrh-staging-api.central.sonatype.com/manual/upload/repository/${KEY}?publishing_type=user_managed" | cat
101+
"https://ossrh-staging-api.central.sonatype.com/manual/upload/repository/${NEWKEY}?publishing_type=user_managed" | cat

0 commit comments

Comments
 (0)