Skip to content

Commit

Permalink
Parallelise build and fix publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadiboo committed Jun 14, 2024
1 parent 544997e commit f86c133
Show file tree
Hide file tree
Showing 3 changed files with 220 additions and 20 deletions.
74 changes: 54 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build
on: [push, workflow_dispatch]
jobs:
build:
build-fabric:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -13,49 +13,83 @@ jobs:
java-version: 17
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Setup Keystore
run: |
echo ${{ secrets.KEYSTORE_BASE64 }} | base64 -d > keystore.jks
echo "keyStore=keystore.jks" >> gradle.properties
echo "keyStoreAlias=${{ secrets.KEYSTORE_ALIAS }}" >> gradle.properties
echo "keyStorePass=${{ secrets.KEYSTORE_PASS }}" >> gradle.properties
echo "keyStoreKeyPass=${{ secrets.KEYSTORE_KEY_PASS }}" >> gradle.properties
echo "signSHA1=${{ secrets.KEYSTORE_SIGN_SHA1 }}" >> gradle.properties
- name: Build and check
run: ./gradlew :fabric:build :forge:build --stacktrace
- name: Archive development jars
- name: Build and check (fabric)
run: ./gradlew :fabric:build --stacktrace
- name: Archive development jars (fabric)
uses: actions/upload-artifact@v4
with:
name: Development jars inside
name: Development jars inside (fabric)
path: |
fabric/build/devlibs/*.jar
if-no-files-found: error
- name: Archive playable jar (fabric)
uses: actions/upload-artifact@v4
with:
name: Playable mod jar inside (fabric)
path: |
fabric/build/libs/*.jar
if-no-files-found: error
- name: Integration tests (forge)
run: ./gradlew :fabric:runGameTestServer --stacktrace
- name: Publish
uses: Kir-Antipov/mc-publish@v3.3
if: "contains(github.event.head_commit.message, '[ci publish]')"
with:
version-type: beta
files: fabric/build/libs/*.jar
github-token: ${{ secrets.GITHUB_TOKEN }}
github-commitish: ${{ env.GITHUB_SHA }}
github-files-primary: fabric/build/libs/*.jar
github-files-secondary: fabric/build/devlibs/*.jar
curseforge-id: 309664
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
modrinth-id: w3bbwFYU
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
build-forge:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build and check (forge)
run: ./gradlew :forge:build --stacktrace
- name: Archive development jars (forge)
uses: actions/upload-artifact@v4
with:
name: Development jars inside (forge)
path: |
forge/build/libs/*-dev.jar
forge/build/libs/*-sources.jar
forge/build/libs/*-javadoc.jar
if-no-files-found: error
- name: Archive playable jar
- name: Archive playable jar (forge)
uses: actions/upload-artifact@v4
with:
name: Playable mod jar inside
name: Playable mod jar inside (forge)
path: |
fabric/build/libs/*.jar
forge/build/libs/*.jar
!forge/build/libs/*-dev.jar
!forge/build/libs/*-sources.jar
!forge/build/libs/*-javadoc.jar
if-no-files-found: error
- name: Integration tests (forge)
run: ./gradlew :fabric:runGameTestServer :forge:runGameTestServer --stacktrace
run: ./gradlew :forge:runGameTestServer --stacktrace
- name: Publish
uses: Kir-Antipov/mc-publish@v3.3
if: "contains(github.event.head_commit.message, '[ci publish]')"
with:
version-type: beta
files: build/libs/!(*-@(dev|sources|javadoc)).jar
files: forge/build/libs/!(*-@(dev|sources|javadoc)).jar
github-token: ${{ secrets.GITHUB_TOKEN }}
github-commitish: ${{ env.GITHUB_SHA }}
github-files-primary: build/libs/!(*-@(dev|sources|javadoc)).jar
github-files-secondary: build/libs/*-@(dev|sources|javadoc).jar
github-files-primary: forge/build/libs/!(*-@(dev|sources|javadoc)).jar
github-files-secondary: forge/build/libs/*-@(dev|sources|javadoc).jar
curseforge-id: 309664
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
modrinth-id: w3bbwFYU
Expand Down
144 changes: 144 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,147 @@ subprojects {
inputs.properties(expandProps)
}
}
<<<<<<< Updated upstream
=======
dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"

// Apply Mixin AP
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'

// For @Nullable
compileOnly 'org.jetbrains:annotations:23.0.0'

// For the config color picker (we include it in our production jar with ShadowJar)
library 'org.beryx:awt-color-factory:1.0.2'

library(annotationProcessor('io.github.llamalad7:mixinextras-common:0.3.6'))
// compileOnly(annotationProcessor('io.github.llamalad7:mixinextras-common:0.3.6'))

implementation fg.deobf('curse.maven:Embeddium-908741:5410220') // embeddium-0.3.20+mc1.20.1.jar
// implementation fg.deobf('curse.maven:Oculus-581495:5108615') // oculus-mc1.20.1-1.6.15a.jar
// implementation fg.deobf('curse.maven:DistantHorizons-508933:4924664') // DistantHorizons-2.0.1-a-1.20.1.jar
// implementation fg.deobf('curse.maven:Origins-474438:5314209') // origins-forge-1.20.1-1.10.0.9-all.jar
// implementation fg.deobf('curse.maven:Caelus-308989:5281700') // caelus-forge-3.2.0+1.20.1.jar

// For unit tests
testImplementation 'org.mockito:mockito-core:4.5.1'
testImplementation 'junit:junit:4.13.2'
}

// region build
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}

// Write our mod version into our mod info file(s)
processResources {
// Ensures this task is redone when the version changes
inputs.property 'version', project.version
// NB: We need to use 'file.jarVersion' in mods.toml because IntelliJ doesn't run this task when it runs our mod in dev
// This works because 'file.jarVersion' gets handled at runtime by Forge
// IntelliJ bug: "https://youtrack.jetbrains.com/issue/IDEA-173367/The-processResources-task-is-not-correctly-handled-by-IntelliJ"
filesMatching('**/META-INF/mods.toml') {
expand 'file': [jarVersion: project.version]
}
}

