Skip to content

Commit

Permalink
chore: ✨ Add automated modrinth upload
Browse files Browse the repository at this point in the history
  • Loading branch information
P3pp3rF1y committed Sep 22, 2024
1 parent c384120 commit 5df5e28
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ jobs:
echo "Branch name does not match the pattern: $BRANCH_NAME. Skipping CurseForge upload."
exit 0
fi
- name: Publish to Modrinth
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
run: |
BRANCH_NAME=${GITHUB_REF##*/}
if [[ "$BRANCH_NAME" =~ ^[0-9]+\.[0-9]+\.([0-9]+|x)$ ]]; then
./gradlew modrinth
else
echo "Branch name does not match the pattern: $BRANCH_NAME. Skipping Modrinth upload."
exit 0
fi
- name: Code Quality
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
19 changes: 19 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id 'net.neoforged.moddev' version '1.0.14'
id "org.sonarqube" version "5.0.0.4638"
id "net.darkhax.curseforgegradle" version "1.1.15"
id "com.modrinth.minotaur" version "2.+"
}

idea {
Expand Down Expand Up @@ -342,6 +343,24 @@ task curseforge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) {
onlyIf { !project.ext.changelog.isEmpty() }
}

tasks.modrinth.dependsOn(tasks.generateChangelog)
tasks.modrinth.onlyIf { !project.ext.changelog.isEmpty() }
modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = "${modrinth_project_id}"
versionType = "${release_type}"
uploadFile = jar
gameVersions = "${release_versions}".split(',').collect {e -> e}
loaders = ["neoforge"]
dependencies {
required.project "sophisticated-core"
optional.project "jei"
optional.project "crafting-tweaks"
optional.project "curios-continuation"
}
changelog = "${ project.ext.changelog }"
}

task printVersionName {
println "version:" + project.version
}
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ sc_version=[1.21,1.22)
#publish
curseforge_id=422301
release_type=release
release_versions=1.21,1.21.1
release_versions=1.21,1.21.1
modrinth_project_id=TyCTlI4b

0 comments on commit 5df5e28

Please sign in to comment.