Skip to content

Commit

Permalink
Modernize CI and gradle.properties usage
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Dec 12, 2024
1 parent 79b8c82 commit 114baa4
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 81 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ jobs:
if-no-files-found: error
path: build/libs/*
- name: 'Deploy to CurseForge'
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/master')
env:
CURSEFORGE_KEY_SECRET: ${{ secrets.CURSEFORGE_KEY_SECRET }}
run: ./gradlew publishCurseForge
- name: 'Deploy to Modrinth'
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/master')
env:
MODRINTH_KEY_SECRET: ${{ secrets.MODRINTH_KEY_SECRET }}
run: ./gradlew modrinth
Expand Down
77 changes: 43 additions & 34 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,30 @@ apply plugin: 'idea'
apply plugin: 'maven-publish'
apply plugin: 'jacoco'

import net.neoforged.gradle.common.tasks.PotentiallySignJar

// Determine build number
String build_number = "DEV" // this will be referenced as simply build_number from now on.
if (System.getenv().BUILD_NUMBER)
build_number = System.getenv().BUILD_NUMBER
if (System.getenv().TRAVIS_BUILD_NUMBER)
build_number = System.getenv().TRAVIS_BUILD_NUMBER
if (System.getenv().GITHUB_RUN_ID)
build_number = System.getenv().GITHUB_RUN_NUMBER
if (System.getenv().RELEASE || System.getenv().TRAVIS_TAG)
if (System.getenv().RELEASE)
build_number = "RELEASE"
logger.lifecycle "BUILDING VERSION: " + build_number

// Set mod details
version = project.mod_version
group = "org.cyclops.integratedterminalscompat"
archivesBaseName = "IntegratedTerminals-Compat-${project.minecraft_version}-neoforge"
// Include build number in version
if (build_number.equals("RELEASE"))
version = "${project.mod_version}"
else
version = "${project.mod_version}-${build_number}"

base {
archivesName = archivesBaseName
archivesName = "${mod_id}-${minecraft_version}-neoforge"
}

// Set Java details
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
java {
toolchain.languageVersion = JavaLanguageVersion.of(java_version)
}
compileJava.options.compilerArgs << "-Xmaxerrs" << "9999"
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))

// Load secrets
def getSecrets() {
Expand All @@ -44,7 +42,10 @@ def getSecrets() {
}
return props
}
Properties secrets = getSecrets();
//ext {
Properties secrets = getSecrets();
secrets.build_number = build_number;
//}

sourceSets {
main
Expand Down Expand Up @@ -194,11 +195,6 @@ runs {
}
}

if (build_number.equals("RELEASE"))
version = "${project.mod_version}"
else
version = "${project.mod_version}-${build_number}"

jar {
manifest {
attributes([
Expand All @@ -213,21 +209,6 @@ jar {
}
}

task signJar(type: PotentiallySignJar, dependsOn: jar) {
dependsOn(tasks.jar)

onlyIf {
System.getenv().SIGN_KEYSTORE
}

keyStore = System.getenv().SIGN_KEYSTORE
alias = System.getenv().SIGN_ALIAS
storePass = System.getenv().SIGN_STOREPASS
keyPass = System.getenv().SIGN_KEYPASS
input = jar.archivePath
output = jar.archivePath
}

task deobfJar(type: Jar) {
from sourceSets.main.output
archiveClassifier.set('deobf')
Expand Down Expand Up @@ -262,6 +243,34 @@ artifacts {
archives javadocJar
}

// Replace properties in files
processResources {
def expandProps = [
'mod_version' : mod_version,
'group' : project.group, //Else we target the task's group.
'minecraft_version' : minecraft_version,
'mod_name' : mod_name,
'mod_author' : mod_author,
'mod_id' : mod_id,
'license' : license,
'issue_tracker_url' : issue_tracker_url,
'display_url' : display_url,
'description' : project.description,
'neoforge_version' : neoforge_version,
'neoforge_loader_version_range' : neoforge_loader_version_range,
'java_version' : java_version,
'cyclopscore_version' : cyclopscore_version,
'cyclopscore_version_semver' : cyclopscore_version.replaceAll("-.*\$", ""),
'integratedterminals_version' : integratedterminals_version,
'integratedterminals_version_semver' : integratedterminals_version.replaceAll("-.*\$", "")
]

filesMatching(['pack.mcmeta', 'META-INF/mods.toml', 'META-INF/neoforge.mods.toml', 'mixins.*.json']) {
expand expandProps
}
inputs.properties(expandProps)
}

publishing {
repositories {
if (project.hasProperty("filesmaven_url")) {
Expand Down
33 changes: 20 additions & 13 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
mod_id=integratedterminals-compat
# Project
mod_version=1.0.0
group=org.cyclops.integratedterminalscompat
java_version=21

# Common
minecraft_version=1.21.1
neoforge_version=21.1.2
mod_name=IntegratedTerminals-Compat
mod_author=rubensworks (aka kroeser)
mod_id=integratedterminalscompat
license=MIT
github_url=https://github.com/CyclopsMC/IntegratedTerminals-Compat
issue_tracker_url=https://github.com/CyclopsMC/IntegratedTerminals-Compat/issues
display_url=https://www.curseforge.com/minecraft/mc-mods/integrated-terminals
description=Integrated Terminals compatibility with other mods. This mod is automatically packaged with Integrated Terminals.

parchment_version=2024.07.07
parchment_minecraft_version=1.21
cyclopscore_version=1.25.1-627
release_type=release
fingerprint=bd0353b3e8a2810d60dd584e256e364bc3bedd44

# NeoForge
neoforge_version=21.1.2
neoforge_loader_version_range=[4,)

# Dependencies
cyclopscore_version=1.25.1-627
integrateddynamics_version=1.23.2-832
integratedterminals_version=1.6.5-417
commoncapabilities_version=2.9.3-147
Expand All @@ -17,11 +32,3 @@ emi_version=1.1.16+1.21.1
rei_version=16.0.783
cloth_config_version=15.0.140
architectury_version=13.0.6

# Workaround for Spotless bug
# https://github.com/diffplug/spotless/issues/834
org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
50 changes: 18 additions & 32 deletions src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
@@ -1,50 +1,36 @@
modLoader="javafml"
loaderVersion="[2,)"
issueTrackerURL="https://github.com/CyclopsMC/IntegratedTerminals-Compat/issues"
displayURL="https://www.curseforge.com/minecraft/mc-mods/integrated-terminals"
license="MIT"
loaderVersion="${neoforge_loader_version_range}"
issueTrackerURL="${issue_tracker_url}"
displayURL="${display_url}"
license="${license}"
logoFile="logo.png"
authors="rubensworks (aka kroeser)"
authors="${mod_author}"
[[mods]]
modId="integratedterminalscompat"
version="${file.jarVersion}"
displayName="IntegratedTerminalsCompat"
description='''
Integrated Terminals compatibility with other mods. This mod is automatically packaged with Integrated Terminals.
'''
[[dependencies.integratedterminalscompat]]
modId="${mod_id}"
version="${mod_version}"
displayName="${mod_name}"
description="${description}"
[[dependencies.${mod_id}]]
modId="cyclopscore"
type="required"
versionRange="[1.25.1,)"
versionRange="[${cyclopscore_version_semver},)"
ordering="NONE"
side="BOTH"
[[dependencies.integratedterminalscompat]]
modId="integrateddynamics"
type="required"
versionRange="[1.23.2,)"
ordering="NONE"
side="BOTH"
[[dependencies.integratedterminalscompat]]
modId="commoncapabilities"
[[dependencies.${mod_id}]]
modId="integratedterminals"
type="required"
versionRange="[2.9.3,)"
versionRange="[${integratedterminals_version_semver},)"
ordering="NONE"
side="BOTH"
[[dependencies.integratedterminalscompat]]
[[dependencies.${mod_id}]]
modId="neoforge"
type="required"
versionRange="[21.1.2,)"
ordering="NONE"
side="BOTH"
[[dependencies.integratedterminalscompat]]
modId="integratedterminals"
type="required"
versionRange="[1.3.0,)"
versionRange="[${neoforge_version},)"
ordering="NONE"
side="BOTH"
[[dependencies.integratedterminalscompat]]
[[dependencies.${mod_id}]]
modId="minecraft"
type="required"
versionRange="[1.21.1,]"
versionRange="[${minecraft_version},]"
ordering="NONE"
side="BOTH"

0 comments on commit 114baa4

Please sign in to comment.