diff --git a/.github/scripts/test-no-crash-reports.sh b/.github/scripts/test-no-crash-reports.sh new file mode 100644 index 00000000..c67e342c --- /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/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 00000000..6c9b3cbc --- /dev/null +++ b/.github/workflows/build-and-test.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: Build and test + +on: + pull_request: + branches: [ master, main ] + push: + branches: [ master, main ] + +jobs: + build-and-test: + 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 + + - 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 00000000..25c354b2 --- /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/.gitignore b/.gitignore index 4a0ea1e6..558ad12d 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,6 @@ server.properties servers.dat usercache.json whitelist.json -world/ /out/ *.iml *.ipr diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 678c2d71..00000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: java -cache: - directories: - - "$HOME/.gradle/caches/2.11" - - "$HOME/.gradle/caches/jars-1" - - "$HOME/.gradle/native" - - "$HOME/.gradle/daemon" - - "$HOME/.gradle/wrapper" -# Append git tag to the compiled jar -# https://github.com/GTNewHorizons/TinkersConstruct/blob/1.7.10/build.gradle#L103 -before_install: -- export ARTIFACT_VERSION=$TRAVIS_TAG -deploy: - provider: releases - api_key: - secure: he2rOPBXPGTTDimG/qwKkZtbX5K+utGL13wjhQtHcAPXrVgiJYdAyM+LpJGBH3pwU/pertX1jj+pvAaWpPB9IcO+GT2MyM5mWjIut0aIN+dXdT7trsX8LcJ8LLtPrVDmzPKioPPuP0akr5G+NV2clO3zGdHSPUxthZZLI4+4KILMJSApnhItkUJFnIZmJpjrkScZwZcUgb5KR3v/7l2axmwQKsGBPb/mdgQUymgfLOoPzPLSVx+e768no0dvq7swQw06LVauFB0WIb3rUq5sr1tMPRyOx1WVjy7ERixc8UVlquPE7IZBAlyeyHETTImsxd8xCbSvtezvsBWOhhQ13ADFpHNxHRPPd3Akd+4y+NpedGj9g1XBI5tLNhIcmhwtIYQBCQarDEF4U7iNruMSgjeZ3LAjWj+o4BUdKtA+Yz44ByA3lbLqVXjL4bQJseLju4jINY0uX2j4Eb2mDDeEGKirxu4ZFGwLoGLHh5ZDAKP9BWmGM/9ksJ0BFlafFX2BkIDivyiFfzWB4uLv/n2bZOTOodK1SJr5RVPVvirepqn+1wm3pmGTQ/0DLjOiqFyDncWwCc1aBQXo91FHDEaA42j01/r5mnAE7WkCTp2/Hq44VFvAUBpXBVwIWZBN6QhlBJf2DPXVmFWqCAUz77nG4YD/6YdEyNR8vBerFxLMm6E= - file: build/libs/TConstruct-1.7.10-*-GTNH.jar - file_glob: true - skip_cleanup: true - on: - repo: GTNewHorizons/TinkersConstruct - tags: true diff --git a/build.gradle b/build.gradle index 3e425e62..a380f6c7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -//version: a553e159ecaf0fc236cf25b2c124ea90f92bb140 +//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 @@ -451,22 +460,6 @@ artifacts { } } -// Crude handler to append custom maven repositories to maven dependency -install{ - repositories{ - mavenInstaller{ - pom.withXml { - def repositoriesNode = asNode().appendNode("repositories") - project.repositories.each { repository -> - def repositoryNode = repositoriesNode.appendNode("repository") - repositoryNode.appendNode("name", repository.name) - repositoryNode.appendNode("url", repository.properties.get("url")) - } - } - } - } -} - // Updating task updateBuildScript { doLast {