Skip to content

Commit 45306d4

Browse files
committed
Stabilize publication promotion
Publication promotion (also known as artifact promotion) promotes a published publication on the Forge files site to become the "latest" version it displays. It also updates the files site and makes it aware of the new version of the project that was just pushed to the maven. This is designed for internal use only by Forge projects, or for projects that have trusted access to the Forge maven. However, it is not a requirement for all Forge projects to be promoted on the files site. As a reminder, promotion is requested like this in your buildscript (Groovy DSL): ```groovy publishing { repositories { maven gradleutils.publishingForgeMaven } publications.register('pluginMaven', MavenPublication) { gradleutils.promote(it) // ... } } ```
1 parent 40cf188 commit 45306d4

File tree

6 files changed

+15
-8
lines changed

6 files changed

+15
-8
lines changed

.github/workflows/publish.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ jobs:
1717
with:
1818
java: 17
1919
gradle_tasks: ':gradleutils-shared:check :check :gradleutils-shared:publish :publish :publishPlugins'
20-
artifact_name: 'gradleutils,gradleutils-shared'
2120
secrets:
2221
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
2322
PROMOTE_ARTIFACT_WEBHOOK: ${{ secrets.PROMOTE_ARTIFACT_WEBHOOK }}

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ publishing {
137137

138138
publications.register('pluginMaven', MavenPublication) {
139139
changelog.publish(it)
140+
gradleutils.promote(it)
140141

141142
pom { pom ->
142143
name = projectDisplayName

gradleutils-shared/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ publishing {
9090
publications.register('mavenJava', MavenPublication) {
9191
from components.java
9292

93+
gradleutils.promote(it)
94+
9395
pom { pom ->
9496
name = projectDisplayName
9597
description = project.description

settings.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ plugins {
1313
// NOTE: We need to load this into the classpath before GradleUtils for the service to load correctly
1414
id 'io.freefair.javadoc-links' version '8.14' apply false // https://plugins.gradle.org/plugin/io.freefair.javadoc-links
1515

16-
id 'net.minecraftforge.gradleutils' version '3.0.0' // https://plugins.gradle.org/plugin/net.minecraftforge.gradleutils
17-
id 'net.minecraftforge.gitversion' version '3.0.0' // https://plugins.gradle.org/plugin/net.minecraftforge.gitversion
16+
id 'net.minecraftforge.gradleutils' version '3.1.4' // https://plugins.gradle.org/plugin/net.minecraftforge.gradleutils
17+
id 'net.minecraftforge.gitversion' version '3.0.2' // https://plugins.gradle.org/plugin/net.minecraftforge.gitversion
1818
}
1919

2020
rootProject.name = 'gradleutils'
@@ -34,7 +34,7 @@ dependencyResolutionManagement {
3434
version 'gradle-javadoc-links', '8.14'
3535

3636
plugin 'licenser', 'net.minecraftforge.licenser' version '1.2.0' // https://plugins.gradle.org/plugin/net.minecraftforge.licenser
37-
plugin 'changelog', 'net.minecraftforge.changelog' version '3.0.0' // https://plugins.gradle.org/plugin/net.minecraftforge.changelog
37+
plugin 'changelog', 'net.minecraftforge.changelog' version '3.0.2' // https://plugins.gradle.org/plugin/net.minecraftforge.changelog
3838
plugin 'plugin-publish', 'com.gradle.plugin-publish' version '1.3.1' // https://plugins.gradle.org/plugin/com.gradle.plugin-publish
3939
plugin 'shadow', 'com.gradleup.shadow' version '9.0.2' // https://plugins.gradle.org/plugin/com.gradleup.shadow
4040

src/main/groovy/net/minecraftforge/gradleutils/PromotePublication.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111

1212
/// This task promotes a publication to the <a href="https://files.minecraftforge.net">Forge Files Site</a>.
1313
///
14-
/// @apiNote This task is still [experimental][ApiStatus.Experimental]. It may be buggy and is subject to change.
15-
@ApiStatus.Experimental
14+
/// @apiNote This task is [internal][org.jetbrains.annotations.ApiStatus.Internal] as it is meant for use in Forge
15+
/// projects only.
16+
@ApiStatus.Internal
1617
public sealed interface PromotePublication extends Task permits PromotePublicationInternal {
1718
/// The publication group to promote.
1819
///

src/main/groovy/net/minecraftforge/gradleutils/PromotePublicationImpl.groovy

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import org.gradle.api.DefaultTask
1111
import org.gradle.api.plugins.BasePluginExtension
1212
import org.gradle.api.provider.ProviderFactory
1313
import org.gradle.api.publish.maven.MavenPublication
14+
import org.gradle.api.publish.plugins.PublishingPlugin
1415
import org.gradle.api.tasks.TaskAction
1516

1617
import javax.inject.Inject
@@ -26,6 +27,9 @@ import java.time.Duration
2627

2728
@Inject
2829
PromotePublicationImpl(MavenPublication publication) {
30+
this.group = PublishingPlugin.PUBLISH_TASK_GROUP
31+
this.description = "Publishes Maven publication '${publication.name}' to the Forge Files site."
32+
2933
this.artifactGroup.convention(this.providers.provider(this.project.&getGroup).map(Object.&toString)).set(this.providers.provider(publication.&getGroupId))
3034
this.artifactName.convention(this.project.extensions.getByType(BasePluginExtension).archivesName).set(this.providers.provider(publication.&getArtifactId))
3135
this.artifactVersion.convention(this.providers.provider(this.project.&getVersion).map(Object.&toString)).set(this.providers.provider(publication.&getVersion))
@@ -45,7 +49,7 @@ import java.time.Duration
4549
@TaskAction
4650
void exec() {
4751
var client = HttpClient.newBuilder().tap {
48-
sslParameters(SSLContext.default.defaultSSLParameters.tap { protocols = ["TLSv1.3"] })
52+
sslParameters(SSLContext.default.defaultSSLParameters.tap { protocols = ['TLSv1.3'] })
4953
}.build()
5054

5155
var request = HttpRequest.newBuilder().tap {
@@ -62,7 +66,7 @@ import java.time.Duration
6266
}.build()
6367

6468
var response = client.send(request, HttpResponse.BodyHandlers.ofString())
65-
if (response.statusCode() != 200)
69+
if (response.statusCode() !== 200)
6670
throw new RuntimeException("Failed to promote artifact: ${response.statusCode()} ${response.body()}")
6771
}
6872
}

0 commit comments

Comments
 (0)