File tree Expand file tree Collapse file tree 2 files changed +38
-27
lines changed Expand file tree Collapse file tree 2 files changed +38
-27
lines changed Original file line number Diff line number Diff line change @@ -212,6 +212,8 @@ test_examples_manual:
212212 - build_manual
213213 script :
214214 - ./gradlew publish
215+ # Trigger deployment from same IP to ensure Sonatype can find the staging repository
216+ - ./gradlew triggerDeployment
215217
216218publish :
217219 extends : .publish_base
@@ -222,33 +224,6 @@ publish_manual:
222224 extends : .publish_base
223225 when : manual
224226
225- # # trigger deployment
226-
227- .trigger_deployment_base :
228- extends : .publish
229- stage : publish
230- image : curlimages/curl:8.14.1
231- script :
232- - NAMESPACE="com.deepl.api"
233- - URL="https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/$NAMESPACE"
234- - PARAMS="publishing_type=automatic"
235- - BEARER_TOKEN=$(echo "${ORG_GRADLE_PROJECT_mavenUploadUsername}:${ORG_GRADLE_PROJECT_mavenUploadPassword}" | base64)
236- - |
237- curl "$URL?$PARAMS" --header "Authorization: Bearer $BEARER_TOKEN" -d "" --write-out "%{http_code}\n"
238-
239- trigger_deployment :
240- extends : .trigger_deployment_base
241- dependencies :
242- - publish
243- rules :
244- - if : ' $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
245-
246- trigger_deployment_manual :
247- extends : .trigger_deployment_base
248- dependencies :
249- - publish_manual
250- when : manual
251-
252227# # gitlab release
253228
254229gitlab release :
Original file line number Diff line number Diff line change 1+ import java.net.HttpURLConnection
2+ import java.net.URL
3+ import java.util.Base64
4+
15plugins {
26 `java- library`
37 `maven- publish`
@@ -124,3 +128,35 @@ signing {
124128 sign(publishing.publications[" mavenJava" ])
125129}
126130
131+ tasks.register(" triggerDeployment" ) {
132+ doLast {
133+ val mavenUploadUsername: String? by project
134+ val mavenUploadPassword: String? by project
135+ val namespace = " com.deepl.api"
136+ val url = " https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/$namespace ?publishing_type=automatic"
137+
138+ val credentials = " $mavenUploadUsername :$mavenUploadPassword "
139+ val encodedCredentials = Base64 .getEncoder().encodeToString(credentials.toByteArray())
140+
141+ val connection = URL (url).openConnection() as HttpURLConnection
142+ connection.requestMethod = " POST"
143+ connection.setRequestProperty(" Authorization" , " Bearer $encodedCredentials " )
144+ connection.doOutput = true
145+ connection.outputStream.write(byteArrayOf())
146+
147+ val responseCode = connection.responseCode
148+ val response = if (responseCode == 200 ) {
149+ connection.inputStream.bufferedReader().readText()
150+ } else {
151+ connection.errorStream.bufferedReader().readText()
152+ }
153+
154+ println (response)
155+ println (" HTTP Status: $responseCode " )
156+
157+ if (responseCode != 200 ) {
158+ throw GradleException (" Failed to trigger deployment: $responseCode - $response " )
159+ }
160+ }
161+ }
162+
You can’t perform that action at this time.
0 commit comments