diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0d4034d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,20 @@ +name: release +on: [workflow_dispatch] + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'adopt' + java-version: 21 + - name: Make gradlew executable + run: chmod +x ./gradlew + - name: Publish mods + run: ./gradlew build publishMods + env: + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 90698d5..1de662d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,13 @@ +import org.jetbrains.changelog.Changelog + plugins { id 'fabric-loom' version '1.6-SNAPSHOT' id 'maven-publish' + id "me.modmuss50.mod-publish-plugin" version "0.5.1" + id 'org.jetbrains.changelog' version '2.+' } -version = project.mod_version +version = project.mod_version + "+" + project.minecraft_version group = project.maven_group base { @@ -61,6 +65,42 @@ jar { } } + +publishMods { + file = remapJar.archiveFile + type = STABLE + changelog = fetchChangelog() + + displayName = "VoteListener ${version.get()}" + modLoaders.add("fabric") + modLoaders.add("quilt") + + modrinth { + accessToken = providers.environmentVariable("MODRINTH_TOKEN") + projectId = "Rl1FP1ar" + minecraftVersions.add(project.minecraft_version) + } + github { + accessToken = providers.environmentVariable("GITHUB_TOKEN") + repository = providers.environmentVariable("GITHUB_REPOSITORY").getOrElse("DrexHD/dryrun") + commitish = providers.environmentVariable("GITHUB_REF_NAME").getOrElse("dryrun") + } +} + + +private String fetchChangelog() { + def log = getChangelog.changelog.get() + if (log.has(project.mod_version)) { + return log.renderItem( + log.get(project.mod_version).withHeader(false), + Changelog.OutputType.MARKDOWN + ) + } else { + return "" + } +} + + // configure the maven publication publishing { publications { diff --git a/gradle.properties b/gradle.properties index 4a29578..7712b85 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ minecraft_version=1.21 loader_version=0.15.11 # Mod Properties -mod_version=1.1.0+1.21 +mod_version=1.1.0 maven_group=me.drex.votelistener archives_base_name=votelistener