Skip to content

Commit c2191df

Browse files
committed
Release 5.27.0 & enable continuous deployment
1 parent d08da1b commit c2191df

8 files changed

Lines changed: 97 additions & 172 deletions

File tree

.github/workflows/gradle.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
jobs:
1212
build:
1313
runs-on: ubuntu-22.04
14+
concurrency:
15+
group: release-${{ github.ref }}
16+
cancel-in-progress: true
1417
steps:
1518
- name: Checkout Repository
1619
uses: actions/checkout@v4
@@ -22,13 +25,31 @@ jobs:
2225
distribution: 'temurin'
2326
java-version: 21
2427
check-latest: true
28+
- name: Check if release branch
29+
id: check_branch
30+
if: github.event_name == 'push'
31+
run: |
32+
if [[ "${{ github.ref }}" =~ ^refs/heads/[0-9]+\. ]]; then
33+
echo "is_release=true" >> $GITHUB_OUTPUT
34+
else
35+
echo "is_release=false" >> $GITHUB_OUTPUT
36+
fi
2537
- name: Setup Gradle
2638
uses: gradle/actions/setup-gradle@v4
2739
with:
28-
cache-read-only: ${{ !startsWith(github.ref, 'refs/heads/1.') }}
40+
cache-read-only: ${{ steps.check_branch.outputs.is_release != 'true' }}
2941
gradle-home-cache-cleanup: true
42+
- name: Remove tags for release on other versions
43+
if: steps.check_branch.outputs.is_release == 'true'
44+
run: ./scripts/tagcleaner.sh
3045
- name: Build ModernFix using Gradle
3146
run: ./gradlew build
47+
- name: Publish mod to CurseForge & Modrinth
48+
if: steps.check_branch.outputs.is_release == 'true'
49+
run: ./gradlew publishMods copyJarToBin
50+
env:
51+
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
52+
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
3253
- name: Upload Artifacts to GitHub
3354
uses: actions/upload-artifact@v4
3455
with:

.github/workflows/release.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

build.gradle.kts

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,20 @@
11
plugins {
22
id("net.neoforged.moddev.legacyforge") version("2.0.134")
3-
id("org.ajoberstar.grgit") version("5.2.0")
4-
id("com.palantir.git-version") version("1.0.0")
53
id("me.modmuss50.mod-publish-plugin") version("1.1.0")
64
}
75

86
val minecraft_version = rootProject.properties["minecraft_version"].toString()
97

108
group = "org.embeddedt"
119

12-
val versionDetails: groovy.lang.Closure<com.palantir.gradle.gitversion.VersionDetails> by extra
13-
// extract base version from tag, generate other metadata ourselves
14-
val details = versionDetails()
15-
16-
var plusIndex = details.lastTag.indexOf("+")
17-
if (plusIndex == -1) {
18-
plusIndex = details.lastTag.length
19-
}
20-
21-
var baseVersion = details.lastTag.substring(0, plusIndex)
22-
23-
val dirtyMarker = if (grgit.status().isClean) "" else ".dirty"
24-
25-
val commitHashMarker =
26-
if (details.commitDistance > 0)
27-
"." + details.gitHash.substring(0, minOf(4, details.gitHash.length))
28-
else
29-
""
30-
31-
var preMarker =
32-
if (details.commitDistance > 0 || !details.isCleanTag)
33-
"-beta.${details.commitDistance}"
34-
else
35-
""
36-
37-
if (preMarker.isNotEmpty()) {
38-
// bump to next patch release
39-
val versionParts = baseVersion.split(".")
40-
baseVersion =
41-
"${versionParts[0]}.${versionParts[1]}.${versionParts[2].toInt() + 1}"
10+
val gitVersion = providers.of(GitVersionSource::class) {
11+
parameters {
12+
minecraftVersion.set(minecraft_version)
13+
projectDir.set(rootProject.layout.projectDirectory)
14+
}
4215
}
4316

44-
val versionString =
45-
"${baseVersion}${preMarker}+mc${minecraft_version}${commitHashMarker}${dirtyMarker}"
46-
47-
version = versionString
17+
version = gitVersion.get()
4818

4919
base.archivesName = "modernfix-forge"
5020

build.gradle.legacy

Lines changed: 0 additions & 67 deletions
This file was deleted.

buildSrc/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import org.gradle.api.file.DirectoryProperty
2+
import org.gradle.api.provider.Property
3+
import org.gradle.api.provider.ValueSource
4+
import org.gradle.api.provider.ValueSourceParameters
5+
import org.gradle.process.ExecOperations
6+
import java.io.ByteArrayOutputStream
7+
import java.io.File
8+
import javax.inject.Inject
9+
10+
abstract class GitVersionSource : ValueSource<String, GitVersionSource.Parameters> {
11+
12+
interface Parameters : ValueSourceParameters {
13+
val minecraftVersion: Property<String>
14+
val projectDir: DirectoryProperty
15+
}
16+
17+
@get:Inject
18+
abstract val execOperations: ExecOperations
19+
20+
override fun obtain(): String {
21+
val minecraftVersion = parameters.minecraftVersion.get()
22+
val workDir = parameters.projectDir.get().asFile
23+
24+
val releaseLine = workDir.resolve("release_line.txt").readText().trim()
25+
26+
val patch = try {
27+
// Find the most recent first-parent commit that touched release_line.txt
28+
val lineStartCommit = git(workDir,
29+
"log", "--first-parent",
30+
"-n", "1",
31+
"--format=%H",
32+
"--",
33+
"release_line.txt"
34+
).trim()
35+
36+
if (lineStartCommit.isEmpty()) {
37+
// count all first-parent commits as a safe fallback
38+
git(workDir, "rev-list", "--count", "--first-parent", "HEAD")
39+
.trim().toIntOrNull() ?: 0
40+
} else {
41+
git(workDir, "rev-list", "--count", "--first-parent", "$lineStartCommit..HEAD")
42+
.trim().toIntOrNull() ?: 0
43+
}
44+
} catch (_: Exception) {
45+
// Git is unavailable or this is not a git repository
46+
999
47+
}
48+
49+
return "$releaseLine.$patch+mc$minecraftVersion"
50+
}
51+
52+
private fun git(workDir: File, vararg args: String): String {
53+
val output = ByteArrayOutputStream()
54+
execOperations.exec {
55+
commandLine("git", *args)
56+
standardOutput = output
57+
workingDir(workDir)
58+
}
59+
return output.toString(Charsets.UTF_8)
60+
}
61+
}

release_line.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5.27

settings.gradle.legacy

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)