Skip to content

Commit 97cbaee

Browse files
committed
try fix publish script
1 parent 91c0683 commit 97cbaee

1 file changed

Lines changed: 52 additions & 40 deletions

File tree

‎build.gradle‎

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ plugins {
1111

1212
id 'com.github.breadmoirai.github-release' version '2.5.2'
1313
id 'com.modrinth.minotaur' version '2.+'
14-
id 'net.darkhax.curseforgegradle' version '1.1.16'
14+
id 'net.darkhax.curseforgegradle' version '1.3.+'
1515
id 'net.ltgt.errorprone' version '5.1.0'
1616
id 'net.neoforged.moddev' version '2.+'
1717
id 'org.jetbrains.changelog' version '1.3.0'
@@ -32,10 +32,14 @@ wrapper {
3232
def isSnapshotVersion = project.hasProperty('teamcityBuild')
3333
def githubUser = 'IntelligenceModding'
3434
def githubRepo = 'AdvancedPeripherals'
35+
def curseforgeProjectId = 431725
36+
def modrinthProjectId = 'SOw6jD6x'
3537

3638
version = "${mod_version}" + (isSnapshotVersion ? "-SNAPSHOT" : "") + "${mod_artifact_suffix}"
3739
group = 'de.srendi.advancedperipherals'
3840

41+
def fullVersionTag = "${minecraft_version}-${project.version}"
42+
3943
def static getenv(path = ".env") {
4044
def env = [:]
4145

@@ -361,7 +365,7 @@ dependencies {
361365
changelog {
362366
version = "${project.version}"
363367
path = "${project.projectDir}/CHANGELOG.md"
364-
header = "[${minecraft_version}-${-> version.get()}] - ${new SimpleDateFormat("yyyy-MM-dd").format(new Date())}"
368+
header = "[${fullVersionTag}] - ${new SimpleDateFormat("yyyy-MM-dd").format(new Date())}"
365369
// Valid patterns would be:
366370
// 1.16.5-1.1.1.1b
367371
// 1.18-1.0r
@@ -440,39 +444,6 @@ tasks.withType(ProcessResources).configureEach {
440444
}
441445
}
442446

443-
tasks.register('publishCurseForge', TaskPublishCurseForge, { task ->
444-
setGroup("publishing")
445-
setDescription("Upload Advanced Peripherals to CurseForge")
446-
447-
// This token is used to authenticate with CurseForge. It should be handled
448-
// with the same level of care and security as your actual password. You
449-
// should never share your token with an untrusted source or publish it
450-
// publicly to GitHub or embed it within a project. The best practice is to
451-
// store this token in an environment variable or a build secret.
452-
apiToken = curseforgeKey
453-
454-
// Tells CurseForgeGradle to publish the output of the jar task. This will
455-
// return a UploadArtifact object that can be used to further configure the
456-
// file.
457-
task.upload(431725, jar) { file ->
458-
try {
459-
file.changelog = "${project.changelog.get("${minecraft_version}-${project.version}").withHeader(false).toText()}"
460-
file.changelogType = "markdown"
461-
} catch (err) {
462-
System.out.println(err)
463-
file.changelog = ""
464-
}
465-
466-
addOptional('applied-energistics-2', 'curios', 'mekanism', 'refined-storage')
467-
468-
addRequirement('cc-tweaked')
469-
470-
addModLoader("neoforge")
471-
472-
releaseType = "${release_type}"
473-
}
474-
})
475-
476447
tasks.register("copyBlockTextures", Copy) {
477448
from 'src/generated/block-textures'
478449
into "src/generated/resources/assets/${project.mod_id}/textures/block"
@@ -497,12 +468,12 @@ githubRelease {
497468
token = githubKey
498469
owner = githubUser
499470
repo = githubRepo
500-
tagName = "${minecraft_version}-${version}"
501-
releaseName = "${minecraft_version}-${version}"
502-
targetCommitish = "release/${minecraft_version}"
471+
tagName = fullVersionTag
472+
releaseName = fullVersionTag
473+
targetCommitish = System.getenv("GITHUB_REF_NAME")
503474
generateReleaseNotes = false
504475
try {
505-
body = project.changelog.get("${minecraft_version}-${version}").withHeader(false).toText()
476+
body = project.changelog.get("${fullVersionTag}").withHeader(false).toText()
506477
} catch (err) {
507478
System.out.println(err)
508479
body = ""
@@ -511,9 +482,50 @@ githubRelease {
511482
prerelease = release_type.equalsIgnoreCase("alpha")
512483
}
513484

485+
tasks.register('publishCurseForge', TaskPublishCurseForge, { task ->
486+
setGroup("publishing")
487+
setDescription("Upload Advanced Peripherals to CurseForge")
488+
489+
// This token is used to authenticate with CurseForge. It should be handled
490+
// with the same level of care and security as your actual password. You
491+
// should never share your token with an untrusted source or publish it
492+
// publicly to GitHub or embed it within a project. The best practice is to
493+
// store this token in an environment variable or a build secret.
494+
apiToken = curseforgeKey
495+
496+
// Tells CurseForgeGradle to publish the output of the jar task. This will
497+
// return a UploadArtifact object that can be used to further configure the
498+
// file.
499+
task.upload(curseforgeProjectId, jar) { file ->
500+
releaseType = "${release_type}"
501+
502+
addGameVersion(minecraft_version)
503+
addModLoader('neoforge')
504+
addRequirement('cc-tweaked')
505+
addOptional(
506+
'applied-energistics-2',
507+
'create',
508+
'curios',
509+
'dimstorage',
510+
'mekanism',
511+
'minecolonies',
512+
'powah',
513+
'refined-storage'
514+
)
515+
516+
try {
517+
file.changelog = "${project.changelog.get("${minecraft_version}-${project.version}").withHeader(false).toText()}"
518+
file.changelogType = "markdown"
519+
} catch (err) {
520+
System.out.println(err)
521+
file.changelog = ""
522+
}
523+
}
524+
})
525+
514526
modrinth {
515527
token = modrinthKey
516-
projectId = 'SOw6jD6x'
528+
projectId = modrinthProjectId
517529
versionNumber = "${minecraft_version}-${project.version}"
518530
versionName = "Advanced Peripherals ${minecraft_version} ${version}"
519531
versionType = release_type

0 commit comments

Comments
 (0)