Skip to content

Commit

Permalink
add publishing to maven
Browse files Browse the repository at this point in the history
  • Loading branch information
realRobotix committed Nov 22, 2024
1 parent 1a1f22a commit 15e5d83
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 36 deletions.
21 changes: 7 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,13 @@ jobs:
- name: Build jar
run: ./gradlew chiseledBuild

# TODO: Fix publishing to Maven repositories
# - name: Publish to GitHub Packages
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# if: env.GITHUB_TOKEN != ''
# continue-on-error: true
# run: ./gradlew publishMavenJavaPublicationToGitHubPackagesRepository
#
# - name: Publish to realRobotix Maven
# env:
# MAVEN_USER: ${{ secrets.MAVEN_USER }}
# MAVEN_ACCESS_TOKEN: ${{ secrets.MAVEN_ACCESS_TOKEN }}
# if: env.MAVEN_USER != '' && env.MAVEN_ACCESS_TOKEN != ''
# run: ./gradlew publishMavenJavaPublicationToRealRobotixMavenRepository -PrealRobotixMavenUsername=${{ secrets.MAVEN_USER }} -PrealRobotixMavenPassword=${{ secrets.MAVEN_ACCESS_TOKEN }}
- name: Publish to Maven Repository
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_ACCESS_TOKEN: ${{ secrets.MAVEN_ACCESS_TOKEN }}
if: env.MAVEN_USER != '' && env.MAVEN_ACCESS_TOKEN != '' && env.GITHUB_TOKEN != ''
run: ./gradlew chiseledPublish -PrealRobotixMavenUsername=${{ secrets.MAVEN_USER }} -PrealRobotixMavenPassword=${{ secrets.MAVEN_ACCESS_TOKEN }}

- name: Find jars
id: find_jars
Expand Down
24 changes: 8 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,14 @@ jobs:
RELEASE: true
run: ./gradlew chiseledBuild

# TODO: Fix publishing to Maven repositories
# - name: Publish to GitHub Packages
# env:
# RELEASE: true
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# if: env.GITHUB_TOKEN != ''
# continue-on-error: true
# run: ./gradlew publishMavenJavaPublicationToGitHubPackagesRepository
#
# - name: Publish to realRobotix Maven
# env:
# RELEASE: true
# MAVEN_USER: ${{ secrets.MAVEN_USER }}
# MAVEN_ACCESS_TOKEN: ${{ secrets.MAVEN_ACCESS_TOKEN }}
# if: env.MAVEN_USER != '' && env.MAVEN_ACCESS_TOKEN != ''
# run: ./gradlew publishMavenJavaPublicationToRealRobotixMavenRepository -PrealRobotixMavenUsername=${{ secrets.MAVEN_USER }} -PrealRobotixMavenPassword=${{ secrets.MAVEN_ACCESS_TOKEN }}
- name: Publish to Maven Repository
env:
RELEASE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAVEN_USER: ${{ secrets.MAVEN_USER }}
MAVEN_ACCESS_TOKEN: ${{ secrets.MAVEN_ACCESS_TOKEN }}
if: env.MAVEN_USER != '' && env.MAVEN_ACCESS_TOKEN != '' && env.GITHUB_TOKEN != ''
run: ./gradlew chiseledPublish -PrealRobotixMavenUsername=${{ secrets.MAVEN_USER }} -PrealRobotixMavenPassword=${{ secrets.MAVEN_ACCESS_TOKEN }}

- name: Find jars
id: find_jars
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@file:Suppress("UnstableApiUsage")

plugins {
`maven-publish`
id("dev.architectury.loom")
id("architectury-plugin")
}
Expand Down
13 changes: 12 additions & 1 deletion fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import java.util.*


