Skip to content

Commit

Permalink
Stop using Bintray to publish to Maven Central
Browse files Browse the repository at this point in the history
This commit reworks the CI pipeline to remove the use of Bintray for
publishing to Maven Central. In its place it adds a new
publishToCentral command to the release scripts. This command can be
used to publish a directory tree of artifacts to the Maven Central
gateway hosted by Sonatype.

Publishing consists of 4 steps:

1. Create the staging repository
2. Deploy artifacts to the repository
3. Close the repository
4. Release the repository

The command requires 3 arguments:

1. The type of release being performed
2. Location of a build info JSON file that describes the release
   that is to be deployed
3. Root of a directory structure, in Maven repository layout, that
   contains the artifacts to be deployed

Closes gh-25107
  • Loading branch information
wilkinsona committed Feb 17, 2021
1 parent 29d46c8 commit 98ee724
Show file tree
Hide file tree
Showing 184 changed files with 2,320 additions and 1,502 deletions.
5 changes: 5 additions & 0 deletions ci/images/releasescripts/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
<spring-javaformat.version>0.0.26</spring-javaformat.version>
</properties>
<dependencies>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpg-jdk15to18</artifactId>
<version>1.68</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@
package io.spring.concourse.releasescripts.artifactory;

import java.net.URI;
import java.time.Duration;
import java.util.Set;

import io.spring.concourse.releasescripts.ReleaseInfo;
import io.spring.concourse.releasescripts.artifactory.payload.BuildInfoResponse;
import io.spring.concourse.releasescripts.artifactory.payload.DistributionRequest;
import io.spring.concourse.releasescripts.artifactory.payload.PromotionRequest;
import io.spring.concourse.releasescripts.bintray.BintrayService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -53,17 +49,11 @@ public class ArtifactoryService {

private static final String BUILD_INFO_URL = ARTIFACTORY_URL + "/api/build/";

private static final String DISTRIBUTION_URL = ARTIFACTORY_URL + "/api/build/distribute/";

private static final String STAGING_REPO = "libs-staging-local";

private final RestTemplate restTemplate;

private final BintrayService bintrayService;

public ArtifactoryService(RestTemplateBuilder builder, ArtifactoryProperties artifactoryProperties,
BintrayService bintrayService) {
this.bintrayService = bintrayService;
public ArtifactoryService(RestTemplateBuilder builder, ArtifactoryProperties artifactoryProperties) {
String username = artifactoryProperties.getUsername();
String password = artifactoryProperties.getPassword();
if (StringUtils.hasLength(username)) {
Expand Down Expand Up @@ -116,37 +106,6 @@ private boolean isAlreadyPromoted(String buildName, String buildNumber, String t
}
}

/**
* Deploy builds from Artifactory to Bintray.
* @param sourceRepo the source repo in Artifactory.
* @param releaseInfo the resease info
* @param artifactDigests the artifact digests
*/
public void distribute(String sourceRepo, ReleaseInfo releaseInfo, Set<String> artifactDigests) {
logger.debug("Attempting distribute via Artifactory");
if (!this.bintrayService.isDistributionStarted(releaseInfo)) {
startDistribute(sourceRepo, releaseInfo);
}
if (!this.bintrayService.isDistributionComplete(releaseInfo, artifactDigests, Duration.ofMinutes(60))) {
throw new DistributionTimeoutException("Distribution timed out.");
}
}

private void startDistribute(String sourceRepo, ReleaseInfo releaseInfo) {
DistributionRequest request = new DistributionRequest(new String[] { sourceRepo });
RequestEntity<DistributionRequest> requestEntity = RequestEntity
.post(URI.create(DISTRIBUTION_URL + releaseInfo.getBuildName() + "/" + releaseInfo.getBuildNumber()))
.contentType(MediaType.APPLICATION_JSON).body(request);
try {
this.restTemplate.exchange(requestEntity, Object.class);
logger.debug("Distribute call completed");
}
catch (HttpClientErrorException ex) {
logger.info("Failed to distribute.");
throw ex;
}
}

private PromotionRequest getPromotionRequest(String targetRepo) {
return new PromotionRequest("staged", STAGING_REPO, targetRepo);
}
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 98ee724

Please sign in to comment.