diff --git a/.github/gradle/pace-snapshot-publishing.init.gradle b/.github/gradle/pace-snapshot-publishing.init.gradle new file mode 100644 index 00000000..eb9e5267 --- /dev/null +++ b/.github/gradle/pace-snapshot-publishing.init.gradle @@ -0,0 +1,20 @@ +import java.util.concurrent.TimeUnit +import org.gradle.api.publish.maven.tasks.PublishToMavenRepository + +// The snapshot workflow runs with --no-parallel. Space out its remote publications. +def publicationInterval = TimeUnit.SECONDS.toNanos(30) +long nextPublication = System.nanoTime() + +gradle.beforeProject { project -> + project.tasks.withType(PublishToMavenRepository).configureEach { publication -> + publication.doFirst { + if (publication.repository.url.toString() == 'https://central.sonatype.com/repository/maven-snapshots/') { + long wait = nextPublication - System.nanoTime() + if (wait > 0) { + TimeUnit.NANOSECONDS.sleep(wait) + } + nextPublication = System.nanoTime() + publicationInterval + } + } + } +} diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index ca0e0879..d84cec46 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -20,7 +20,7 @@ jobs: publish-snapshot: runs-on: ubuntu-latest if: github.repository == 'vRallev/app-platform' - timeout-minutes: 60 + timeout-minutes: 110 steps: - uses: actions/checkout@v4 @@ -33,8 +33,9 @@ jobs: - name: Publish snapshot run: | - ./gradlew clean publish -PRELEASE_SIGNING_ENABLED=true --no-build-cache --stacktrace --show-version --no-configuration-cache - ./gradlew -p gradle-plugin clean publish -PRELEASE_SIGNING_ENABLED=true --no-build-cache --stacktrace --show-version --no-configuration-cache + publish_flags=(--init-script "$PWD/.github/gradle/pace-snapshot-publishing.init.gradle" --no-parallel -Dorg.gradle.internal.network.retry.initial.backOff=10000) + ./gradlew clean publish -PRELEASE_SIGNING_ENABLED=true --no-build-cache --stacktrace --show-version --no-configuration-cache "${publish_flags[@]}" + ./gradlew -p gradle-plugin clean publish -PRELEASE_SIGNING_ENABLED=true --no-build-cache --stacktrace --show-version --no-configuration-cache "${publish_flags[@]}" env: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_PORTAL_USERNAME_RALF }} ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PORTAL_PASSWORD_RALF }}