Skip to content

Commit

Permalink
Modernize setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
LambdAurora committed Jul 23, 2024
1 parent e539113 commit e65846c
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 62 deletions.
20 changes: 9 additions & 11 deletions .github/workflows/gradle_build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Gradle Build
name: "Gradle Build"

on:
workflow_dispatch:
push:
pull_request:
on: [push, pull_request]

jobs:
build:
Expand All @@ -12,24 +9,25 @@ jobs:
java: [ 17, 21 ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK ${{ matrix.java }}
- name: "Set up Java"
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'gradle'
- name: Set up Gradle
- name: "Set up Gradle"
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: ${{ !startsWith(github.ref, 'refs/heads/1.') && !startsWith(github.ref, 'refs/heads/dev/') && !startsWith(github.ref, 'refs/tags/v') }}

- name: Build with Gradle
- name: "Build with Gradle"
run: ./gradlew build --parallel --stacktrace

- uses: actions/upload-artifact@v4
- name: "Upload artifacts"
uses: actions/upload-artifact@v4
with:
name: Artifacts_j${{ matrix.java }}
path: ./build/libs/
9 changes: 5 additions & 4 deletions .github/workflows/maven_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
- name: "Set up Java"
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
- name: Set up Gradle
- name: "Set up Gradle"
uses: gradle/actions/setup-gradle@v3

# The USERNAME and PASSWORD need to correspond to the credentials environment variables used in
# the publishing section of your build.gradle
- name: Publish to GitHub Packages and other Mavens
- name: "Publish to GitHub Packages and other Mavens"
run: ./gradlew publish --parallel --stacktrace
env:
BRANCH_NAME: ${{ github.ref }}
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release
name: "Release"

on:
release:
Expand All @@ -9,24 +9,26 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
- name: "Set up Java"
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
- name: Set up Gradle
- name: "Set up Gradle"
uses: gradle/actions/setup-gradle@v3

- name: Build with Gradle
- name: "Build with Gradle"
run: ./gradlew build modrinth curseforge --parallel --stacktrace
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}

- uses: actions/upload-artifact@v4
- name: "Upload artifacts"
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: ./build/libs/
82 changes: 41 additions & 41 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
plugins {
id 'fabric-loom' version '1.4.+'
id 'dev.yumi.gradle.licenser' version '1.1.+'
id 'java-library'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'com.modrinth.minotaur' version '2.+'
id 'net.darkhax.curseforgegradle' version '1.1.+'
id "fabric-loom" version "1.4.+"
id "dev.yumi.gradle.licenser" version "1.1.+"
id "java-library"
id "maven-publish"
id "com.github.johnrengelman.shadow" version "8.1.1"
id "com.modrinth.minotaur" version "2.+"
id "net.darkhax.curseforgegradle" version "1.1.+"
}

import com.modrinth.minotaur.dependencies.ModDependency
Expand All @@ -18,22 +18,22 @@ base.archivesName = project.archives_base_name
// This field defines the Java version your mod target.
def targetJavaVersion = 17

