From f698064674889ef3a67bae0ab9d82ab6e58fd66e Mon Sep 17 00:00:00 2001 From: Up Date: Thu, 29 Feb 2024 07:33:40 +0100 Subject: [PATCH] update publishing information --- .github/workflows/build.yml | 22 ------ .github/workflows/build_status.yml | 32 ++++++++ .github/workflows/release.yml | 69 +++++++++++++++++ build.gradle | 117 +++++++++++++++++++---------- gradle.properties | 13 ++-- gradle/libs.versions.toml | 4 +- settings.gradle | 2 + src/main/resources/quilt.mod.json | 47 ++++++++---- 8 files changed, 226 insertions(+), 80 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/build_status.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 347744c..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Build Mod -on: push - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up Eclipse Temurin 21 - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 21 - - name: Build with Gradle - run: gradle build - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: build-artifacts - path: build/libs diff --git a/.github/workflows/build_status.yml b/.github/workflows/build_status.yml new file mode 100644 index 0000000..d611042 --- /dev/null +++ b/.github/workflows/build_status.yml @@ -0,0 +1,32 @@ +name: Build Status + +on: + push: + paths-ignore: + - '.github/**' + branches: + - '*' + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'microsoft' + java-version: 17 + cache: 'gradle' + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + - name: Build with Gradle + run: ./gradlew build + - name: Upload build artifacts (Quilt) + continue-on-error: true + uses: actions/upload-artifact@v4 + with: + name: ${{ github.event.repository.name }}-Quilt-${{ github.sha }} + path: | + build/libs/!(*-@(dev|slim)).jar diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..47e5c30 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,69 @@ +name: Upload Release Artifacts + +on: + push: + tags: + - '*' + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'microsoft' + java-version: 17 + - name: Get current time + uses: srfrnk/current-time@master + id: current-time + with: + format: YYYYMMDDHHmmss + - name: Setup ENV + run: echo "TAG=${{ github.ref_name }}" >> $GITHUB_ENV + - name: Copy Maven Upload URL + id: extract_maven_upload_url + run: echo "maven_upload_url=${{secrets.MAVEN_UPLOAD_URL}}" >> $GITHUB_OUTPUT + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + - name: Build with Gradle + env: + BUILD_TIME: ${{ steps.current-time.outputs.formattedTime }} + BUILD_NUMBER: ${{ github.run_number }} + run: ./gradlew assemble + - name: Maven Release + if: steps.extract_maven_upload_url.outputs.maven_upload_url + continue-on-error: true + run: ./gradlew publish + env: + BUILD_TIME: ${{ steps.current-time.outputs.formattedTime }} + BUILD_NUMBER: ${{ github.run_number }} + MAVEN_UPLOAD_URL: ${{ secrets.MAVEN_UPLOAD_URL }} + MAVEN_UPLOAD_USERNAME: ${{ secrets.MAVEN_UPLOAD_USERNAME }} + MAVEN_UPLOAD_PASSWORD: ${{ secrets.MAVEN_UPLOAD_PASSWORD }} + - name: Upload build artifacts (Quilt) + continue-on-error: true + uses: actions/upload-artifact@v4 + with: + name: ${{ github.event.repository.name }}-Quilt-${{ github.sha }} + path: | + build/libs/!(*-@(dev|slim)).jar + - name: Publish (GitHub Releases) + continue-on-error: true + uses: Kir-Antipov/mc-publish@423b200ec84e6eefad726549c72513d7a9b4c2c0 # (new) v3.3 + with: + github-token: ${{ github.token }} + files: | + build/libs/!(*-@(dev|sources|javadoc|slim)).jar + build/libs/*-@(sources|javadoc).jar + - name: Publish (Quilt) + continue-on-error: true + uses: Kir-Antipov/mc-publish@423b200ec84e6eefad726549c72513d7a9b4c2c0 # (new) v3.3 + with: + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} + version: ${{ github.ref_name }}+Quilt + files: | + build/libs/!(*-@(dev|sources|javadoc|slim)).jar + build/libs/*-@(sources|javadoc).jar diff --git a/build.gradle b/build.gradle index 18e6548..1a1d3c6 100644 --- a/build.gradle +++ b/build.gradle @@ -3,12 +3,27 @@ plugins { alias libs.plugins.quilt.loom } -base { - archivesName = project.archives_base_name +// messy workaround for bug in quilt loom 1.3.3+ +project.configurations.configureEach { + exclude(group: "net.fabricmc", module: "fabric-loader") + exclude(group: "net.fabricmc.fabric-api") } -version = "$project.version+${libs.versions.minecraft.get()}" -group = project.maven_group +def javaVersion = 17 + +group = project.maven_group_id + +def ENV = System.getenv() +def NOW = new Date(); +def buildTime = ENV.BUILD_TIME ?: NOW.format('yyyyMMddHHmmss') + +boolean isPreviewBuild = !ENV.TAG || ENV.TAG.matches(".+-.+") +def buildNumber = !ENV.TAG ? ("${ENV.BUILD_NUMBER ? "build.${ENV.BUILD_NUMBER}" : buildTime}") : "" +version = (ENV.TAG ?: "${libs.versions.minecraft.get()}-development") + ((isPreviewBuild && !ENV.TAG) ? "+${buildNumber}" : "") + +base { + archivesName = "${rootProject.name}-Quilt" +} repositories { mavenCentral() @@ -18,10 +33,13 @@ repositories { loom { mods { - "ok_zoomer" { + "${project.mod_id}" { sourceSet("main") } } + mixin { + defaultRefmapName.set("${project.mod_id}.refmap.json") + } } // All the dependencies are declared at gradle/libs.version.toml and referenced with "libs." @@ -33,65 +51,88 @@ dependencies { modImplementation libs.quilt.loader modImplementation libs.quilted.fabric.api - modImplementation(libs.mod.menu) { - transitive = false - } - modImplementation libs.libzoomer - modImplementation(libs.spruceui) { - transitive = false - } + modCompileOnly libs.modmenu + modLocalRuntime libs.modmenu + + modImplementation libs.libzoomer include libs.libzoomer + + modImplementation libs.spruceui include libs.spruceui } processResources { - inputs.property 'version', version + filteringCharset "UTF-8" - filesMatching('quilt.mod.json') { - expand 'version': version - } -} + def expandProps = [ + "version" : version, + "maven_group_id" : maven_group_id, + "mod_id" : mod_id, + "minecraft_version" : libs.versions.minecraft.get(), + "curseforge_id" : curseforge_id, + "modrinth_id" : modrinth_id, -tasks.withType(JavaCompile).configureEach { - it.options.encoding = 'UTF-8' - // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. - it.options.release = 17 + "quilt_loader_version" : libs.versions.quilt.loader.get(), + ] + + filesMatching(['*.mod.json', '*.mixins.json']) { + expand expandProps + } + inputs.properties(expandProps) } java { - // Still required by IDEs such as Eclipse and Visual Studio Code - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + toolchain { + languageVersion = JavaLanguageVersion.of(javaVersion) + vendor = JvmVendorSpec.MICROSOFT + } + withSourcesJar() +// withJavadocJar() + } - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task if it is present. - // If you remove this line, sources will not be generated. - withSourcesJar() - - // If this mod is going to be a library, then it should also generate Javadocs in order to aid with developement. - // Uncomment this line to generate them. - // withJavadocJar() +jar { + from('LICENSE') { + rename { "LICENSE_${base.archivesName.get()}" } + } } -jar { +sourcesJar { from('LICENSE') { - rename { "${it}_${base.archivesName.get()}" } + rename { "LICENSE_${base.archivesName.get()}" } } } +tasks.withType(JavaCompile).configureEach { + it.options.encoding = 'UTF-8' + it.options.release = 17 +} + +// Disables Gradle's custom module metadata from being published to maven. The +// metadata includes mapped dependencies which are not reasonably consumable by +// other mod developers. +tasks.withType(GenerateModuleMetadata).configureEach { + enabled = false +} + // Configure the maven publication publishing { publications { mavenJava(MavenPublication) { + artifactId "${rootProject.name}-Quilt" from components.java } } - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. repositories { - // Add repositories to publish to here. - // Notice: This block does NOT have the same function as the block in the top level. - // The repositories here will be used for publishing your artifact, not for - // retrieving dependencies. + if (ENV.MAVEN_UPLOAD_URL) { + maven { + url = ENV.MAVEN_UPLOAD_URL + credentials { + username = ENV.MAVEN_UPLOAD_USERNAME + password = ENV.MAVEN_UPLOAD_PASSWORD + } + } + } } } diff --git a/gradle.properties b/gradle.properties index fb3a3a2..37b9f5a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,11 @@ # Gradle Properties -org.gradle.jvmargs = -Xmx1G -org.gradle.parallel = true +org.gradle.jvmargs=-Xmx1G +org.gradle.parallel=true # Mod Properties -version = 5.0.2 -maven_group = io.github.ennuil -archives_base_name = ok_zoomer +mod_id=ok_zoomer + +# Publishing +maven_group_id=io.github.ennuil.ok-zoomer +curseforge_id=354047 +modrinth_id=aXf2OSFU diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e9b5115..ad0609e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,7 +6,7 @@ quilt_loader = "0.23.1" quilted_fabric_api = "8.0.0-alpha.4+0.91.6-1.20.2" libzoomer = "0.8.0+1.20.1" -mod_menu = "8.0.1" +modmenu = "8.0.1" spruceui = "5.0.3+1.20.2" [libraries] @@ -16,7 +16,7 @@ quilt_loader = { module = "org.quiltmc:quilt-loader", version.ref = "quilt_loade quilted_fabric_api = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-api", version.ref = "quilted_fabric_api" } libzoomer = { module = "io.github.ennuil:LibZoomer", version.ref = "libzoomer" } -mod_menu = { module = "com.terraformersmc:modmenu", version.ref = "mod_menu" } +modmenu = { module = "com.terraformersmc:modmenu", version.ref = "modmenu" } spruceui = { module = "dev.lambdaurora:spruceui", version.ref = "spruceui" } [plugins] diff --git a/settings.gradle b/settings.gradle index 6908847..2a852b3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,3 +11,5 @@ pluginManagement { gradlePluginPortal() } } + +rootProject.name = 'OkZoomer' diff --git a/src/main/resources/quilt.mod.json b/src/main/resources/quilt.mod.json index 3b2c04c..7609b8a 100644 --- a/src/main/resources/quilt.mod.json +++ b/src/main/resources/quilt.mod.json @@ -1,8 +1,8 @@ { "schema_version": 1, "quilt_loader": { - "group": "io.github.ennuil", - "id": "ok_zoomer", + "group": "${maven_group_id}", + "id": "${mod_id}", "version": "${version}", "metadata": { "name": "Ok Zoomer", @@ -11,9 +11,9 @@ "Ennui Langeweile": "Owner" }, "contact": { - "homepage": "https://modrinth.com/mod/ok-zoomer", - "issues": "https://github.com/EnnuiL/OkZoomer/issues", - "sources": "https://github.com/EnnuiL/OkZoomer" + "homepage": "https://modrinth.com/mod/${modrinth_id}", + "issues": "https://github.com/Up-Mods/OkZoomer/issues", + "sources": "https://github.com/Up-Mods/OkZoomer" }, "license": "MIT", "icon": "assets/ok_zoomer/icon.png" @@ -22,19 +22,30 @@ "depends": [ { "id": "quilt_loader", - "versions": ">=0.23.0-" - }, - { - "id": "libzoomer", - "versions": ">=0.8.0" + "versions": ">=${quilt_loader_version}" }, { "id": "quilted_fabric_api", - "versions": ">=7.0.0" + "mc-publish": { + "curseforge": "634179", + "modrinth": "qvIfYCYJ" + } }, { + "id": "minecraft", + "versions": "=${minecraft_version}" + }, + { "id": "mixinextras", - "versions": ">=0.3.0" + "mc-publish": { + "ignore": true + } + }, + { + "id": "libzoomer", + "mc-publish": { + "modrinth": "UuqHBjf9" + } } ], "entrypoints": { @@ -53,5 +64,15 @@ "minecraft": { "environment": "client" }, - "mixin": "ok_zoomer.mixins.json" + "mixin": "ok_zoomer.mixins.json", + "mc-publish": { + "curseforge": "${curseforge_id}", + "modrinth": "${modrinth_id}", + "loaders": [ + "quilt" + ], + "dependencies": [ + "libzoomer(required)#(ignore:curseforge)" + ] + } }