diff --git a/.github/workflows/fabric-build.yml b/.github/workflows/fabric-build.yml new file mode 100644 index 0000000..959eeed --- /dev/null +++ b/.github/workflows/fabric-build.yml @@ -0,0 +1,46 @@ +# Automatically build the project and run any configured tests for every push +# and submitted pull request. This can help catch issues that only occur on +# certain platforms or Java versions, and provides a first line of defence +# against bad commits. + +name: Fabric Build +on: [pull_request, push] + +jobs: + build: + strategy: + matrix: + # Use these Java versions + java: [17] # Latest version + # and run on both Linux and Windows + os: [ubuntu-20.04, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/cache@v2 + with: + path: | + ~/.gradle/loom-cache + ~/.gradle/caches + ~/.gradle/wrapper + key: gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + gradle- + - name: checkout repository + uses: actions/checkout@v2 + - name: validate gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: setup jdk ${{ matrix.java }} + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - name: make gradle wrapper executable + if: ${{ runner.os != 'Windows' }} + run: chmod +x ./gradlew + - name: build + run: ./gradlew fabric:build + - name: capture build artifacts + if: ${{ runner.os == 'Linux' }} + uses: actions/upload-artifact@v2 + with: + name: Artifacts + path: fabric/build/libs/ \ No newline at end of file diff --git a/.github/workflows/fabric-release.yml b/.github/workflows/fabric-release.yml new file mode 100644 index 0000000..9f19896 --- /dev/null +++ b/.github/workflows/fabric-release.yml @@ -0,0 +1,44 @@ +# Taken from Leuokcyte (https://github.com/NucleoidMC/leukocyte/blob/main/.github/workflows/release.yml) + +name: Fabric Release + +on: + release: + types: + - published + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/cache@v2 + with: + path: | + ~/.gradle/loom-cache + ~/.gradle/caches + ~/.gradle/wrapper + key: gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + gradle- + - uses: actions/checkout@v2 + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: 17 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build and publish with Gradle + run: ./gradlew fabric:build fabric:modrinth fabric:curseforge --stacktrace + env: + CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }} + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} + + - name: Upload GitHub release + uses: AButler/upload-release-assets@v2.0 + with: + files: 'fabric/build/libs/*-fabric.jar' + repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/forge-build.yml b/.github/workflows/forge-build.yml new file mode 100644 index 0000000..a733ae9 --- /dev/null +++ b/.github/workflows/forge-build.yml @@ -0,0 +1,46 @@ +# Automatically build the project and run any configured tests for every push +# and submitted pull request. This can help catch issues that only occur on +# certain platforms or Java versions, and provides a first line of defence +# against bad commits. + +name: Forge Build +on: [pull_request, push] + +jobs: + build: + strategy: + matrix: + # Use these Java versions + java: [17] # Latest version + # and run on both Linux and Windows + os: [ubuntu-20.04, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/cache@v2 + with: + path: | + ~/.gradle/loom-cache + ~/.gradle/caches + ~/.gradle/wrapper + key: gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + gradle- + - name: checkout repository + uses: actions/checkout@v2 + - name: validate gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: setup jdk ${{ matrix.java }} + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - name: make gradle wrapper executable + if: ${{ runner.os != 'Windows' }} + run: chmod +x ./gradlew + - name: build + run: ./gradlew forge:build + - name: capture build artifacts + if: ${{ runner.os == 'Linux' }} + uses: actions/upload-artifact@v2 + with: + name: Artifacts + path: forge/build/libs/ diff --git a/.github/workflows/forge-release.yml b/.github/workflows/forge-release.yml new file mode 100644 index 0000000..1c51ff3 --- /dev/null +++ b/.github/workflows/forge-release.yml @@ -0,0 +1,44 @@ +# Taken from Leuokcyte (https://github.com/NucleoidMC/leukocyte/blob/main/.github/workflows/release.yml) + +name: Forge Release + +on: + release: + types: + - published + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/cache@v2 + with: + path: | + ~/.gradle/loom-cache + ~/.gradle/caches + ~/.gradle/wrapper + key: gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + gradle- + - uses: actions/checkout@v2 + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: 17 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build and publish with Gradle + run: ./gradlew forge:build forge:curseforge forge:modrinth --stacktrace + env: + CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }} + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} + + - name: Upload GitHub release + uses: AButler/upload-release-assets@v2.0 + with: + files: 'forge/build/libs/*-forge.jar' + repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index d313999..2a92864 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # TraderNPCs -A Taterzens addon that adds ability to create GUI traders. +A [Taterzens](https://github.com/samolego/Taterzens) addon that adds ability to create GUI traders. ## Features * simple GUI editing diff --git a/build.gradle b/build.gradle index 8853c41..00e516d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,9 @@ plugins { id "architectury-plugin" version "3.4-SNAPSHOT" id "dev.architectury.loom" version "0.10.0-SNAPSHOT" apply false + + id 'com.matthewprenger.cursegradle' version '1.4.0' + id "com.modrinth.minotaur" version "1.1.0" } architectury { diff --git a/common/src/main/resources/tradersnpcs/icon.png b/common/src/main/resources/tradersnpcs/icon.png new file mode 100644 index 0000000..28d501e Binary files /dev/null and b/common/src/main/resources/tradersnpcs/icon.png differ diff --git a/fabric/build.gradle b/fabric/build.gradle index ad00d9d..f5bf538 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -1,5 +1,10 @@ +import com.modrinth.minotaur.TaskModrinthUpload + plugins { id "com.github.johnrengelman.shadow" version "7.0.0" + + id 'com.matthewprenger.cursegradle' + id "com.modrinth.minotaur" } architectury { @@ -7,6 +12,8 @@ architectury { fabric() } +def ENV = System.getenv(); + configurations { common shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. @@ -76,3 +83,49 @@ publishing { // Add repositories to publish to here. } } + + +// from FAPI https://github.com/FabricMC/fabric/blob/1.16/build.gradle +curseforge { + if (ENV.CURSEFORGE_API_KEY) { + apiKey = ENV.CURSEFORGE_API_KEY + } + + project { + id = "550916" + changelog = "A changelog can be found at https://github.com/samolego/TraderNPCs/releases/tag/${version}" + releaseType = "release" + addGameVersion "${project.minecraft_version}" + addGameVersion "Fabric" + + mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}-fabric.jar")) { + displayName = "[${project.minecraft_version}] TraderNPCs ${version} [Fabric]" + } + + afterEvaluate { + uploadTask.dependsOn("remapJar") + } + } + + options { + forgeGradleIntegration = false + } +} + +task modrinth(type: TaskModrinthUpload, dependsOn: remapJar) { + onlyIf { + ENV.MODRINTH_TOKEN + } + + token = ENV.MODRINTH_TOKEN + projectId = "78ZQG4Et" + versionNumber = project.minecraft_version + "+" + version + "-fabric" + changelog = "A changelog can be found at https://github.com/samolego/TraderNPCs/releases/tag/${version}" + versionName = "[${project.minecraft_version}] TraderNPCs ${version} [Fabric]" + releaseType = "release" + + uploadFile = file("${project.buildDir}/libs/${archivesBaseName}-${version}-fabric.jar") + + addGameVersion("${project.minecraft_version}") + addLoader('fabric') +} diff --git a/forge/build.gradle b/forge/build.gradle index 1085f8f..de0c104 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -1,5 +1,10 @@ +import com.modrinth.minotaur.TaskModrinthUpload + plugins { id "com.github.johnrengelman.shadow" version "7.0.0" + + id 'com.matthewprenger.cursegradle' + id "com.modrinth.minotaur" } loom { forge { @@ -12,6 +17,8 @@ architectury { forge() } +def ENV = System.getenv(); + configurations { common shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. @@ -79,3 +86,50 @@ publishing { // Add repositories to publish to here. } } + + + +// from FAPI https://github.com/FabricMC/fabric/blob/1.16/build.gradle +curseforge { + if (ENV.CURSEFORGE_API_KEY) { + apiKey = ENV.CURSEFORGE_API_KEY + } + + project { + id = "550916" + changelog = "A changelog can be found at https://github.com/samolego/TraderNPCs/releases/tag/${version}" + releaseType = "release" + addGameVersion "${project.minecraft_version}" + addGameVersion "Forge" + + mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}-forge.jar")) { + displayName = "[${project.minecraft_version}] TraderNPCs ${version} [Forge]" + } + + afterEvaluate { + uploadTask.dependsOn("remapJar") + } + } + + options { + forgeGradleIntegration = false + } +} + +task modrinth(type: TaskModrinthUpload, dependsOn: remapJar) { + onlyIf { + ENV.MODRINTH_TOKEN + } + + token = ENV.MODRINTH_TOKEN + projectId = "78ZQG4Et" + versionNumber = project.minecraft_version + "+" + version + "-forge" + changelog = "A changelog can be found at https://github.com/samolego/TraderNPCs/releases/tag/${version}" + versionName = "[${project.minecraft_version}] TraderNPCs ${version} [Forge]" + releaseType = "release" + + uploadFile = file("${project.buildDir}/libs/${archivesBaseName}-${version}-forge.jar") + + addGameVersion("${project.minecraft_version}") + addLoader('forge') +}