Skip to content

Commit c3c0127

Browse files
committed
Grant execute permissions for gradlew in Modrinth and Hangar workflows; improve Git versioning error handling
1 parent 7dd996b commit c3c0127

3 files changed

Lines changed: 31 additions & 8 deletions

File tree

.github/workflows/hangar-publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
- name: Setup Gradle
2727
uses: gradle/actions/setup-gradle@v4
2828

29+
- name: Grant execute permission for gradlew
30+
run: chmod +x gradlew
31+
2932
- name: Publish to Hangar
3033
run: ./gradlew :eternalcore-plugin:publishPluginPublicationToHangar
3134
env:

.github/workflows/modrinth-publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
- name: Setup Gradle
2727
uses: gradle/actions/setup-gradle@v4
2828

29+
- name: Grant execute permission for gradlew
30+
run: chmod +x gradlew
31+
2932
- name: Publish to Modrinth
3033
run: ./gradlew :eternalcore-plugin:modrinth
3134
env:

buildSrc/src/main/kotlin/eternalcore-publish-plugin.gradle.kts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,35 @@ val buildNumber = providers.environmentVariable("GITHUB_RUN_NUMBER").orNull
1010
val isRelease = providers.environmentVariable("GITHUB_EVENT_NAME").orNull == "release"
1111

1212
if (buildNumber != null && !isRelease) {
13-
val offset = try {
14-
val description = providers.exec {
13+
var offset = "0"
14+
15+
try {
16+
val describeResult = providers.exec {
1517
commandLine("git", "describe", "--tags", "--long")
16-
}.standardOutput.asText.get().trim()
17-
val parts = description.split("-")
18-
if (parts.size >= 3) parts[parts.size - 2] else "0"
18+
isIgnoreExitValue = true
19+
}
20+
val exitCode = describeResult.result.get().exitValue
21+
22+
if (exitCode == 0) {
23+
val description = describeResult.standardOutput.asText.get().trim()
24+
val parts = description.split("-")
25+
if (parts.size >= 3) {
26+
offset = parts[parts.size - 2]
27+
}
28+
}
1929
} catch (e: Exception) {
30+
}
31+
32+
if (offset == "0") {
2033
try {
21-
providers.exec {
34+
val revListResult = providers.exec {
2235
commandLine("git", "rev-list", "--count", "HEAD")
23-
}.standardOutput.asText.get().trim()
36+
isIgnoreExitValue = true
37+
}
38+
if (revListResult.result.get().exitValue == 0) {
39+
offset = revListResult.standardOutput.asText.get().trim()
40+
}
2441
} catch (e: Exception) {
25-
"0"
2642
}
2743
}
2844

@@ -32,6 +48,7 @@ if (buildNumber != null && !isRelease) {
3248

3349
val changelogText = providers.environmentVariable("CHANGELOG").orElse(providers.exec {
3450
commandLine("git", "log", "-1", "--format=%B")
51+
isIgnoreExitValue = true
3552
}.standardOutput.asText)
3653

3754
logger.lifecycle("Building version: $version")

0 commit comments

Comments
 (0)