@TaskAction
    public void run() throws IOException, InterruptedException
    {
        if (!portalUsername.isPresent())
        {
            return; // release is not configured
        }

        if (snapshotRelease.get())
        {
            return; // snapshots are published directly
        }

        final HttpClient httpClient = HttpClient.newBuilder()
            .connectTimeout(CONNECTION_TIMEOUT)
            .build();

        final String userNameAndPassword = portalUsername.get() + ":" + portalPassword.get();
        final String bearer = new String(
            Base64.getEncoder().encode(userNameAndPassword.getBytes(US_ASCII)), US_ASCII);

        final HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
            .header("Authorization", "Bearer " + bearer);

        final URI apiUri = URI.create(CENTRAL_PORTAL_OSSRH_API_URI);

        final String repositoryKey = findOpenRepository(apiUri, httpClient, requestBuilder);
        uploadRepositoryToPortal(apiUri, httpClient, requestBuilder, repositoryKey);
        dropRepository(apiUri, httpClient, requestBuilder, repositoryKey);
    }
Publish staging repository to the Central Portal.
buildSrc/src/main/java/uk/co/real_logic/sbe/build/SonatypeCentralPortalUploadRepositoryTask.java