2018-03-13 08:07:15 +08:00
#!/bin/bash
buildName = $( cat artifactory-repo/build-info.json | jq -r '.buildInfo.name' )
buildNumber = $( cat artifactory-repo/build-info.json | jq -r '.buildInfo.number' )
groupId = $( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/\(.*\):.*:.*/\1/' )
version = $( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' )
echo " Syncing ${ buildName } / ${ buildNumber } to Maven Central "
2019-06-17 12:00:31 +08:00
publishStatus = $( curl \
2018-03-13 08:07:15 +08:00
-s \
2019-06-17 12:00:31 +08:00
-o /dev/null \
-I \
2019-06-19 12:04:54 +08:00
-w "%{http_code}" \
2019-06-17 12:00:31 +08:00
" https://oss.sonatype.org/service/local/repositories/releases/content/org/springframework/boot/spring-boot/ ${ version } /spring-boot- ${ version } .jar.sha1 " )
2019-06-19 12:04:54 +08:00
if [ [ ${ publishStatus } = = "200" ] ] ; then
2019-06-17 12:00:31 +08:00
echo "Already published to Sonatype"
else
echo "Calling Bintray to sync to Sonatype"
curl \
-s \
--connect-timeout 240 \
--max-time 2700 \
-u ${ BINTRAY_USERNAME } :${ BINTRAY_API_KEY } \
-H "Content-Type: application/json" -d " {\"username\": \" ${ SONATYPE_USER_TOKEN } \", \"password\": \" ${ SONATYPE_PASSWORD_TOKEN } \"} " \
-f \
-X \
POST " https://api.bintray.com/maven_central_sync/ ${ BINTRAY_SUBJECT } / ${ BINTRAY_REPO } / ${ groupId } /versions/ ${ version } " > /dev/null || { echo "Failed to sync" >& 2; exit 1; }
fi
2018-11-16 03:15:33 +08:00
echo "Sync complete"
2019-03-23 05:23:13 +08:00
echo $version > version/version