Skip to content

Commit

Permalink
Add mod publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
DrexHD committed Sep 30, 2024
1 parent 8b08e9a commit f80f940
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 43 deletions.
41 changes: 0 additions & 41 deletions .github/workflows/publish.yml

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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: 'microsoft'
java-version: 21
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Publish mods
run: ./gradlew build publishMods
env:
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [2.0.0] - 2024-09-30
Initial public release
46 changes: 45 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import org.jetbrains.changelog.Changelog

plugins {
java
id("maven-publish")
id("fabric-loom") version "1.7.+"
kotlin("jvm") version "2.0.20"
id("io.github.goooler.shadow") version "8.1.7"
kotlin("plugin.serialization") version "2.0.20"
id("me.modmuss50.mod-publish-plugin") version "0.7.4"
id("org.jetbrains.changelog") version "2.+"
}

configurations.implementation.get().extendsFrom(configurations.shadow.get())
Expand All @@ -19,7 +23,7 @@ allprojects {

base.archivesName.set(modId)
group = mavenGroup
version = "$modVersion${getVersionMetadata()}"
version = "$modVersion+${rootProject.libs.versions.minecraft.get()}${getVersionMetadata()}"

java {
sourceCompatibility = JavaVersion.VERSION_21
Expand Down Expand Up @@ -118,6 +122,33 @@ dependencies {
}
}

publishMods {
file.set(tasks.remapJar.get().archiveFile)
type.set(STABLE)
changelog.set(fetchChangelog())

displayName.set("Blockbot ${version.get()}")
modLoaders.add("fabric")
modLoaders.add("quilt")

val minecraftVersion = rootProject.libs.versions.minecraft.get()
curseforge {
accessToken.set(providers.environmentVariable("CF_API_TOKEN"))
projectId.set("482904")
minecraftVersions.add(minecraftVersion)
}
modrinth {
accessToken.set(providers.environmentVariable("MODRINTH_TOKEN"))
projectId.set("yKZ9outG")
minecraftVersions.add(minecraftVersion)
}
github {
accessToken.set(providers.environmentVariable("GITHUB_TOKEN"))
repository.set(providers.environmentVariable("GITHUB_REPOSITORY").getOrElse("QuiltServerTools/dryrun"))
commitish.set(providers.environmentVariable("GITHUB_REF_NAME").getOrElse("dryrun"))
}
}

tasks {
remapJar {
dependsOn(shadowJar)
Expand Down Expand Up @@ -200,3 +231,16 @@ fun getVersionMetadata(): String {
// No tracking information could be found about the build
return ""
}

private fun fetchChangelog(): String {
val changelog = tasks.getChangelog.get().changelog.get()
val modVersion: String by project
return if (changelog.has(modVersion)) {
changelog.renderItem(
changelog.get(modVersion).withHeader(false),
Changelog.OutputType.MARKDOWN
)
} else {
""
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Mod
modName = BlockBot Discord
modId = blockbot-discord
modVersion = 2.0.0-beta
modVersion = 2.0.0
mavenGroup = io.github.quiltservertools

# Other
Expand Down

0 comments on commit f80f940

Please sign in to comment.