Skip to content

Commit 7b29ccc

Browse files
committed
Fix build, update gradle, publish every commit
1 parent f13ef9d commit 7b29ccc

11 files changed

Lines changed: 59 additions & 89 deletions

File tree

.github/workflows/modrinth.yml

Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,41 @@
1-
name: Daily Modrinth Publish
1+
name: Modrinth Publish
22

33
on:
4-
schedule:
5-
# Runs at 00:00 UTC every day
6-
- cron: '0 0 * * *'
4+
push:
5+
branches:
6+
- master
77
# Allow manual triggering from the GitHub UI
88
workflow_dispatch:
9-
inputs:
10-
force_run:
11-
description: 'Force run even if no recent commits (ignores commit check)'
12-
required: false
13-
default: 'false'
14-
type: boolean
159
# Trigger when a new release is created
1610
release:
1711
types: [created]
1812

1913
jobs:
20-
check-commits-and-publish:
14+
publish:
2115
if: github.repository_owner == 'SamB440'
2216
runs-on: ubuntu-latest
2317
steps:
2418
- name: Checkout repository
25-
uses: actions/checkout@v4
19+
uses: actions/checkout@v6
2620
with:
2721
fetch-depth: 0 # Fetch all history for all branches and tags
2822

29-
- name: Check if should run
30-
id: check_run
31-
run: |
32-
# Always run for releases or forced manual runs
33-
if [[ "${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.force_run == 'true') }}" == "true" ]]; then
34-
echo "::set-output name=should_run::true"
35-
echo "Release or forced run - proceeding with Modrinth publish"
36-
# For scheduled runs, check for recent commits
37-
else
38-
echo "=== Debug Information ==="
39-
echo "Current time: $(date)"
40-
echo "24 hours ago: $(date -d '24 hours ago')"
41-
echo "Git log history:"
42-
git log --since="24 hours ago" --pretty=format:'%h - %s (%cr)' || echo "Git log command failed"
43-
44-
echo "\nChecking for commits in the last 24 hours..."
45-
46-
COMMIT_COUNT=$(git rev-list --count --since="24 hours ago" HEAD)
47-
echo "Found $COMMIT_COUNT commits in the last 24 hours"
48-
49-
if [ "$COMMIT_COUNT" -gt 0 ]; then
50-
echo "::set-output name=should_run::true"
51-
else
52-
echo "No commits found in the last 24 hours"
53-
echo "::set-output name=should_run::false"
54-
fi
55-
fi
56-
57-
- name: Set up JDK 21
58-
if: steps.check_run.outputs.should_run == 'true'
59-
uses: actions/setup-java@v4
23+
- name: Set up JDK 25
24+
uses: actions/setup-java@v5
6025
with:
61-
java-version: '21'
26+
java-version: '25'
6227
distribution: 'temurin'
6328

6429
- name: Setup Gradle
65-
if: steps.check_run.outputs.should_run == 'true'
66-
uses: gradle/actions/setup-gradle@v4
30+
uses: gradle/actions/setup-gradle@v6
6731

6832
- name: Publish to Modrinth
69-
if: steps.check_run.outputs.should_run == 'true'
7033
run: ./gradlew modrinth
7134
env:
7235
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
7336

7437
- name: Capture build artifacts
75-
if: steps.check_run.outputs.should_run == 'true'
76-
uses: actions/upload-artifact@v4
38+
uses: actions/upload-artifact@v7
7739
with:
7840
name: Artifacts
7941
path: |

.github/workflows/publish.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout repository
13-
uses: actions/checkout@v4
13+
uses: actions/checkout@v6
1414
with:
1515
fetch-depth: 0 # Fetch all history for all branches and tags
1616

17-
- name: Setup JDK 21
18-
uses: actions/setup-java@v4
17+
- name: Setup JDK 25
18+
uses: actions/setup-java@v5
1919
with:
20-
java-version: '21'
20+
java-version: '25'
2121
distribution: 'temurin'
2222

2323
- name: Setup Gradle
24-
uses: gradle/actions/setup-gradle@v4 # Handles Gradle wrapper validation and basic caching
24+
uses: gradle/actions/setup-gradle@v6 # Handles Gradle wrapper validation and basic caching
2525

2626
- name: Build and Publish to Convallyria repository
2727
run: ./gradlew build publish
@@ -30,7 +30,7 @@ jobs:
3030
MAVEN_PASSWORD: ${{ secrets.REPO_PASSWORD }}
3131

3232
- name: Capture build artifacts
33-
uses: actions/upload-artifact@v4
33+
uses: actions/upload-artifact@v7
3434
with:
3535
name: Artifacts
3636
path: |

.github/workflows/pull_request.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@ jobs:
66
runs-on: ubuntu-latest
77
steps:
88
- name: Checkout repository
9-
uses: actions/checkout@v4
9+
uses: actions/checkout@v6
1010