plugins {
`maven-publish`
id("dev.architectury.loom")
id("architectury-plugin")
id("com.github.johnrengelman.shadow")
Expand Down Expand Up @@ -146,7 +147,6 @@ dependencies {
shadowBundle(project(common.path, "transformProductionFabric")) { isTransitive = false }
}


java {
withSourcesJar()
val java = if (stonecutter.eval(minecraftVersion, ">=1.20.5"))
Expand All @@ -155,6 +155,17 @@ java {
sourceCompatibility = java
}

publishing {
publications {
create<MavenPublication>("mavenJava") {
artifact(tasks.remapJar)
artifact(tasks.remapSourcesJar)
group = mod.group
artifactId = mod.id
}
}
}

tasks.shadowJar {
exclude("architectury.common.json")
configurations = listOf(shadowBundle)
Expand Down
15 changes: 13 additions & 2 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


plugins {
`maven-publish`
id("dev.architectury.loom")
id("architectury-plugin")
id("com.github.johnrengelman.shadow")
Expand All @@ -18,7 +19,7 @@ val release = System.getenv("RELEASE")?.toBoolean() ?: false
val nightly = ci && !release
val buildNumber = System.getenv("GITHUB_RUN_NUMBER")?.toIntOrNull()
version = "${mod.version}${if (release) "" else "-dev"}+mc.${minecraftVersion}-${loader}${if (nightly) "-build.${buildNumber}" else ""}"
group = mod.group
group = "${mod.group}.$loader"
base {
archivesName.set(mod.id)
}
Expand Down Expand Up @@ -113,7 +114,6 @@ dependencies {
shadowBundle(project(common.path, "transformProductionForge")) { isTransitive = false }
}


java {
withSourcesJar()
val java = if (stonecutter.eval(minecraftVersion, ">=1.20.5"))
Expand All @@ -122,6 +122,17 @@ java {
sourceCompatibility = java
}

publishing {
publications {
create<MavenPublication>("mavenJava") {
artifact(tasks.remapJar)
artifact(tasks.remapSourcesJar)
group = mod.group
artifactId = mod.id
}
}
}

tasks.jar {
archiveClassifier = "dev"
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
37 changes: 35 additions & 2 deletions stonecutter.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import org.gradle.kotlin.dsl.support.uppercaseFirstChar

plugins {
`maven-publish`
id("dev.kikugie.stonecutter")
id("dev.architectury.loom") version "1.6-SNAPSHOT" apply false
id("architectury-plugin") version "3.4-SNAPSHOT" apply false
Expand All @@ -14,15 +15,28 @@ stonecutter registerChiseled tasks.register("chiseledBuild", stonecutter.chisele
ofTask("buildAndCollect")
}

// Builds loader-specific versions into `build/libs/{mod.version}/{loader}`
stonecutter registerChiseled tasks.register("chiseledPublish", stonecutter.chiseled) {
group = "project"
ofTask("publish")
}

for (it in stonecutter.tree.branches) {
if (it.id.isEmpty()) continue
val loader = it.id.uppercaseFirstChar()
val loader = it.id.upperCaseFirst()

// Builds loader-specific versions into `build/libs/{mod.version}/{loader}`
stonecutter registerChiseled tasks.register("chiseledBuild$loader", stonecutter.chiseled) {
group = "project"
versions { branch, _ -> branch == it.id }
ofTask("buildAndCollect")
}

// Publishes loader-specific versions
stonecutter registerChiseled tasks.register("chiseledPublish$loader", stonecutter.chiseled) {
group = "project"
versions { branch, _ -> branch == it.id }
ofTask("publish")
}
}

// Runs active versions for each loader
Expand All @@ -37,6 +51,7 @@ for (it in stonecutter.tree.nodes) {
}

subprojects {
apply(plugin = "maven-publish")
repositories {
mavenCentral()
// mappings
Expand Down Expand Up @@ -74,4 +89,22 @@ subprojects {
dir("libs")
}
}
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/cannoneers-of-create/createbigcannons")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
}
}
maven {
name = "realRobotixMaven"
url = uri("https://maven.realrobotix.me/createbigcannons")
credentials(PasswordCredentials::class)
}
mavenLocal()
}
}
}

0 comments on commit 15e5d83

Please sign in to comment.