Skip to content

Commit 52050a4

Browse files
feat: initial ci run
1 parent ed0a242 commit 52050a4

File tree

3 files changed

+142
-25
lines changed

3 files changed

+142
-25
lines changed

.github/workflows/release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Java CI - Build Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- "[0-9]+\.[0-9]+/main"
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
if: |
13+
!contains(github.event.head_commit.message, '[ciskip]')
14+
steps:
15+
- name: Clone project
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
- name: Set up JDK
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: "microsoft"
23+
java-version: 21
24+
- name: Fix borked permissions
25+
run: chmod +x ./gradlew
26+
- name: Get minecraft version
27+
run: |
28+
export MC_VERSION=$(grep ^minecraft_version= ./gradle.properties | cut -d= -f2)
29+
if [ -z "$MC_VERSION" ]; then
30+
echo "Could not find minecraft_version in gradle.properties"
31+
exit 1
32+
fi
33+
- name: Pull meta data
34+
run: |
35+
export LAST_HASH=$((curl https://api.feed-the-beast.com/versions/mods/ftb-promoter/${MC_VERSION} | jq -r -e .hash) || git rev-list HEAD | tail -n 1)
36+
git log --pretty=full $LAST_HASH..HEAD >> COMMIT_HISTORY
37+
- name: Download FTB Worlds
38+
run: |
39+
mkdir -p libs
40+
curl -o libs/rgp_client-1.0.6.jar https://cdn.feed-the-beast.com/ephemeral/rgp_client-1.0.6.jar
41+
- name: Setup Gradle and Validate Wrapper
42+
uses: gradle/actions/setup-gradle@v4
43+
with:
44+
cache-read-only: false
45+
- name: Run gradle tasks
46+
run: ./gradlew build publishMods publish
47+
env:
48+
BUILD_NUMBER: ${{ github.run_number }}
49+
FTB_MAVEN_TOKEN: ${{ secrets.FTB_MAVEN_TOKEN }}
50+
CURSEFORGE_KEY: ${{ secrets.CURSEFORGE_KEY }}
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
- name: Update Meta info
53+
# Get the current commit hash and push it against the minecraft version
54+
run: |
55+
export CURRENT_HASH=$(git rev-parse HEAD)
56+
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer ${{ secrets.META_TOKEN }}" -d "{\"hash\":\"$CURRENT_HASH\"}" https://api.feed-the-beast.com/versions/mods/ftb-promoter/${MC_VERSION}

build.gradle

Lines changed: 85 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ dependencies {
9494
implementation "libs:rgp_client:1.0.6"
9595
}
9696

97-
implementation "dev.ftb.mods:ftb-library-neoforge:2101.1.8"
9897
implementation "curse.maven:fancymenu-367706:5823966"
9998

10099
// Deps
@@ -146,27 +145,88 @@ idea {
146145
}
147146
}
148147

149-
//publishMods {
150-
// dryRun = providers.environmentVariable("CURSEFORGE_KEY").getOrNull() == null
151-
// changelog = createChangelog(project)
152-
// version = "${mod_version}"
153-
// file = project.provider { project(":$projectName").tasks.remapJar }.flatMap { it.archiveFile }
154-
//
155-
// // TODO: Migrate to something else
156-
// def tag = providers.environmentVariable("TAG").getOrElse("release")
157-
// type = STABLE
158-
//
159-
// curseforge {
160-
// displayName = "[${projectName.toUpperCase()}][${minecraft_version}] ${readable_name} ${mod_version}"
161-
// modLoaders.add("neoforge")
162-
//
163-
// accessToken = providers.environmentVariable("CURSEFORGE_KEY")
164-
// minecraftVersions.add("${minecraft_version}")
165-
//
166-
// projectId = curseforge_id_forge
167-
// requires('architectury-api')
168-
// requires('ftb-library-forge')
169-
// requires('ftb-teams-forge')
170-
// optional('ftb-xmod-compat')
171-
// }
172-
//}
148+
def createChangelog() {
149+
def commitHistory = file("COMMIT_HISTORY")
150+
if (!commitHistory.exists()) {
151+
return ""
152+
}
153+
154+
def line = commitHistory.readLines()
155+
Map<String, List<String>> changes = [
156+
"added" : [],
157+
"fixed" : [],
158+
"changed": [],
159+
"removed": [],
160+
]
161+
162+
def reading = false
163+
for (def commit : line) {
164+
if (commit.startsWith("Date:")) {
165+
reading = true
166+
continue
167+
}
168+
169+
if (commit.startsWith("commit")) {
170+
reading = false
171+
continue
172+
}
173+
174+
if (!reading) {
175+
continue
176+
}
177+
178+
commit = commit.trim()
179+
if (commit.empty) {
180+
continue
181+
}
182+
183+
if (commit.startsWith("feat: ")) changes.get("added") << commit.substring(6)
184+
if (commit.startsWith("fix: ")) changes.get("fixed") << commit.substring(5)
185+
if (commit.startsWith("chore: ")) changes.get("changed") << commit.substring(7)
186+
if (commit.startsWith("refactor: ")) changes.get("changed") << commit.substring(10)
187+
if (commit.startsWith("removed: ")) changes.get("removed") << commit.substring(9)
188+
}
189+
190+
def changelog = ""
191+
def changesKeys = changes.keySet()
192+
for (def key : changesKeys) {
193+
def changeList = changes[key]
194+
if (changeList.size() > 0) {
195+
changelog += "### ${key.capitalize()}\n\n"
196+
for (def change : changeList) {
197+
// Titlecase the change
198+
change = change.substring(0, 1).toUpperCase() + change.substring(1)
199+
changelog += "- $change\n"
200+
}
201+
}
202+
203+
changelog += "\n"
204+
}
205+
206+
def output = changelog.trim()
207+
if (output.empty) {
208+
return "No changelog provided"
209+
}
210+
211+
return output
212+
}
213+
214+
publishMods {
215+
dryRun = true
216+
changelog = createChangelog()
217+
file = jar.archiveFile
218+
displayName = "[NEOFORGE] FTB Promoter ${project.version}"
219+
modLoaders.add("neoforge")
220+
221+
type = STABLE
222+
223+
curseforge {
224+
accessToken = providers.environmentVariable("CURSEFORGE_KEY")
225+
minecraftVersions.add(minecraft_version)
226+
227+
projectId = curseforge_id
228+
229+
optional('fancymenu')
230+
optional('bisecthosting-server-integration-menu-neoforge')
231+
}
232+
}

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ parchment_minecraft_version=1.21.1
22
parchment_mappings_version=2024.11.17
33

44
mod_id=ftbpromoter
5+
curseforge_id=126
56

67
minecraft_version=1.21.1
78
minecraft_version_range=[1.21.1]

0 commit comments

Comments
 (0)