if (!(System.getenv("CURSEFORGE_TOKEN") || System.getenv("MODRINTH_TOKEN"))) {
if (!(System.getenv("CURSEFORGE_TOKEN") || System.getenv("MODRINTH_TOKEN") || System.getenv("LDL_MAVEN"))) {
version += "-local"
}
logger.lifecycle("Preparing version ${version}...")

boolean isMCVersionNonRelease() {
return project.minecraft_version.matches('^\\d\\dw\\d\\d[a-z]$')
|| project.minecraft_version.matches('\\d+\\.\\d+-(pre|rc)(\\d+)')
|| project.minecraft_version.matches("\\d+\\.\\d+-(pre|rc)(\\d+)")
}

String getMCVersionString() {
if (isMCVersionNonRelease()) {
return project.minecraft_version
}
def version = project.minecraft_version.split('\\.')
return version[0] + '.' + version[1]
def version = project.minecraft_version.split("\\.")
return version[0] + "." + version[1]
}

String getVersionType() {
Expand All @@ -50,27 +50,27 @@ String parseReadme() {
def excludeRegex = /(?m)<!-- modrinth_exclude\.start -->(.|\n)*?<!-- modrinth_exclude\.end -->/
def linkRegex = /!\[([A-z_ ]+)]\((images\/[A-z.\/_]+)\)/

def readme = (String) file('README.md').text
readme = readme.replaceAll(excludeRegex, '')
readme = readme.replaceAll(linkRegex, '![$1](https://raw.githubusercontent.com/LambdAurora/LambDynamicLights/1.19/$2)')
def readme = (String) file("README.md").text
readme = readme.replaceAll(excludeRegex, "")
readme = readme.replaceAll(linkRegex, "![\$1](https://raw.githubusercontent.com/LambdAurora/LambDynamicLights/1.19/\$2)")
return readme
}

String fetchChangelog() {
def changelogText = file('CHANGELOG.md').text
def regexVersion = ((String) project.mod_version).replaceAll('\\.', /\\./).replaceAll('\\+', '\\+')
def changelogText = file("CHANGELOG.md").text
def regexVersion = ((String) project.mod_version).replaceAll("\\.", /\\./).replaceAll("\\+", "\\+")
def changelogRegex = ~"###? ${regexVersion}\\n\\n(( *- .+\\n)+)"
def matcher = changelogText =~ changelogRegex

if (matcher.find()) {
def changelogContent = matcher.group(1)

def changelogLines = changelogText.split('\n')
def linkRefRegex = ~'^\\[([A-z\\d _\\-/+.]+)]: '
def changelogLines = changelogText.split("\n")
def linkRefRegex = ~"^\\[([A-z\\d _\\-/+.]+)]: "
for (int i = changelogLines.length - 1; i > 0; i--) {
def line = changelogLines[i]
if ((line =~ linkRefRegex).find())
changelogContent += '\n' + line
changelogContent += "\n" + line
else break
}
return changelogContent
Expand All @@ -87,16 +87,16 @@ repositories {
url "https://maven.quiltmc.org/repository/release"
}
maven {
name 'Terraformers'
url 'https://maven.terraformersmc.com/releases/'
name "Terraformers"
url "https://maven.terraformersmc.com/releases/"
}
maven {
name 'Gegy'
url 'https://maven.gegy.dev'
name "Gegy"
url "https://maven.gegy.dev"
}
maven {
name 'grondag'
url 'https://maven.dblsaiko.net/'
name "grondag"
url "https://maven.dblsaiko.net/"
}
exclusiveContent {
forRepository {
Expand Down Expand Up @@ -137,8 +137,8 @@ dependencies {

modRuntimeOnly "maven.modrinth:sodium:${project.sodium_version}"

shadow 'com.electronwill.night-config:core:3.6.6'
shadow 'com.electronwill.night-config:toml:3.6.6'
shadow "com.electronwill.night-config:core:3.6.6"
shadow "com.electronwill.night-config:toml:3.6.6"
}

java {
Expand All @@ -149,36 +149,36 @@ java {
}

tasks.withType(JavaCompile).configureEach {
it.options.encoding = 'UTF-8'
it.options.encoding = "UTF-8"

it.options.release.set(targetJavaVersion)
}

processResources {
inputs.property 'version', project.version
inputs.property "version", project.version

filesMatching('fabric.mod.json') {
expand 'version': project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}

jar {
from('LICENSE') {
from("LICENSE") {
rename { "${it}_${base.archivesName}" }
}
}

license {
rule file('HEADER')
rule file("HEADER")
}

shadowJar {
dependsOn jar
configurations = [project.configurations.shadow]
destinationDirectory.set(file("${project.layout.buildDirectory.get()}/devlibs"))
archiveClassifier.set('dev')
archiveClassifier.set("dev")

relocate 'com.electronwill.nightconfig', 'dev.lambdaurora.lambdynlights.shadow.nightconfig'
relocate "com.electronwill.nightconfig", "dev.lambdaurora.lambdynlights.shadow.nightconfig"
}
remapJar.dependsOn(shadowJar)

Expand Down Expand Up @@ -207,7 +207,7 @@ modrinth {
}
tasks.modrinth.dependsOn(tasks.modrinthSyncBody)

tasks.register('curseforge', TaskPublishCurseForge) {
tasks.register("curseforge", TaskPublishCurseForge) {
setGroup("publishing")

if (System.getenv("CURSEFORGE_TOKEN")) {
Expand Down Expand Up @@ -258,18 +258,18 @@ publishing {
repositories {
mavenLocal()
maven {
name = 'BuildDirLocal'
name = "BuildDirLocal"
url = "${project.layout.buildDirectory.get()}/repo"
}

def ldlMaven = System.getenv('LDL_MAVEN')
def ldlMaven = System.getenv("LDL_MAVEN")
if (ldlMaven) {
maven {
name = 'LambDynamicLightsMaven'
name = "LambDynamicLightsMaven"
url = uri(ldlMaven)
credentials {
username = project.findProperty('gpr.user') ?: System.getenv('MAVEN_USERNAME')
password = project.findProperty('gpr.key') ?: System.getenv('MAVEN_PASSWORD')
username = project.findProperty("gpr.user") ?: System.getenv("MAVEN_USERNAME")
password = project.findProperty("gpr.key") ?: System.getenv("MAVEN_PASSWORD")
}
}
}
Expand Down

0 comments on commit e65846c

Please sign in to comment.