xerial / sbt-sonatype

A sbt plugin for publishing Scala/Java projects to the Maven central.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Found multiple staging repositories

jamesward opened this issue · comments

I'd like to do this:

sbt +publishSigned sonatypeRelease

But I often run into issues because there are multiple staging repos (due to other releases going on). This also prevents me from using sonatypeReleaseAll. Is there any way for sonatypeRelease to know what staging repo was created by publishSigned and use that? Or maybe a new task that can publish and release?

Hi. Currently we can explicitly open a staging repository using sonatypeOpen ..., but it’s not convenient to use as we need to check the name of the staging repository created at Sonatype by looking at the display logs.

I’ve been thinking re-designing sbt-sonatype so that we can seamlessly support concurrent releases and idempotent executions (upon any failures).

Thanks! Wish I had some cycles to help. I'm so thankful for your plugin!

Yep, would also love to see a fix for this. A short-term solution might be to improve the error message and add sonatypeDropAll so there's an easy way to clean up and try again.

So, guys. Those who have issues with sbt publishing (like low speed, multiple repositories and non-transactional behaviour)may drastically improve their experience by using this simple ant script (which utilizes nexus-specific APIs):

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:staging="antlib:org.sonatype.nexus.ant.staging">
    <property environment="env"/>
    <!-- https://oss.sonatype.org/ -->
    <property name="nexus.uri" value="${env.NEXUS_URI}" />
    <property name="nexus.user" value="${env.NEXUS_USER}" />
    <property name="nexus.pass" value="${env.NEXUS_PASS}" />
    <property name="dir.repo" value="${env.DIR_REPO}" />
    <property name="nexus.profile" value="${env.NEXUS_PROFILE}" />

    <taskdef uri="antlib:org.sonatype.nexus.ant.staging"
            resource="org/sonatype/nexus/ant/staging/antlib.xml">
    <classpath>
        <fileset dir="tasks" includes="nexus-staging-ant-tasks-*uber.jar" />
    </classpath>
    </taskdef>

    <staging:nexusStagingInfo id="target-nexus" stagingDirectory="target/staging">
        <staging:projectInfo
                groupId="org.sonatype.nexus.ant"
                artifactId="nexus-staging-ant-tasks"
                stagingProfileId="${nexus.profile}"
                version="1.0" />
        <staging:connectionInfo
            baseUrl="${nexus.uri}">
            <staging:authentication
            username="${nexus.user}"
            password="${nexus.pass}" />
        </staging:connectionInfo>
    </staging:nexusStagingInfo>

    <target name="deploy" description="Deploy: Local and Remote Staging">
        <staging:stageLocally>
            <staging:nexusStagingInfo refid="target-nexus" />
            <fileset dir="${dir.repo}" includes="**/*.*" />
        </staging:stageLocally>

        <staging:stageRemotely>
            <staging:nexusStagingInfo refid="target-nexus" />
        </staging:stageRemotely>

        <staging:releaseStagingRepository>
            <staging:nexusStagingInfo refid="target-nexus" />
        </staging:releaseStagingRepository>

        <staging:dropStagingRepository>
            <staging:nexusStagingInfo refid="target-nexus" />
        </staging:dropStagingRepository>
    </target>

</project>

More instructions here

In order to prepare your artifacts for this script you would need the following sbt setting:

   publishTo := Some(Resolver.file("file", new File("/path/to/repo"))), 

Use ant deploy to run.

In my case this simple trick allowed to decrease publishing time from ~40..80 minutes to 2 minutes...

@tpolecat sonatypeDropAll is added.

@jamesward sbt-sonatype 3.0 can support idempotent release with:
; sonatypePrepare; publishSigned; sonatypeRelease

Let me close the issue.

@xerial : it should fix the most annoying integrity issue, though it does not address insanely slow uploads. Maybe it's a good idea to incorporate a fast uploader into your plugin as well?..

@pshirshov I'd like to add such a feature to reduce my pain to upload artifacts. I still don't fully understand what your ant script does (rather what org.sonatype.nexus.ant.staging does) behind the scene. If I can understand the trick it would be possible to improve sbt-sonatype plugin.

Yeah, that's correct.

The ant script, essentially, just sends a zip file of the full maven layout to sonatype trough nexus-specific API.

Nice. So instead of using publishSigned directly to sonatype repo:

  1. Create a bundle (= the artifacts of publishLocalSigned) locally
  2. Upload it using the bundle upload API
  3. Do the regular close/promote step at Sonatype API

@pshirshov I'll move the discussion to #89 as the issue title doesn't match the conversation.