11-
- name: Setup JDK 21
12-
uses: actions/setup-java@v4
11+
- name: Setup JDK 25
12+
uses: actions/setup-java@v5
1313
with:
14-
java-version: '21'
14+
java-version: '25'
1515
distribution: 'temurin'
1616

1717
- name: Setup Gradle
18-
uses: gradle/actions/setup-gradle@v4 # Handles Gradle wrapper validation and basic caching
18+
uses: gradle/actions/setup-gradle@v6 # Handles Gradle wrapper validation and basic caching
1919

2020
- name: Build
2121
run: ./gradlew build
2222

2323
- name: Capture build artifacts
24-
uses: actions/upload-artifact@v4
24+
uses: actions/upload-artifact@v7
2525
with:
2626
name: Artifacts
2727
path: |

build-logic/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repositories {
1616
}
1717

1818
dependencies {
19-
implementation("com.gradleup.shadow:shadow-gradle-plugin:9.0.0-beta12")
20-
implementation("com.diffplug.spotless:spotless-plugin-gradle:7.0.3")
19+
implementation("com.gradleup.shadow:shadow-gradle-plugin:9.4.1")
20+
implementation("com.diffplug.spotless:spotless-plugin-gradle:8.4.0")
2121
implementation("com.modrinth.minotaur:com.modrinth.minotaur.gradle.plugin:2.+")
2222
}

build-logic/src/main/kotlin/buildlogic.java-modrinth-conventions.gradle.kts

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
import java.io.ByteArrayOutputStream
2-
31
plugins {
42
id("com.modrinth.minotaur")
53
}
64

75
// Helper methods
86
fun executeGitCommand(vararg command: String): String {
9-
val byteOut = ByteArrayOutputStream()
10-
exec {
7+
return providers.exec {
118
commandLine = listOf("git", *command)
12-
standardOutput = byteOut
13-
}
14-
return byteOut.toString(Charsets.UTF_8.name()).trim()
9+
}.standardOutput.asText.get().trim()
1510
}
1611

17-
fun latestCommitMessage(): String {
18-
val commits = executeGitCommand("log", "--since=24 hours ago", "--pretty=format:- %s")
19-
return if (commits.isNotBlank()) {
20-
"Recent changes (last 24 hours):\n$commits"
21-
} else {
22-
"No commits in the last 24 hours"
12+
fun latestCommitChangelog(): String {
13+
val shortHash = executeGitCommand("log", "-1", "--pretty=format:%h")
14+
val fullHash = executeGitCommand("log", "-1", "--pretty=format:%H")
15+
val author = executeGitCommand("log", "-1", "--pretty=format:%an")
16+
val date = executeGitCommand("log", "-1", "--pretty=format:%ad", "--date=short")
17+
val subject = executeGitCommand("log", "-1", "--pretty=format:%s")
18+
val body = executeGitCommand("log", "-1", "--pretty=format:%b")
19+
20+
return buildString {
21+
appendLine("### Commit [`$shortHash`](https://github.com/SamB440/ForcePack/commit/$fullHash)")
22+
appendLine()
23+
appendLine("**$subject**")
24+
if (body.isNotBlank()) {
25+
appendLine()
26+
appendLine(body.trim())
27+
}
28+
appendLine()
29+
append("by $author on $date")
2330
}
2431
}
2532

@@ -28,8 +35,12 @@ fun getChangelogSinceLastRelease(): String {
2835
val latestTag = executeGitCommand("describe", "--tags", "--abbrev=0")
2936
val currentVersion = project.version.toString()
3037

31-
// Get all commits between the latest tag and HEAD
32-
val commits = executeGitCommand("log", "--pretty=format:- %s", "$latestTag..HEAD")
38+
// Get all commits between the latest tag and HEAD, including short hash links
39+
val commits = executeGitCommand(
40+
"log",
41+
"--pretty=format:- %s ([`%h`](https://github.com/SamB440/ForcePack/commit/%H))",
42+
"$latestTag..HEAD"
43+
)
3344
.lines()
3445
.filter { it.isNotBlank() }
3546
.joinToString("\n")
@@ -64,11 +75,11 @@ modrinth {
6475
val changelogContent: String = if (isRelease) {
6576
getChangelogSinceLastRelease()
6677
} else {
67-
latestCommitMessage()
78+
latestCommitChangelog()
6879
}
6980
changelog.set(changelogContent)
7081
} catch (e: Exception) {
7182
println("Failed to generate changelog: ${e.message}. Was the repository cloned with tags?")
7283
changelog.set("Failed to generate changelog: ${e.message}")
7384
}
74-
}
85+
}

gradle/wrapper/gradle-wrapper.jar

5.08 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 2 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradlew.bat

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pluginManagement {
33
includeBuild("build-logic")
44

55
repositories {
6+
gradlePluginPortal()
67
maven("https://repo.spongepowered.org/repository/maven-public/") // Sponge
78
}
89
}

0 commit comments

Comments
 (0)