diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 851d013..8e81639 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -61,12 +61,6 @@ made regularly. At any given time, the latest code that exists in production can be found under the `main` branch. -#### `next` / `next-major` - -An upcoming major release can be found under the `next` or `next-major` -branches. For example, if `main` is currently on `v2.4.1`, the next major -release is expected to be on `v3.0.0`. - #### `beta` / `alpha` The latest Beta and Alpha releases can be found under the `beta` and `alpha` @@ -117,18 +111,15 @@ pattern `+([0-9])?(.{+([0-9]),x}).x`, e.g. `2.x`. ## Continuous Integration & Deployment (CI/CD) This project uses [GitHub Actions][github:actions] in tandem -with [semantic-release][semantic-release] to automate building, testing and +with [release-please][release-please] to automate building, testing and deploying new versions of the codebase. -Please refer to the following [recipes][semantic-release:recipes] for triggering -new releases. - ### How it works? When new commits make their way into one of the release branches outlined in the [Branching Strategy](#branching-strategy), a -GitHub [workflow][workflow:publish] is triggered. This workflow in turn -executes [semantic-release][semantic-release]. +GitHub [workflow][workflow:release] is triggered. This workflow in turn +executes [release-please][release-please]. ## Code Style @@ -149,7 +140,6 @@ this functionality to your IDE. [conventionalcommits]: https://www.conventionalcommits.org/ [github:actions]: https://github.com/features/actions [github:flow]: https://guides.github.com/introduction/flow -[semantic-release]: https://github.com/semantic-release/semantic-release -[semantic-release:recipes]: https://github.com/semantic-release/semantic-release/blob/v17.4.4/docs/recipes +[release-please]: https://github.com/googleapis/release-please [semver]: https://semver.org/ -[workflow:publish]: workflows/publish.yml +[workflow:release]: workflows/release.yml diff --git a/.github/release-please.json b/.github/release-please.json new file mode 100644 index 0000000..151fe40 --- /dev/null +++ b/.github/release-please.json @@ -0,0 +1,16 @@ +{ + "release-type": "simple", + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": true, + "group-pull-request-title-pattern": "chore: release v${version}", + "extra-files": ["gradle.properties"], + "packages": { + ".": { + "component": "fabric-example-mod", + "include-component-in-tag": false + }, + "example-submod": { + "component": "example-submod" + } + } +} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d101905..61c8ab9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,27 +23,20 @@ jobs: - name: ✨ Checkout repository uses: actions/checkout@v2 - - name: 🛂 Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v1 - - - name: 🏗 Set up JDK 17 + - name: ☕ Set up JDK 17 uses: actions/setup-java@v2 with: java-version: 17 distribution: adopt - - name: 📷 Begin Gradle cache - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- + - name: 🐘 Set up Gradle + uses: gradle/gradle-build-action@v2 + + - name: 🧪 Run tests + run: ./gradlew check - name: 🔨 Build artifacts - run: gradle clean build + run: ./gradlew build publishToMavenLocal - name: 📦 Upload artifacts uses: actions/upload-artifact@v2 @@ -58,7 +51,8 @@ jobs: name: reports path: '**/build/reports/' - - name: 🧨 Cleanup Gradle cache - run: | - rm -f ~/.gradle/caches/modules-2/modules-2.lock - rm -f ~/.gradle/caches/modules-2/gc.properties + - name: 🗃 Upload Maven local + uses: actions/upload-artifact@v2 + with: + name: maven + path: ~/.m2/repository/ diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 99a3c63..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,66 +0,0 @@ -# Builds and publishes any packages - -name: Publish - -# On updates to release branches -on: - push: - branches: - - main - - master - - next - - next-major - - beta - - alpha - paths: - - '**/src/main/**' - - '**/build.gradle' - - '**/gradle.properties' - - '**/settings.gradle' - - .github/workflows/publish.yml - - .releaserc* - - LICENCE.txt - -jobs: - publish: - name: Publish - - runs-on: ubuntu-latest - permissions: - contents: write - issues: write - packages: write - - steps: - - name: ✨ Checkout repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: 🛂 Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v1 - - - name: 🏗 Set up JDK 17 - uses: actions/setup-java@v2 - with: - java-version: 17 - distribution: adopt - - - name: 🏗 Set up Node.js - uses: actions/setup-node@v1 - with: - node-version: 14 - - - name: ⬇ Install Node.js dependencies - run: npm install -g - semantic-release@17 - @semantic-release/git - @semantic-release/changelog - @semantic-release/exec - - - name: 📦 Publish new release - run: semantic-release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} - CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0d29a57 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,57 @@ +# Prepares, builds and publishes new releases + +name: Release + +on: + push: + branches: + - main + - master + workflow_dispatch: + +jobs: + release: + name: Release + + runs-on: ubuntu-latest + + steps: + - name: 🙌 Prepare release + id: release-please + uses: GoogleCloudPlatform/release-please-action@v3 + with: + command: manifest + config-file: .github/release-please.json + token: ${{ secrets.GITHUB_TOKEN }} + + - name: ✨ Checkout repository + if: ${{ steps.release-please.outputs.release_created }} + uses: actions/checkout@v2 + + - name: ☕ Set up JDK 17 + if: ${{ steps.release-please.outputs.release_created }} + uses: actions/setup-java@v2 + with: + java-version: 17 + distribution: adopt + + - name: 🐘 Set up Gradle + if: ${{ steps.release-please.outputs.release_created }} + uses: gradle/gradle-build-action@v2 + + - name: 📢 Publish new release + if: ${{ steps.release-please.outputs.release_created }} + run: ./gradlew publish + env: + CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }} + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} + + - name: 📦 Upload artifacts + if: ${{ steps.release-please.outputs.release_created }} + uses: svenstaro/upload-release-action@v2 + with: + tag: ${{ steps.release-please.outputs.tag_name }} + file: '**/build/libs/*' + file_glob: true + overwrite: true + repo_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..59299b6 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1 @@ +{".":"1.0.0","example-submod":"1.0.0"} diff --git a/.releaserc.yml b/.releaserc.yml deleted file mode 100644 index aba5085..0000000 --- a/.releaserc.yml +++ /dev/null @@ -1,28 +0,0 @@ -# https://semantic-release.gitbook.io - -plugins: - - '@semantic-release/commit-analyzer' - - '@semantic-release/release-notes-generator' - - '@semantic-release/changelog' - - - '@semantic-release/exec' - - verifyConditionsCmd: gradle clean check - prepareCmd: sed -i -E 's/^(mod_version\s*=\s*).*$/\1${nextRelease.version}/I' gradle.properties **/gradle.properties - publishCmd: gradle build publish - - - '@semantic-release/github' - - assets: - - '**/build/libs/**' - - - '@semantic-release/git' - - assets: - - CHANGELOG.md - - '**/gradle.properties' - -branches: - - 'main' - - 'master' - - 'next' - - 'next-major' - - '+([0-9])?(.{+([0-9]),x}).x' - - name: 'beta' - prerelease: true - - name: 'alpha' - prerelease: true diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/build.gradle b/build.gradle index 4d4b7b4..250f64b 100644 --- a/build.gradle +++ b/build.gradle @@ -2,9 +2,9 @@ plugins { id 'java' id 'checkstyle' id 'maven-publish' - id 'com.modrinth.minotaur' version '1.2.1' + id 'com.modrinth.minotaur' version '2.1.1' id 'com.matthewprenger.cursegradle' version '1.4.0' - id 'fabric-loom' version '0.10-SNAPSHOT' + id 'fabric-loom' version '0.11-SNAPSHOT' } allprojects { @@ -96,7 +96,7 @@ curseforge { // Set the release notes changelog = "For a list of changes, please refer to https://github.com/${project.github_repo}/releases/tag/v${project.version}" // Add all supported game versions - project.cf_game_versions.split(',').each { addGameVersion it } + project.cf_game_versions.split(', ').each { addGameVersion it } // Add the main artifact mainArtifact(remapJar) { displayName = "${project.mod_name} v${project.version} for Minecraft ${project.minecraft_version}" } // Add any additional artifacts @@ -109,32 +109,28 @@ curseforge { } // Add any dependencies relations { - if (project.cf_relations_required) project.cf_relations_required.split(',').each { requiredDependency it } - if (project.cf_relations_optional) project.cf_relations_optional.split(',').each { optionalDependency it } - if (project.cf_relations_embedded) project.cf_relations_embedded.split(',').each { embeddedLibrary it } - if (project.cf_relations_tools) project.cf_relations_tools.split(',').each { tool it } - if (project.cf_relations_incompatible) project.cf_relations_incompatible.split(',').each { incompatible it } + if (project.cf_relations_required) project.cf_relations_required.split(', ').each { requiredDependency it } + if (project.cf_relations_optional) project.cf_relations_optional.split(', ').each { optionalDependency it } + if (project.cf_relations_embedded) project.cf_relations_embedded.split(', ').each { embeddedLibrary it } + if (project.cf_relations_tools) project.cf_relations_tools.split(', ').each { tool it } + if (project.cf_relations_incompatible) project.cf_relations_incompatible.split(', ').each { incompatible it } } } // Configure other options options { forgeGradleIntegration = false + debug = System.getenv('CURSEFORGE_DEBUG') as boolean ?: false } } // Define how artifacts are published to Modrinth (https://modrinth.com) -import com.modrinth.minotaur.TaskModrinthUpload -task modrinth(type: TaskModrinthUpload) { - // Set task metadata - description 'Uploads all Modrinth projects' - group 'upload' - allprojects.each { dependsOn it.build } - +import com.modrinth.minotaur.dependencies.ModDependency +modrinth { // Set the API token from the environment token = System.getenv('MODRINTH_TOKEN') ?: '' - onlyIf { !token.isEmpty() } - + // Set whether debug mode is enabled + debugMode = System.getenv('MODRINTH_DEBUG') as boolean ?: false // Set the project id projectId = project.mr_project_id // Set the release name @@ -146,23 +142,23 @@ task modrinth(type: TaskModrinthUpload) { // Set the release notes changelog = "For a list of changes, please refer to https://github.com/${project.github_repo}/releases/tag/v${project.version}" // Add all supported mod loaders - addLoader 'fabric' + loaders = ['fabric'] // Add all supported game versions - project.mr_game_versions.split(',').each { addGameVersion it } + project.mr_game_versions.split(', ').each { gameVersions.add it } // Add the main artifact uploadFile = remapJar -// // Add any additional artifacts -// addFile sourcesJar -// addFile jar -// subprojects.each { -// addFile it.remapJar -// addFile it.sourcesJar -// addFile it.jar -// } + // Add any additional artifacts + additionalFiles.add sourcesJar + additionalFiles.add jar + subprojects.each { + additionalFiles.add it.remapJar + additionalFiles.add it.sourcesJar + additionalFiles.add it.jar + } // Add any dependencies - if (project.mr_relations_required) project.mr_relations_required.split(',').each { addDependency it, 'required' } - if (project.mr_relations_optional) project.mr_relations_optional.split(',').each { addDependency it, 'optional' } - if (project.mr_relations_incompatible) project.mr_relations_incompatible.split(',').each { addDependency it, 'incompatible' } + if (project.mr_relations_required) dependencies.addAll project.mr_relations_required.split(', ').collect { new ModDependency(it, 'required') } + if (project.mr_relations_optional) dependencies.addAll project.mr_relations_optional.split(', ').collect { new ModDependency(it, 'optional') } + if (project.mr_relations_incompatible) dependencies.addAll project.mr_relations_incompatible.split(', ').collect { new ModDependency(it, 'incompatible') } } // Define how packages are published diff --git a/example-submod/CHANGELOG.md b/example-submod/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/example-submod/gradle.properties b/example-submod/gradle.properties index 52b60a4..fbf6f8d 100644 --- a/example-submod/gradle.properties +++ b/example-submod/gradle.properties @@ -1,4 +1,6 @@ # Mod mod_name = Another Example mod_id = modid-sub +## {x-release-please-start-version} mod_version = 1.0.0 +## {x-release-please-end} diff --git a/example-submod/src/main/java/com/example/modid/submod/AnotherExample.java b/example-submod/src/main/java/com/example/modid/submod/AnotherExample.java index c158c46..3747bf1 100644 --- a/example-submod/src/main/java/com/example/modid/submod/AnotherExample.java +++ b/example-submod/src/main/java/com/example/modid/submod/AnotherExample.java @@ -5,6 +5,9 @@ import net.fabricmc.api.ModInitializer; +/** + * Another Example Minecraft mod. + */ public class AnotherExample implements ModInitializer { public static final Logger LOGGER = LogManager.getLogger("modid-sub"); diff --git a/gradle.properties b/gradle.properties index abbd9c4..c5195bf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,24 +1,26 @@ # Mod mod_name = Example mod_id = modid +## {x-release-please-start-version} mod_version = 1.0.0 +## {x-release-please-end} # Fabric -minecraft_version = 1.18 -loader_version = 0.12.8 -yarn_mappings = 1.18+build.1 -fabric_version = 0.44.0+1.18 +minecraft_version = 1.18.2 +loader_version = 0.13.3 +yarn_mappings = 1.18.2+build.2 +fabric_version = 0.48.0+1.18.2 # Dependencies -mod_menu_version = 3.0.0 +mod_menu_version = 3.1.0 -checkstyle_version = 9.2 +checkstyle_version = 10.0 jetbrains_annotations_version = 23.0.0 -junit_jupiter_version = 5.8.1 +junit_jupiter_version = 5.8.2 # CurseForge cf_project_id = 494721 -cf_game_versions = Fabric,Java 17,1.18 +cf_game_versions = Fabric, Java 17, 1.18, 1.18.1, 1.18.2 cf_relations_required = fabric-api cf_relations_optional = modmenu cf_relations_embedded = @@ -27,9 +29,9 @@ cf_relations_incompatible = # Modrinth mr_project_id = dohojEfz -mr_game_versions = 1.18 -mr_relations_required = 5eX37YdU -mr_relations_optional = JPP6w2U1 +mr_game_versions = 1.18, 1.18.1, 1.18.2 +mr_relations_required = P7dR8mSH +mr_relations_optional = mOgUt4GM mr_relations_incompatible = # Publish diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180..41d9927 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102..00e33ed 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 index c53aefa..1b6c787 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright 2015-2021 the original authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,10 +32,10 @@ # Busybox and similar reduced shells will NOT work, because this script # requires all of these POSIX shell features: # * functions; -# * expansions $var, ${var}, ${var:-default}, ${var+SET}, -# ${var#prefix}, ${var%suffix}, and $( cmd ); -# * compound commands having a testable exit status, especially case; -# * various built-in commands including command, set, and ulimit. +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». # # Important for patching: # diff --git a/src/main/java/com/example/modid/Example.java b/src/main/java/com/example/modid/Example.java index a966d81..15c5262 100644 --- a/src/main/java/com/example/modid/Example.java +++ b/src/main/java/com/example/modid/Example.java @@ -5,6 +5,9 @@ import net.fabricmc.api.ModInitializer; +/** + * Example Minecraft mod. + */ public class Example implements ModInitializer { public static final Logger LOGGER = LogManager.getLogger("modid");