diff --git a/.github/scripts/test-no-crash-reports.sh b/.github/scripts/test-no-crash-reports.sh new file mode 100644 index 0000000..c67e342 --- /dev/null +++ b/.github/scripts/test-no-crash-reports.sh @@ -0,0 +1,9 @@ +directory="run/crash-reports" +if [ -d $directory ]; then + echo "Crash reports detected:" + cat $directory/* + exit 1 +else + echo "No crash reports detected" + exit 0 +fi diff --git a/.github/workflows/pull-request.yml b/.github/workflows/build-and-test.yml similarity index 66% rename from .github/workflows/pull-request.yml rename to .github/workflows/build-and-test.yml index f4e30c1..6c9b3cb 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/build-and-test.yml @@ -1,14 +1,16 @@ # This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle -name: Build pull request +name: Build and test on: pull_request: branches: [ master, main ] + push: + branches: [ master, main ] jobs: - build: + build-and-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -30,3 +32,14 @@ jobs: - name: Build the mod run: ./gradlew build + + - name: Run server for 1 minute + run: | + mkdir run + echo "eula=true" > run/eula.txt + timeout 10 ./gradlew runServer || true + + - name: Test no crashes happend + run: | + chmod +x .github/scripts/test-no-crash-reports.sh + .github/scripts/test-no-crash-reports.sh diff --git a/.github/workflows/release-tags.yml b/.github/workflows/release-tags.yml new file mode 100644 index 0000000..25c354b --- /dev/null +++ b/.github/workflows/release-tags.yml @@ -0,0 +1,45 @@ +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Release tagged build + +on: + push: + tags: + - '*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set release version + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Set up JDK 8 + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Setup the workspace + run: ./gradlew setupCIWorkspace + + - name: Build the mod + run: ./gradlew build + + - name: Release under current tag + uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: "${{ env.RELEASE_VERSION }}" + prerelease: false + title: "${{ env.RELEASE_VERSION }}" + files: build/libs/*.jar diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 6a64794..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,41 +0,0 @@ -# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle - -name: Build and release main branch - -on: - push: - branches: [ master, main ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Set up JDK 8 - uses: actions/setup-java@v2 - with: - java-version: '8' - distribution: 'adopt' - cache: gradle - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - - name: Setup the workspace - run: ./gradlew setupCIWorkspace - - - name: Build the mod - run: ./gradlew build - - - uses: "marvinpinto/action-automatic-releases@latest" - with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - automatic_release_tag: "latest" - prerelease: true - title: "Latest Development Build" - files: build/libs/*.jar - diff --git a/.gitignore b/.gitignore index 4a0ea1e..558ad12 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,6 @@ server.properties servers.dat usercache.json whitelist.json -world/ /out/ *.iml *.ipr diff --git a/build.gradle b/build.gradle index 910ddbc..a380f6c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -//version: eb0b030ab9cb1d0f9a31f11e69e1ceed1dab2c89 +//version: ffe7b130f98fdfa1ac7c6ba4bd34722a55ab28d4 /* DO NOT CHANGE THIS FILE! @@ -62,6 +62,10 @@ idea { } } +if(JavaVersion.current() != JavaVersion.VERSION_1_8) { + throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current()) +} + checkPropertyExists("modName") checkPropertyExists("modId") checkPropertyExists("modGroup") @@ -153,7 +157,12 @@ configurations.all { // Fix Jenkins' Git: chmod a file should not be detected as a change and append a '.dirty' to the version 'git config core.fileMode false'.execute() // Pulls version from git tag -version = minecraftVersion + "-" + gitVersion() +try { + version = minecraftVersion + "-" + gitVersion() +} +catch (Exception e) { + throw new IllegalStateException("This mod must be version controlled by Git AND the repository must provide at least one tag!"); +} group = modGroup archivesBaseName = modId @@ -225,14 +234,13 @@ dependencies { apply from: 'dependencies.gradle' -def mixinConfigJson = "mixins." + modId + ".json" def mixingConfigRefMap = "mixins." + modId + ".refmap.json" def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfigRefMap def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg" task generateAssets { if(usesMixins.toBoolean()) { - new File(projectDir.toString() + "/src/main/resources/", mixinConfigJson).text = """{ + new File(projectDir.toString() + "/src/main/resources/", "mixins." + modId + ".json").text = """{ "required": true, "minVersion": "0.7.11", "package": "${modGroup}.${mixinsPackage}", @@ -351,6 +359,10 @@ processResources "modName": modName } + if(usesMixins.toBoolean()) { + from refMap + } + // copy everything else, thats not the mcmod.info from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' @@ -359,7 +371,7 @@ processResources def getManifestAttributes() { def manifestAttributes = [:] - if(containsMixinsAndOrCoreModOnly.toBoolean() == false) { + if(containsMixinsAndOrCoreModOnly.toBoolean() == false && (usesMixins.toBoolean() || coreModClass)) { manifestAttributes += ["FMLCorePluginContainsFMLMod": true] } @@ -374,7 +386,7 @@ def getManifestAttributes() { if(usesMixins.toBoolean()) { manifestAttributes += [ "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", - "MixinConfigs" : mixinConfigJson, + "MixinConfigs" : "mixins." + modId + ".json", "ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false ] }