Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ internal class CurseForgeClient(
logger,
)

suspend fun uploadFile(spec: ReleaseArtifact) = uploadFile(spec.artifact.toFile()) {
suspend fun uploadFile(
spec: ReleaseArtifact,
excludeVersions: List<String> = emptyList(),
) = uploadFile(spec.artifact.toFile()) {
displayName(spec.displayName)
releaseType(spec.versionType.toCurseForge())

Expand All @@ -45,7 +48,7 @@ internal class CurseForgeClient(
spec.loaders,
spec.curseForgeEnvironments,
spec.curseForgeJavaVersions,
spec.curseForgeMinecraftVersions,
spec.curseForgeMinecraftVersions.filterNot(excludeVersions::contains),
).flatten().forEach(::addGameVersion)

spec.relationships.forEach { (slug, _, type) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,25 @@ internal class DefaultCurseForgePlatform(

override suspend fun publishRelease(metadata: ReleaseMetadata, artifacts: List<ReleaseArtifact>) {
artifacts.forEach { spec ->
logger.info { "publishing artifact ${spec.name}" }
client.uploadFile(spec)
try {
logger.info { "publishing artifact ${spec.name}" }
client.uploadFile(spec)
} catch (e: IllegalArgumentException /* TODO: InvalidCurseVersionException */) {
val infix = " is not a valid game version."
e.message?.takeIf { infix in it }?.let { msg ->
// TODO: CurseUpload4J 1.1.1's `InvalidCurseVersionException` will list all invalid versions.
val invalid = listOf(msg.substringBefore(infix))

// CurseForge has flaky support for snapshot versions,
// so retry if all invalid versions end in '-snapshot'.
if (invalid.all { it.endsWith("-snapshot") }) {
logger.warn { "retrying ${spec.name} without invalid snapshot versions: $invalid" }
client.uploadFile(spec, excludeVersions = invalid)
return@forEach
}
}
throw e
}
}
}
}
Loading