From a4a370ddfc07aa298ed41e48b6b55f2ca6b51627 Mon Sep 17 00:00:00 2001 From: deirn Date: Sat, 27 Jan 2024 18:06:10 +0700 Subject: [PATCH] setup ci --- .editorconfig | 4 ++ .github/workflows/head.yml | 36 ++++++++++ .github/workflows/release.yml | 35 ++++++++++ build.gradle.kts | 1 + buildSrc/src/main/kotlin/GenModsTomlTask.kt | 2 +- buildSrc/src/main/kotlin/Uploads.kt | 7 +- modules/fabric/build.gradle.kts | 65 +++++++++++++++++++ .../applied-energistics-2/build.gradle.kts | 5 +- modules/forge/build.gradle.kts | 49 ++++++++++++++ modules/forge/create/build.gradle.kts | 5 +- .../immersive-engineering/build.gradle.kts | 5 +- 11 files changed, 208 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/head.yml create mode 100644 .github/workflows/release.yml diff --git a/.editorconfig b/.editorconfig index 219c40b..c1779cc 100644 --- a/.editorconfig +++ b/.editorconfig @@ -275,3 +275,7 @@ ij_json_wrap_long_lines = false [{*.kt,*.kts}] ij_continuation_indent_size = 4 + +[{*.yml,*.yaml}] +indent_size = 2 +tab_width = 2 diff --git a/.github/workflows/head.yml b/.github/workflows/head.yml new file mode 100644 index 0000000..0439311 --- /dev/null +++ b/.github/workflows/head.yml @@ -0,0 +1,36 @@ +name: head +on: + push: + branches: + - '**' + tags-ignore: + - '*.*' + pull_request: + branches: + - '**' + tags-ignore: + - '*.*' +jobs: + build: + runs-on: ubuntu-latest + steps: + - id: vars + run: | + echo "git_hash=${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: temurin + - run: chmod +x gradlew + - uses: actions/cache@v3 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-${{ github.ref }}-${{ hashFiles('**/*.gradle.kts') }} + - run: ./gradlew build + env: + GIT_HASH: ${{ steps.vars.outputs.git_hash }} + - uses: actions/upload-artifact@v3 + with: + name: megane-${{ steps.vars.outputs.git_hash }} + path: "./modules/**/build/libs/**.jar" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..feb9b04 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,35 @@ +name: release +on: + push: + tags: "*" +jobs: + build: + runs-on: ubuntu-latest + steps: + - id: vars + run: | + echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: temurin + - run: chmod +x gradlew + - run: ./gradlew build publishMods + env: + MOD_VERSION: ${{ steps.vars.outputs.version }} + CURSEFORGE_API: ${{ secrets.CURSEFORGE_API }} + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} + - uses: actions/upload-artifact@v3 + with: + name: megane-${{ steps.vars.outputs.git_hash }} + path: "./modules/**/build/libs/**.jar" + - uses: alexellis/upload-assets@259de5111cb56966d046ced998941e93f91d2c93 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + asset_paths: | + [ + "./modules/*/build/libs/*[0-9.].jar", + "./modules/*/*/build/libs/*[0-9.].jar", + ] diff --git a/build.gradle.kts b/build.gradle.kts index 229e126..a751a09 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,6 +3,7 @@ import java.nio.charset.StandardCharsets plugins { java id("lol.bai.explosion") version "0.1.0" apply false + id("me.modmuss50.mod-publish-plugin") version "0.4.5" apply false } group = "lol.bai.megane" diff --git a/buildSrc/src/main/kotlin/GenModsTomlTask.kt b/buildSrc/src/main/kotlin/GenModsTomlTask.kt index 519f138..52af99a 100644 --- a/buildSrc/src/main/kotlin/GenModsTomlTask.kt +++ b/buildSrc/src/main/kotlin/GenModsTomlTask.kt @@ -64,7 +64,7 @@ abstract class GenModsTomlTask : DefaultTask() { put("modId", id) put("version", "${project.version}") put("authors", "deirn") - put("logoFile", "megane.jpg") + put("logoFile", "megane.png") if (contributors.get().isNotEmpty()) { put("credits", contributors.get().joinToString(separator = ", ")) diff --git a/buildSrc/src/main/kotlin/Uploads.kt b/buildSrc/src/main/kotlin/Uploads.kt index 0225c3e..5603e17 100644 --- a/buildSrc/src/main/kotlin/Uploads.kt +++ b/buildSrc/src/main/kotlin/Uploads.kt @@ -14,12 +14,15 @@ object cfIds { } object cfSlugs { - val wthit = "wthit" + val wthitFabric = "wthit" + val wthitForge = "wthit-forge" val ae2 = "applied-energistics-2" val alloyForge = "alloy-forgery" val createFabric = "create-fabric" + val createForge = "create" val dml = "deep-mob-learning-refabricated" val extraGen = "extra-generators" + val ie = "immersive-engineering" val indrev = "industrial-revolution" val kibe = "kibe" val lba = "libblockattributes" @@ -39,8 +42,8 @@ object mrIds { val ae2 = "XxWD5pD3" val alloyForge = "jhl28YkY" val architectury = "lhGA9TYQ" - val createForge = "LNytGWDc" val createFabric = "Xbc0uyRg" + val createForge = "LNytGWDc" val dml = "osuPHzT3" val clothConfig = "9s6osm5g" val cofhCore = "OWSRM4vD" diff --git a/modules/fabric/build.gradle.kts b/modules/fabric/build.gradle.kts index f5fd5d3..28ef794 100644 --- a/modules/fabric/build.gradle.kts +++ b/modules/fabric/build.gradle.kts @@ -1,5 +1,60 @@ +import me.modmuss50.mpp.ReleaseType + plugins { id("fabric-loom") version "1.3.+" + + id("me.modmuss50.mod-publish-plugin") +} + +publishMods { + changelog.set("https://github.com/badasintended/megane/releases/tag/${project.version}") + type.set(ReleaseType.STABLE) + modLoaders.add("fabric") + + val curseForgeApi = providers.environmentVariable("CURSEFORGE_API") + val modrinthToken = providers.environmentVariable("MODRINTH_TOKEN") + dryRun.set(!(curseForgeApi.isPresent && modrinthToken.isPresent)) + + curseforge { + projectId.set("408118") + accessToken.set(curseForgeApi) + minecraftVersions.add("1.19.2") + + requires(cfSlugs.wthitFabric) + optional( + cfSlugs.alloyForge, + cfSlugs.ae2, + cfSlugs.createFabric, + cfSlugs.dml, + cfSlugs.extraGen, + cfSlugs.indrev, + cfSlugs.kibe, + cfSlugs.luggage, + cfSlugs.modernDynamics, + cfSlugs.powah, + cfSlugs.rebornCore, + cfSlugs.techReborn, + cfSlugs.wirelessNet, + ) + } + + modrinth { + projectId.set("ZNk5S5U6") + accessToken.set(modrinthToken) + minecraftVersions.add("1.19.2") + + requires(mrIds.wthit) + optional( + mrIds.alloyForge, + mrIds.ae2, + mrIds.createFabric, + mrIds.dml, + mrIds.extraGen, + mrIds.kibe, + mrIds.modernDynamics, + mrIds.powah, + ) + } } allprojects { @@ -68,4 +123,14 @@ afterEvaluate { } } } + + publishMods { + file.set(tasks.jar.get().archiveFile) + } +} + +subprojects { + base { + archivesName.set("megane-fabric-${project.name}") + } } diff --git a/modules/forge/applied-energistics-2/build.gradle.kts b/modules/forge/applied-energistics-2/build.gradle.kts index 1a98b43..718ae89 100644 --- a/modules/forge/applied-energistics-2/build.gradle.kts +++ b/modules/forge/applied-energistics-2/build.gradle.kts @@ -10,7 +10,10 @@ metadata("lol.bai.megane.module.ae2") { forgeFml() packMcmeta() - modsToml() + + modsToml { + depends("ae2" to any) + } } repositories { diff --git a/modules/forge/build.gradle.kts b/modules/forge/build.gradle.kts index 5488027..f0d7089 100644 --- a/modules/forge/build.gradle.kts +++ b/modules/forge/build.gradle.kts @@ -1,9 +1,48 @@ import groovy.lang.GroovyObject +import me.modmuss50.mpp.ReleaseType import net.minecraftforge.gradle.common.util.RunConfig plugins { id("net.minecraftforge.gradle") version "[6.0.16, 6.2)" id("org.spongepowered.mixin") version "0.7.+" + + id("me.modmuss50.mod-publish-plugin") +} + +publishMods { + changelog.set("https://github.com/badasintended/megane/releases/tag/${project.version}") + type.set(ReleaseType.STABLE) + modLoaders.add("forge") + + val curseForgeApi = providers.environmentVariable("CURSEFORGE_API") + val modrinthToken = providers.environmentVariable("MODRINTH_TOKEN") + dryRun.set(!(curseForgeApi.isPresent && modrinthToken.isPresent)) + + curseforge { + projectId.set("965089") + accessToken.set(curseForgeApi) + minecraftVersions.add("1.19.2") + + requires(cfSlugs.wthitForge) + optional( + cfSlugs.ae2, + cfSlugs.createForge, + cfSlugs.ie + ) + } + + modrinth { + projectId.set("pcvCiEEP") + accessToken.set(modrinthToken) + minecraftVersions.add("1.19.2") + + requires(mrIds.wthit) + optional( + mrIds.ae2, + mrIds.createForge, + mrIds.ie + ) + } } allprojects { @@ -120,6 +159,10 @@ tasks { mergeWaila.input.add(genWaila.output) } } + + project.publishMods { + file.set(fatJar.archiveFile) + } } subprojects.forEach { sub -> @@ -143,3 +186,9 @@ subprojects.forEach { sub -> } } } + +subprojects { + base { + archivesName.set("megane-forge-${project.name}") + } +} diff --git a/modules/forge/create/build.gradle.kts b/modules/forge/create/build.gradle.kts index 1c77215..d691951 100644 --- a/modules/forge/create/build.gradle.kts +++ b/modules/forge/create/build.gradle.kts @@ -11,7 +11,10 @@ metadata("lol.bai.megane.module.create") { forgeFml() packMcmeta() language() - modsToml() + + modsToml{ + depends("create" to any) + } } dependencies { diff --git a/modules/forge/immersive-engineering/build.gradle.kts b/modules/forge/immersive-engineering/build.gradle.kts index 08e6581..26439f4 100644 --- a/modules/forge/immersive-engineering/build.gradle.kts +++ b/modules/forge/immersive-engineering/build.gradle.kts @@ -11,7 +11,10 @@ metadata("lol.bai.megane.module.ie") { forgeFml() packMcmeta() language() - modsToml() + + modsToml{ + depends("immersiveengineering" to any) + } } dependencies {