Release 5.27.0 & enable continuous deployment
This commit is contained in:
parent
d08da1b3c8
commit
c2191df359
23
.github/workflows/gradle.yml
vendored
23
.github/workflows/gradle.yml
vendored
|
|
@ -11,6 +11,9 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
|
concurrency:
|
||||||
|
group: release-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
@ -22,13 +25,31 @@ jobs:
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
java-version: 21
|
java-version: 21
|
||||||
check-latest: true
|
check-latest: true
|
||||||
|
- name: Check if release branch
|
||||||
|
id: check_branch
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
run: |
|
||||||
|
if [[ "${{ github.ref }}" =~ ^refs/heads/[0-9]+\. ]]; then
|
||||||
|
echo "is_release=true" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "is_release=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
- name: Setup Gradle
|
- name: Setup Gradle
|
||||||
uses: gradle/actions/setup-gradle@v4
|
uses: gradle/actions/setup-gradle@v4
|
||||||
with:
|
with:
|
||||||
cache-read-only: ${{ !startsWith(github.ref, 'refs/heads/1.') }}
|
cache-read-only: ${{ steps.check_branch.outputs.is_release != 'true' }}
|
||||||
gradle-home-cache-cleanup: true
|
gradle-home-cache-cleanup: true
|
||||||
|
- name: Remove tags for release on other versions
|
||||||
|
if: steps.check_branch.outputs.is_release == 'true'
|
||||||
|
run: ./scripts/tagcleaner.sh
|
||||||
- name: Build ModernFix using Gradle
|
- name: Build ModernFix using Gradle
|
||||||
run: ./gradlew build
|
run: ./gradlew build
|
||||||
|
- name: Publish mod to CurseForge & Modrinth
|
||||||
|
if: steps.check_branch.outputs.is_release == 'true'
|
||||||
|
run: ./gradlew publishMods copyJarToBin
|
||||||
|
env:
|
||||||
|
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
|
||||||
|
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
|
||||||
- name: Upload Artifacts to GitHub
|
- name: Upload Artifacts to GitHub
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
34
.github/workflows/release.yml
vendored
34
.github/workflows/release.yml
vendored
|
|
@ -1,34 +0,0 @@
|
||||||
name: Release ModernFix Artifacts
|
|
||||||
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types:
|
|
||||||
- published
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
release:
|
|
||||||
if: github.repository_owner == 'embeddedt'
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
steps:
|
|
||||||
- name: Checkout Repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- name: Set up JDK 21
|
|
||||||
uses: actions/setup-java@v4
|
|
||||||
with:
|
|
||||||
distribution: 'temurin'
|
|
||||||
java-version: 21
|
|
||||||
check-latest: true
|
|
||||||
- name: Remove tags for release on other versions
|
|
||||||
run: ./scripts/tagcleaner.sh
|
|
||||||
- name: Build and publish mod to CurseForge & Modrinth
|
|
||||||
run: ./gradlew publishMods copyJarToBin
|
|
||||||
env:
|
|
||||||
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
|
|
||||||
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
|
|
||||||
- name: Upload assets to GitHub
|
|
||||||
uses: AButler/upload-release-assets@v3.0
|
|
||||||
with:
|
|
||||||
files: 'bin/*'
|
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
plugins {
|
plugins {
|
||||||
id("net.neoforged.moddev.legacyforge") version("2.0.134")
|
id("net.neoforged.moddev.legacyforge") version("2.0.134")
|
||||||
id("org.ajoberstar.grgit") version("5.2.0")
|
|
||||||
id("com.palantir.git-version") version("1.0.0")
|
|
||||||
id("me.modmuss50.mod-publish-plugin") version("1.1.0")
|
id("me.modmuss50.mod-publish-plugin") version("1.1.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -9,42 +7,14 @@ val minecraft_version = rootProject.properties["minecraft_version"].toString()
|
||||||
|
|
||||||
group = "org.embeddedt"
|
group = "org.embeddedt"
|
||||||
|
|
||||||
val versionDetails: groovy.lang.Closure<com.palantir.gradle.gitversion.VersionDetails> by extra
|
val gitVersion = providers.of(GitVersionSource::class) {
|
||||||
// extract base version from tag, generate other metadata ourselves
|
parameters {
|
||||||
val details = versionDetails()
|
minecraftVersion.set(minecraft_version)
|
||||||
|
projectDir.set(rootProject.layout.projectDirectory)
|
||||||
var plusIndex = details.lastTag.indexOf("+")
|
}
|
||||||
if (plusIndex == -1) {
|
|
||||||
plusIndex = details.lastTag.length
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var baseVersion = details.lastTag.substring(0, plusIndex)
|
version = gitVersion.get()
|
||||||
|
|
||||||
val dirtyMarker = if (grgit.status().isClean) "" else ".dirty"
|
|
||||||
|
|
||||||
val commitHashMarker =
|
|
||||||
if (details.commitDistance > 0)
|
|
||||||
"." + details.gitHash.substring(0, minOf(4, details.gitHash.length))
|
|
||||||
else
|
|
||||||
""
|
|
||||||
|
|
||||||
var preMarker =
|
|
||||||
if (details.commitDistance > 0 || !details.isCleanTag)
|
|
||||||
"-beta.${details.commitDistance}"
|
|
||||||
else
|
|
||||||
""
|
|
||||||
|
|
||||||
if (preMarker.isNotEmpty()) {
|
|
||||||
// bump to next patch release
|
|
||||||
val versionParts = baseVersion.split(".")
|
|
||||||
baseVersion =
|
|
||||||
"${versionParts[0]}.${versionParts[1]}.${versionParts[2].toInt() + 1}"
|
|
||||||
}
|
|
||||||
|
|
||||||
val versionString =
|
|
||||||
"${baseVersion}${preMarker}+mc${minecraft_version}${commitHashMarker}${dirtyMarker}"
|
|
||||||
|
|
||||||
version = versionString
|
|
||||||
|
|
||||||
base.archivesName = "modernfix-forge"
|
base.archivesName = "modernfix-forge"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,67 +0,0 @@
|
||||||
plugins {
|
|
||||||
id "architectury-plugin" version "3.4-SNAPSHOT"
|
|
||||||
id "dev.architectury.loom" version "1.9-SNAPSHOT" apply false
|
|
||||||
id "maven-publish"
|
|
||||||
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
|
|
||||||
id 'com.palantir.git-version' version '1.0.0'
|
|
||||||
id 'org.ajoberstar.grgit' version '5.2.0'
|
|
||||||
id 'se.bjurr.gitchangelog.git-changelog-gradle-plugin' version '1.79.0'
|
|
||||||
id "com.modrinth.minotaur" version "2.+" apply false
|
|
||||||
id("com.diffplug.spotless") version "6.25.0" apply false
|
|
||||||
id 'modernfix.common-conventions' apply false
|
|
||||||
}
|
|
||||||
|
|
||||||
architectury {
|
|
||||||
minecraft = rootProject.minecraft_version
|
|
||||||
}
|
|
||||||
|
|
||||||
ext.archives_base_name = 'modernfix'
|
|
||||||
|
|
||||||
apply plugin: 'modernfix.common-conventions'
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile).configureEach {
|
|
||||||
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
|
||||||
// this fixes some edge cases with special characters not displaying correctly
|
|
||||||
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
|
||||||
// If Javadoc is generated, this must be specified in that task too.
|
|
||||||
options.encoding = "UTF-8"
|
|
||||||
|
|
||||||
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
|
|
||||||
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
|
|
||||||
// We'll use that if it's available, but otherwise we'll use the older option.
|
|
||||||
def targetVersion = 8
|
|
||||||
/*
|
|
||||||
if (JavaVersion.current().isJava9Compatible()) {
|
|
||||||
options.release = targetVersion
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register('generateChangelog', se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
|
|
||||||
def details = versionDetails();
|
|
||||||
def theVersionRef
|
|
||||||
if (details.commitDistance > 0) {
|
|
||||||
theVersionRef = details.lastTag;
|
|
||||||
} else {
|
|
||||||
def secondLastTagCmd = "git describe --abbrev=0 " + details.lastTag + "^"
|
|
||||||
def secondLastTag = secondLastTagCmd.execute().text.trim()
|
|
||||||
theVersionRef = secondLastTag;
|
|
||||||
}
|
|
||||||
|
|
||||||
fromRef = theVersionRef
|
|
||||||
|
|
||||||
file = new File("${rootDir}/CHANGELOG.md");
|
|
||||||
templateContent = new File("${rootDir}/gradle/changelog.mustache").getText('UTF-8').replace("[[modernFixVersionRef]]", theVersionRef);
|
|
||||||
toCommit = "HEAD";
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register('checkCleanTag') {
|
|
||||||
doLast {
|
|
||||||
def details = versionDetails()
|
|
||||||
if (!details.isCleanTag || versionDetails().commitDistance != 0) {
|
|
||||||
throw new GradleException('Not a clean tree.')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
println "ModernFix: " + version
|
|
||||||
7
buildSrc/build.gradle.kts
Normal file
7
buildSrc/build.gradle.kts
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
plugins {
|
||||||
|
`kotlin-dsl`
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
61
buildSrc/src/main/kotlin/GitVersionSource.kt
Normal file
61
buildSrc/src/main/kotlin/GitVersionSource.kt
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
import org.gradle.api.file.DirectoryProperty
|
||||||
|
import org.gradle.api.provider.Property
|
||||||
|
import org.gradle.api.provider.ValueSource
|
||||||
|
import org.gradle.api.provider.ValueSourceParameters
|
||||||
|
import org.gradle.process.ExecOperations
|
||||||
|
import java.io.ByteArrayOutputStream
|
||||||
|
import java.io.File
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
abstract class GitVersionSource : ValueSource<String, GitVersionSource.Parameters> {
|
||||||
|
|
||||||
|
interface Parameters : ValueSourceParameters {
|
||||||
|
val minecraftVersion: Property<String>
|
||||||
|
val projectDir: DirectoryProperty
|
||||||
|
}
|
||||||
|
|
||||||
|
@get:Inject
|
||||||
|
abstract val execOperations: ExecOperations
|
||||||
|
|
||||||
|
override fun obtain(): String {
|
||||||
|
val minecraftVersion = parameters.minecraftVersion.get()
|
||||||
|
val workDir = parameters.projectDir.get().asFile
|
||||||
|
|
||||||
|
val releaseLine = workDir.resolve("release_line.txt").readText().trim()
|
||||||
|
|
||||||
|
val patch = try {
|
||||||
|
// Find the most recent first-parent commit that touched release_line.txt
|
||||||
|
val lineStartCommit = git(workDir,
|
||||||
|
"log", "--first-parent",
|
||||||
|
"-n", "1",
|
||||||
|
"--format=%H",
|
||||||
|
"--",
|
||||||
|
"release_line.txt"
|
||||||
|
).trim()
|
||||||
|
|
||||||
|
if (lineStartCommit.isEmpty()) {
|
||||||
|
// count all first-parent commits as a safe fallback
|
||||||
|
git(workDir, "rev-list", "--count", "--first-parent", "HEAD")
|
||||||
|
.trim().toIntOrNull() ?: 0
|
||||||
|
} else {
|
||||||
|
git(workDir, "rev-list", "--count", "--first-parent", "$lineStartCommit..HEAD")
|
||||||
|
.trim().toIntOrNull() ?: 0
|
||||||
|
}
|
||||||
|
} catch (_: Exception) {
|
||||||
|
// Git is unavailable or this is not a git repository
|
||||||
|
999
|
||||||
|
}
|
||||||
|
|
||||||
|
return "$releaseLine.$patch+mc$minecraftVersion"
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun git(workDir: File, vararg args: String): String {
|
||||||
|
val output = ByteArrayOutputStream()
|
||||||
|
execOperations.exec {
|
||||||
|
commandLine("git", *args)
|
||||||
|
standardOutput = output
|
||||||
|
workingDir(workDir)
|
||||||
|
}
|
||||||
|
return output.toString(Charsets.UTF_8)
|
||||||
|
}
|
||||||
|
}
|
||||||
1
release_line.txt
Normal file
1
release_line.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
5.27
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
pluginManagement {
|
|
||||||
repositories {
|
|
||||||
gradlePluginPortal()
|
|
||||||
maven { url "https://maven.fabricmc.net/" }
|
|
||||||
maven { url "https://maven.architectury.dev/" }
|
|
||||||
maven { url "https://maven.minecraftforge.net/" }
|
|
||||||
}
|
|
||||||
resolutionStrategy {
|
|
||||||
eachPlugin {
|
|
||||||
if (requested.id.id == "com.github.johnrengelman.shadow") {
|
|
||||||
useModule("gradle.plugin.com.github.johnrengelman:shadow:${shadow_version}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
include("annotation-processor")
|
|
||||||
include("annotations")
|
|
||||||
include("test_agent")
|
|
||||||
include("common")
|
|
||||||
|
|
||||||
def current_platforms = getProperty("enabled_platforms").tokenize(',')
|
|
||||||
current_platforms.each { it ->
|
|
||||||
def platform_name = it.trim()
|
|
||||||
include(platform_name)
|
|
||||||
if(hasProperty("modernfix.testmod.enable")) {
|
|
||||||
def testmodFolder = new File(platform_name + "/" + "testmod")
|
|
||||||
if (testmodFolder.isDirectory()) {
|
|
||||||
include(platform_name + ":testmod")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rootProject.name = 'modernfix'
|
|
||||||
Loading…
Reference in New Issue
Block a user