jar {
archiveClassifier.set('dev')
manifest {
attributes([
// See https://docs.oracle.com/javase/8/docs/technotes/guides/versioning/spec/versioning2.html
'Specification-Title' : project.name,
'Specification-Version' : mod_version,
'Specification-Vendor' : project.group,
'Implementation-Title' : mod_id,
'Implementation-Version': project.version,
'Implementation-Vendor' : project.group,

'Built-For' : "${minecraft_version}-${forge_version}",
'Built-At-UTC' : new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'Built-On-JVM' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
'Signing-Fingerprint' : project.hasProperty('signSHA1') ? project.findProperty('signSHA1') : 'unsigned',

'Main-Class' : 'io.github.cadiboo.nocubes.DoNotRunThisFromTheConsoleDialog'
])
}
from('LICENSE') {
rename { "${it}_${project.base.archivesName.get()}" }
}
}
shadowJar {
archiveClassifier.set('')

configurations = [project.configurations.shadow]
[
'org.beryx',
'com.llamalad7.mixinextras',
].each {
relocate(it, "${mod_group}.repackage.${it}")
}
mergeServiceFiles() // Very important for MixinExtras to work
manifest.attributes(jar.manifest.getAttributes())
from('LICENSE') {
rename { "${it}_${project.base.archivesName.get()}" }
}
}
reobf {
// We want the output of the following tasks to be reobfuscated
// More info at "https://github.com/MinecraftForge/MinecraftForge/blob/b6ce4fb066eb886a305f0678649c33d6f8ba4f76/mdk/build.gradle#L157-L161"
shadowJar {}
}
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}
javadoc {
// Gradle doesn't support Java 8's new tags out of the box
options.tags = [
'apiNote:a:API Note:',
'implSpec:a:Implementation Requirements:',
'implNote:a:Implementation Note:',
]
}

artifacts {
archives jar
archives shadowJar
archives sourcesJar
archives javadocJar
}
// endregion

// region publish
// TODO: Move this to the publish step, not the build step
// Sign all the jars
import net.minecraftforge.gradle.common.tasks.SignJar

[
// jar,
// shadowJar,
// sourcesJar,
// javadocJar,
].each { jarTask ->
Task signingTask = tasks.create(name: "sign-${jarTask.name}", type: SignJar, dependsOn: jarTask) {
// Skips if the keyStore property is missing.
onlyIf {
project.hasProperty('keyStore')
}
// findProperty allows us to reference the property without it existing.
// Using project.propName would cause the script to fail validation if the property did not exist.
keyStore = project.findProperty('keyStore')
alias = project.findProperty('keyStoreAlias')
storePass = project.findProperty('keyStorePass')
keyPass = project.findProperty('keyStoreKeyPass')
inputFile = jarTask.archiveFile
outputFile = jarTask.archiveFile
}
jarTask.finalizedBy(signingTask)
}
// endregion
>>>>>>> Stashed changes
22 changes: 22 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,25 @@ mod_description=NoCubes is a mod by Cadiboo for 1.12.2+ that creates smooth terr
# Gradle
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
<<<<<<< Updated upstream
=======

# Mod properties
mod_id = nocubes
# NB: Maven and Gradle don't like spaces in filenames
mod_name = NoCubes
# See "http://maven.apache.org/guides/mini/guide-naming-conventions.html"
mod_group = io.github.cadiboo.nocubes
# Taken from https://semver.org
# Given a version number MAJOR.MINOR.PATCH, increment the:
# MAJOR version when you make incompatible API changes,
# MINOR version when you add functionality in a backwards-compatible manner, and
# PATCH version when you make backwards-compatible bug fixes.
# Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
# We use the format MCVERSION-MAJOR.MINOR.PATCH
mod_version = 0.5.1-dev-originscompat

# Dependency properties
minecraft_version = 1.20.1
forge_version = 47.3.1
>>>>>>> Stashed changes

0 comments on commit f86c133

Please sign in to comment.