Skip to content

Commit 07a05d8

Browse files
committed
back to old action approach, make gradle pull just jars if a property is set
1 parent d60dd8c commit 07a05d8

2 files changed

Lines changed: 34 additions & 20 deletions

File tree

.github/workflows/publish.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ jobs:
3232
- name: Build
3333
run: ./gradlew clean build
3434

35-
- name: Tar workspace
36-
run: tar -cf workspace.tar --exclude=workspace.tar .
37-
38-
- name: Upload workspace
35+
- name: Upload built jars
3936
uses: actions/upload-artifact@v7
4037
with:
41-
name: workspace
42-
path: workspace.tar
38+
name: mod-jars
39+
path: |
40+
**/build/libs/*.jar
41+
!**/build/libs/*-sources.jar
42+
!**/build/libs/*-javadoc.jar
43+
!**/build/libs/*-plain.jar
4344
retention-days: 1
4445

4546
publish:
@@ -51,15 +52,14 @@ jobs:
5152
# target: [ maven, modrinth, curseforge ]
5253
target: [ maven ]
5354
steps:
54-
- name: Download workspace
55+
- uses: actions/checkout@v6
56+
57+
- name: Download built jars
5558
uses: actions/download-artifact@v8
5659
with:
57-
name: workspace
60+
name: mod-jars
5861
path: .
5962

60-
- name: Extract workspace
61-
run: tar -xf workspace.tar && rm workspace.tar
62-
6363
- name: Setup Java
6464
uses: actions/setup-java@v5
6565
with:
@@ -72,21 +72,21 @@ jobs:
7272
cache-read-only: true
7373

7474
- name: Publish to ${{ matrix.target }}
75-
run: ./gradlew ${{ matrix.target }}
75+
run: ./gradlew ${{ matrix.target }} -PprebuiltJar
7676

7777
github:
7878
needs: build
7979
runs-on: ubuntu-latest
8080
steps:
81-
- name: Download workspace
81+
- name: Checkout repository
82+
uses: actions/checkout@v6
83+
84+
- name: Download built jars
8285
uses: actions/download-artifact@v8
8386
with:
84-
name: workspace
87+
name: mod-jars
8588
path: .
8689

87-
- name: Extract workspace
88-
run: tar -xf workspace.tar && rm workspace.tar
89-
9090
- name: Get Version
9191
id: get-version
9292
run: |

build.gradle.kts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,19 @@ tasks.jar {
162162
}
163163
}
164164

165+
// if -PprebuiltJar is set then directly point to the jars so we don't run tasks, this is useful for parallel deploys
166+
val prebuiltJar = providers.gradleProperty("prebuiltJar").map { it.toBoolean() }.getOrElse(false)
167+
val modJarFile: Any = if (prebuiltJar) {
168+
layout.buildDirectory.file("libs/${base.archivesName.get()}-${version}.jar").get().asFile
169+
}
170+
else {
171+
loomx.modJar.flatMap { it.archiveFile }
172+
}
173+
165174
modrinth {
166175
token.set(providers.environmentVariable("MODRINTH_TOKEN"))
167176
projectId = "uIvrDZas"
168-
uploadFile.set(loomx.modJar.flatMap { it.archiveFile })
177+
uploadFile.set(modJarFile)
169178
changelog.set(providers.fileContents(rootProject.layout.projectDirectory.file("CHANGELOG.md")).asText)
170179
versionType.set(if (isAlpha) "alpha" else "release")
171180
gameVersions = compatibleVersions
@@ -181,7 +190,7 @@ tasks.register<TaskPublishCurseForge>("curseforge") {
181190

182191
disableVersionDetection()
183192

184-
val mainFile = upload("1149875", loomx.modJar.flatMap { it.archiveFile })
193+
val mainFile = upload("1149875", modJarFile)
185194
mainFile.changelog = providers.fileContents(rootProject.layout.projectDirectory.file("CHANGELOG.md")).asText.orElse("")
186195
mainFile.changelogType = "markdown"
187196
mainFile.releaseType = if (isAlpha) "alpha" else "release"
@@ -197,7 +206,12 @@ publishing {
197206
groupId = property("mod.group") as String
198207
artifactId = property("mod.id") as String
199208
version = mvnVersion
200-
from(components["java"])
209+
if (prebuiltJar) {
210+
artifact(modJarFile)
211+
}
212+
else {
213+
from(components["java"])
214+
}
201215
}
202216
}
203217
repositories {

0 commit comments

Comments
 (0)