Skip to content

Commit

Permalink
Fix release script
Browse files Browse the repository at this point in the history
  • Loading branch information
NotRyken committed Jan 5, 2025
1 parent 825841d commit 90b2545
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 32 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ jobs:
run: chmod +x ./gradlew
- name: Build
# run: ./gradlew build neoforge:publishGithub fabric:publishGithub --stacktrace
run: ./gradlew build neoforge:publishGithub neoforge:publishModrinth neoforge:publishCurseforge fabric:publishGithub fabric:publishModrinth fabric:publishCurseforge --stacktrace
run: ./gradlew build neoforge:publishGithub neoforge:publishModrinth fabric:publishGithub fabric:publishModrinth --stacktrace
# run: ./gradlew build neoforge:publishGithub neoforge:publishModrinth neoforge:publishCurseforge fabric:publishGithub fabric:publishModrinth fabric:publishCurseforge --stacktrace
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
Expand Down
51 changes: 20 additions & 31 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,26 @@ subprojects {
displayName = "v${mod_version}-${capsLoader(project.name)}"
modLoaders.addAll(project.property("release_mod_loaders_${project.name}").split(","))
maxRetries = 5
boolean missingToken = false

github {
dryRun = providers.environmentVariable("GITHUB_TOKEN").getOrNull() == null
accessToken = providers.environmentVariable("GITHUB_TOKEN")
parent project(":").tasks.named("publishGithub")
String token = providers.environmentVariable("GITHUB_TOKEN").getOrNull()
missingToken = (missingToken || token == null || token.isBlank())
accessToken = token
repository = github_repo
commitish = grgitService.service.get().grgit.branch.current().name
tagName = "v${mod_version}-${capsLoader(project.name)}"
additionalFiles.from(sourcesJar.archiveFile)
String versions = "## Minecraft Versions\n"
project.property("release_game_versions_${project.name}").split(",").each {
versions = "${versions}\n- ${it}"
}
changelog = versions + "\n\n## Changelog\n\n" + versionChangelog()
}
modrinth {
dryRun = providers.environmentVariable("MODRINTH_TOKEN").getOrNull() == null
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
String token = providers.environmentVariable("MODRINTH_TOKEN").getOrNull()
missingToken = (missingToken || token == null || token.isBlank())
accessToken = token
projectId = modrinth_id
minecraftVersions.addAll(project.property("release_game_versions_${project.name}").split(","))
changelog = versionChangelog()
Expand Down Expand Up @@ -79,8 +90,9 @@ subprojects {
projectDescription = providers.fileContents(layout.projectDirectory.file("README.md")).asText
}
curseforge {
dryRun = providers.environmentVariable("CURSEFORGE_TOKEN").getOrNull() == null
accessToken = providers.environmentVariable("CURSEFORGE_TOKEN")
String token = providers.environmentVariable("CURSEFORGE_TOKEN").getOrNull()
missingToken = (missingToken || token == null || token.isBlank())
accessToken = token
projectId = curseforge_id
projectSlug = curseforge_slug
minecraftVersions.addAll(project.property("release_game_versions_${project.name}").split(","))
Expand All @@ -106,35 +118,12 @@ subprojects {
}
}
}
dryRun = missingToken
}
}
}
}

publishMods {
// This task is necessary to allow publishing files from multiple
// subprojects to a single GitHub release.
version = mod_version
type = me.modmuss50.mpp.ReleaseType.of(release_type)
github {
dryRun = providers.environmentVariable("GITHUB_TOKEN").getOrNull() == null
accessToken = providers.environmentVariable("GITHUB_TOKEN")
repository = github_repo
commitish = grgitService.service.get().grgit.branch.current().name
tagName = "v${mod_version}"
allowEmptyFiles = true
// Include compatible MC version lists in description
String versions = "## MC versions\n\n"
if (project.hasProperty("release_game_versions_fabric"))
versions = String.format("%s - Fabric: %s\n", versions,
project.property("release_game_versions_fabric"))
if (project.hasProperty("release_game_versions_neoforge"))
versions = String.format("%s - NeoForge: %s\n", versions,
project.property("release_game_versions_neoforge"))
changelog = versions + "\n\n## Changelog\n\n" + versionChangelog()
}
}

String versionChangelog() {
List<String> lines = rootProject.file("CHANGELOG.md").readLines()
StringBuilder builder = new StringBuilder()
Expand Down

0 comments on commit 90b2545

Please sign in to comment.