From b210d0540e7923f1da279f7e95d7a9cc51f6dfd7 Mon Sep 17 00:00:00 2001 From: Lucas Petrino Date: Tue, 16 Jan 2024 14:52:17 +1300 Subject: [PATCH] Update build scripts - add publish to modrinth script - add publish to curseforge script - update build and release ci - fix spelling in README.md Signed-off-by: Lucas Petrino --- .github/workflows/build.yml | 10 ++++-- .github/workflows/release.yml | 6 ++-- README.md | 2 +- build.gradle.kts | 62 ++++++++++++++++++++++++++++++++++- fabric/build.gradle.kts | 2 ++ forge/build.gradle.kts | 2 ++ 6 files changed, 78 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2d98c9c..a49bca3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,6 +8,8 @@ on: jobs: build: runs-on: ubuntu-latest + env: + CI_DEV_BUILD: true steps: - uses: actions/checkout@v3 - name: Set up JDK 17 @@ -15,6 +17,8 @@ jobs: with: java-version: '17' distribution: 'temurin' + - name: Setup build number + run: echo "BUILD_NUMBER=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV - name: Make gradlew executable run: chmod +x ./gradlew - name: Build with Gradle @@ -24,5 +28,7 @@ jobs: - name: Upload Build Results uses: actions/upload-artifact@v3 with: - name: build - path: build/libs/*.jar \ No newline at end of file + name: weather-changer-build + path: | + fabric/build/**/*.jar + forge/build/**/*.jar \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ca2c338..7c1bdf1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,9 @@ jobs: uses: actions/upload-artifact@v3 with: name: build - path: build/libs/*.jar + path: | + fabric/build/**/*.jar + forge/build/**/*.jar release: runs-on: ubuntu-latest @@ -40,7 +42,7 @@ jobs: - name: Create Release run: | mkdir dist - mv build/*.jar dist + mv build/**/*.jar dist pushd dist shasum -a 256 * > checksums.txt diff --git a/README.md b/README.md index 1743c82..6e0e2b0 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Changes the weather on client side (only visible to you) to clear, rain, or thun The command alias `/cweather` may also be used as a shortcut. ### Keybindings -To set the keybindings you can do so in the minecraft keyBase bind settings. +To set the keybindings you can do so in the minecraft keybinding settings. | Description | Default | |----------------------------------------------------------------------------------|---------| diff --git a/build.gradle.kts b/build.gradle.kts index dc2d320..0d5bf69 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,13 @@ +import io.github.themrmilchmann.gradle.publish.curseforge.ChangelogFormat +import io.github.themrmilchmann.gradle.publish.curseforge.GameVersion +import io.github.themrmilchmann.gradle.publish.curseforge.ReleaseType +import net.fabricmc.loom.task.RemapJarTask + plugins { id("architectury-plugin") version "3.4-SNAPSHOT" id ("dev.architectury.loom") version "1.3-SNAPSHOT" apply false + id("com.modrinth.minotaur") version "2.+" + id("io.github.themrmilchmann.curseforge-publish") version "0.6.1" } architectury { @@ -15,6 +22,10 @@ subprojects { "minecraft"("com.mojang:minecraft:${properties["minecraft_version"]}") "mappings"("net.fabricmc:yarn:${rootProject.properties["yarn_mappings"]}:v2") } + + tasks.named("remapJar", RemapJarTask::class) { + archiveBaseName.set(properties["archives_base_name"].toString() + archiveBaseName) + } } allprojects { @@ -22,7 +33,12 @@ allprojects { apply(plugin = "maven-publish") apply(plugin = "architectury-plugin") - version = properties["mod_version"].toString() + version = if (System.getenv("CI_DEV_BUILD")?.toBoolean() == true) { + System.getenv("BUILD_NUMBER") ?: properties["mod_version"].toString() + } else { + properties["mod_version"].toString() + } + group = properties["maven_group"].toString() tasks.withType { @@ -33,4 +49,48 @@ allprojects { tasks.withType { archiveBaseName.set(properties["archives_base_name"].toString()) } +} + +modrinth { + token.set(System.getenv("MODRINTH_TOKEN")) + projectId.set("nhSHTGyl") + versionNumber.set(properties["mod_version"].toString()) + versionType.set(properties["release_channel"].toString()) + uploadFile.set("build/libs/weather-changer-1.0.0.jar") + gameVersions.addAll("1.20", "1.20.1", "1.20.2", "1.20.3", "1.20.4") + + loaders.add("fabric") + loaders.add("forge") + + dependencies { + required.project("fabric-api") + } + + syncBodyFrom = rootProject.file("README.md").readText() +} + +curseforge { + publications { + register("curseForge") { + projectId = "682513" + + gameVersions.add(GameVersion("minecraft-1-20", "1.20")) + gameVersions.add(GameVersion("minecraft-1-20", "1.20.1")) + gameVersions.add(GameVersion("minecraft-1-20", "1.20.2")) + gameVersions.add(GameVersion("minecraft-1-20", "1.20.3")) + gameVersions.add(GameVersion("minecraft-1-20", "1.20.4")) + + artifacts.register("main") { + displayName = "Weather Changer" + // TODO: read from file + releaseType = ReleaseType.BETA + + changelog { + // TODO: get from git diff + format = ChangelogFormat.MARKDOWN + from(file("CHANGELOG.md")) + } + } + } + } } \ No newline at end of file diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 1a961da..b310fee 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -41,6 +41,8 @@ tasks { "fabric_loader_version" to rootProject.property("fabric.loader_version") )) } + + exclude("architectury.common.json") } remapJar { diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index 40f9294..9d4051f 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -48,6 +48,8 @@ tasks { "minecraft_version" to rootProject.property("minecraft_version") )) } + + exclude("architectury.common.json") } remapJar {