From dc6ff2cc504cc2c5882ff1912681752a6dc88f1b Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Tue, 7 Jun 2022 20:59:47 +0200 Subject: [PATCH 1/5] add GitHub Actions --- .github/workflows/gradle.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/gradle.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 000000000..2650d2d9c --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,28 @@ +name: Java CI with Gradle + +on: [push, pull_request, workflow_dispatch] + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + java-version: '8' + distribution: 'temurin' + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b + - name: Build with Gradle + uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee + with: + arguments: build + - name: Archive artifacts + uses: actions/upload-artifact@v3 + with: + name: Release files + path: build/libs/*.jar From babd9ae917bda93ecfa70c8266321f279db74d4e Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Tue, 7 Jun 2022 23:28:49 +0200 Subject: [PATCH 2/5] build.gradle: increase Scala worker memory limit to 1GB --- build.gradle | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.gradle b/build.gradle index 37efb4e4a..6563ac5b2 100644 --- a/build.gradle +++ b/build.gradle @@ -72,6 +72,12 @@ runServer { jvmArgs '-Dfml.coreMods.load=li.cil.oc.common.launch.TransformerLoader' } +compileScala { + configure(scalaCompileOptions.forkOptions) { + memoryMaximumSize = '1g' + } +} + if (JavaVersion.current().isJava8Compatible()) { allprojects { tasks.withType(Javadoc) { From 8000ef5f4ef7ef31915a19d9961a3760559bfce9 Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Tue, 7 Jun 2022 23:43:01 +0200 Subject: [PATCH 3/5] update GitHub Actions, add Modrinth uploads --- .github/workflows/{gradle.yml => build.yml} | 21 +-- .github/workflows/publish.yml | 154 ++++++++++++++++++++ build.gradle | 33 ++++- build.properties | 2 +- gradle.properties | 1 + 5 files changed, 193 insertions(+), 18 deletions(-) rename .github/workflows/{gradle.yml => build.yml} (50%) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/build.yml similarity index 50% rename from .github/workflows/gradle.yml rename to .github/workflows/build.yml index 2650d2d9c..201901adf 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/build.yml @@ -16,13 +16,16 @@ jobs: java-version: '8' distribution: 'temurin' - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b + uses: gradle/wrapper-validation-action@v1 + - uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: ${{ runner.os }}-gradle- - name: Build with Gradle - uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee - with: - arguments: build - - name: Archive artifacts - uses: actions/upload-artifact@v3 - with: - name: Release files - path: build/libs/*.jar + run: ./gradlew build + env: + GPR_USER: ${{ secrets.GPR_USER }} + GPR_KEY: ${{ secrets.GPR_KEY }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..effa875d9 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,154 @@ +name: publish + +on: + release: + types: [published] + +jobs: + publish-github: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Extract Version from Tag + uses: rishabhgupta/split-by@v1 + id: split_tag + with: + string: ${{ github.event.release.tag_name }} + split-by: '/' + + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + java-version: '8' + distribution: 'temurin' + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ubuntu-latest-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: ubuntu-latest-gradle- + - name: Build with Gradle + run: ./gradlew -Pmod_version='${{ steps.split_tag.outputs._1 }}' build + env: + GPR_USER: ${{ secrets.GPR_USER }} + GPR_KEY: ${{ secrets.GPR_KEY }} + + - name: Add Artifacts to Github Release + uses: alexellis/upload-assets@0.3.0 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + asset_paths: '["./build/libs/*.jar"]' + + - name: Publish to Github Packages + run: gradle -Pmod_version='${{ steps.split_tag.outputs._1 }}' publish + env: + GPR_USER: ${{ secrets.GPR_USER }} + GPR_KEY: ${{ secrets.GPR_KEY }} + GITHUB_MAVEN_URL: 'https://maven.pkg.github.com/${{ github.repository }}' + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish-curse: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Extract Version from Tag + uses: rishabhgupta/split-by@v1 + id: split_tag + with: + string: ${{ github.event.release.tag_name }} + split-by: '/' + + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + java-version: '8' + distribution: 'temurin' + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ubuntu-latest-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: ubuntu-latest-gradle- + + # Set Curseforge release type based on pre-release flag. + - name: Set release type to 'release' + run: | + echo "CURSEFORGE_RELEASE_TYPE=release" >> $GITHUB_ENV + if: github.event.release.prerelease == false + - name: Set release type to 'alpha' + run: | + echo "CURSEFORGE_RELEASE_TYPE=alpha" >> $GITHUB_ENV + if: github.event.release.prerelease == true + + - name: Publish to Curseforge + run: ./gradlew -Pmod_version='${{ steps.split_tag.outputs._1 }}' curseforge + env: + GPR_USER: ${{ secrets.GPR_USER }} + GPR_KEY: ${{ secrets.GPR_KEY }} + CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }} + CURSEFORGE_RELEASE_TYPE: ${{ env.CURSEFORGE_RELEASE_TYPE }} + CHANGELOG: ${{ github.event.release.body }} + + publish-modrinth: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Extract Version from Tag + uses: rishabhgupta/split-by@v1 + id: split_tag + with: + string: ${{ github.event.release.tag_name }} + split-by: '/' + + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + java-version: '8' + distribution: 'temurin' + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ubuntu-latest-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: ubuntu-latest-gradle- + + # Set Modrinth release type based on pre-release flag. + - name: Set release type to 'release' + run: | + echo "MODRINTH_RELEASE_TYPE=release" >> $GITHUB_ENV + if: github.event.release.prerelease == false + - name: Set release type to 'alpha' + run: | + echo "MODRINTH_RELEASE_TYPE=alpha" >> $GITHUB_ENV + if: github.event.release.prerelease == true + + - name: Publish to Modrinth + run: ./gradlew -Pmod_version='${{ steps.split_tag.outputs._1 }}' modrinth + env: + GPR_USER: ${{ secrets.GPR_USER }} + GPR_KEY: ${{ secrets.GPR_KEY }} + MODRINTH_API_KEY: ${{ secrets.MODRINTH_API_KEY }} + MODRINTH_RELEASE_TYPE: ${{ env.MODRINTH_RELEASE_TYPE }} + CHANGELOG: ${{ github.event.release.body }} diff --git a/build.gradle b/build.gradle index 6563ac5b2..3a16cde8b 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,6 @@ buildscript { } dependencies { classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.7' - classpath 'gradle.plugin.com.matthewprenger:CurseGradle:1.4.0' } } @@ -27,10 +26,11 @@ plugins { id 'scala' id 'idea' id 'maven-publish' + id "com.matthewprenger.cursegradle" version "1.4.0" + id 'com.modrinth.minotaur' version '2.2.0' } apply plugin: 'forge' -apply plugin: 'com.matthewprenger.cursegradle' file "build.properties" withReader { def prop = new Properties() @@ -268,6 +268,9 @@ artifacts { publishing { publications { mavenJava(MavenPublication) { + groupId = project.group + artifactId = project.name + version = mod_version artifact jar artifact apiJar artifact javadocJar @@ -277,26 +280,40 @@ publishing { } repositories { maven { - url System.getenv("MAVEN_PATH") + name = "GitHubPackages" + url = System.getenv("GITHUB_MAVEN_URL") ?: "" + credentials { + username = System.getenv("GITHUB_ACTOR") + password = System.getenv("GITHUB_TOKEN") + } } } } curseforge { - apiKey = project.hasProperty("curseForgeApiKey") ? project.curseForgeApiKey : "" + apiKey = System.getenv('CURSEFORGE_API_KEY') ?: "" project { id = config.curse.project.id - releaseType = config.curse.project.releaseType + releaseType = System.getenv('CURSEFORGE_RELEASE_TYPE') ?: "alpha" changelogType = "markdown" - changelog = file("changelog.md") + changelog = System.getenv("CHANGELOG") ?: "Changelog not available." addGameVersion config.minecraft.version addGameVersion "Java 8" addGameVersion "Forge" - - mainArtifact jar } } +modrinth { + token = System.getenv("MODRINTH_API_KEY") ?: "" + projectId = config.modrinth.project.id + changelog = System.getenv("CHANGELOG") ?: "Changelog not available." + versionNumber = mod_version + versionName = "${rootProject.name}-${version}" + versionType = System.getenv('MODRINTH_RELEASE_TYPE') ?: "alpha" + uploadFile = jar + gameVersions = [config.minecraft.version] +} + // this is needed for IntelliJ so we don't have to copy over the assets manually every time idea { module { diff --git a/build.properties b/build.properties index 7d9c019da..90f2932a2 100644 --- a/build.properties +++ b/build.properties @@ -50,4 +50,4 @@ cofhcore.cf=2388/750 cofhcore.version=[1.7.10]3.1.4-329 curse.project.id=223008 -curse.project.releaseType=release +modrinth.project.id=YiAbZis2 diff --git a/gradle.properties b/gradle.properties index e69de29bb..7bd318153 100644 --- a/gradle.properties +++ b/gradle.properties @@ -0,0 +1 @@ +mod_version=0.0.0 From 9565d8f60f7624d6394aac2be80d8c965097464b Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Tue, 7 Jun 2022 23:49:43 +0200 Subject: [PATCH 4/5] update GitHub Actions, save build JARs for builds --- .github/workflows/build.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 201901adf..91db909a1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,3 +29,13 @@ jobs: env: GPR_USER: ${{ secrets.GPR_USER }} GPR_KEY: ${{ secrets.GPR_KEY }} + - name: Archive artifacts + uses: actions/upload-artifact@v3 + with: + name: OpenComputers + path: build/libs/*-universal.jar + - name: Archive artifacts + uses: actions/upload-artifact@v3 + with: + name: OpenComputers (development environment build) + path: build/libs/*-dev.jar From fb73d37474e1720f65c65ae48f24acd7cc5dc0fe Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Wed, 8 Jun 2022 00:23:09 +0200 Subject: [PATCH 5/5] build.gradle: fix Git reference appending --- build.gradle | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 3a16cde8b..bb6204b25 100644 --- a/build.gradle +++ b/build.gradle @@ -38,7 +38,7 @@ file "build.properties" withReader { ext.config = new ConfigSlurper().parse prop } -version = "${config.oc.version}" +version = "${mod_version}" group = "li.cil.oc" archivesBaseName = "OpenComputers" @@ -55,12 +55,7 @@ def getGitRef() { } } -if (System.getenv("PROMOTED_NUMBER") != null) - version += ".${System.getenv("PROMOTED_NUMBER")}" -else if (System.getenv("BUILD_NUMBER") != null) - version += ".${System.getenv("BUILD_NUMBER")}" -else - version += "+" + getGitRef() +version += "+" + getGitRef() ext.simpleVersion = version version = "MC${config.minecraft.version}-${project.version}"