Skip to content

Commit

Permalink
feat: initial ci run
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHillcox committed Feb 4, 2025
1 parent ed0a242 commit 52050a4
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 25 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Java CI - Build Release

on:
push:
branches:
- main
- "[0-9]+\.[0-9]+/main"

jobs:
build:
runs-on: ubuntu-latest
if: |
!contains(github.event.head_commit.message, '[ciskip]')
steps:
- name: Clone project
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: "microsoft"
java-version: 21
- name: Fix borked permissions
run: chmod +x ./gradlew
- name: Get minecraft version
run: |
export MC_VERSION=$(grep ^minecraft_version= ./gradle.properties | cut -d= -f2)
if [ -z "$MC_VERSION" ]; then
echo "Could not find minecraft_version in gradle.properties"
exit 1
fi
- name: Pull meta data
run: |
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)
git log --pretty=full $LAST_HASH..HEAD >> COMMIT_HISTORY
- name: Download FTB Worlds
run: |
mkdir -p libs
curl -o libs/rgp_client-1.0.6.jar https://cdn.feed-the-beast.com/ephemeral/rgp_client-1.0.6.jar
- name: Setup Gradle and Validate Wrapper
uses: gradle/actions/setup-gradle@v4
with:
cache-read-only: false
- name: Run gradle tasks
run: ./gradlew build publishMods publish
env:
BUILD_NUMBER: ${{ github.run_number }}
FTB_MAVEN_TOKEN: ${{ secrets.FTB_MAVEN_TOKEN }}
CURSEFORGE_KEY: ${{ secrets.CURSEFORGE_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update Meta info
# Get the current commit hash and push it against the minecraft version
run: |
export CURRENT_HASH=$(git rev-parse HEAD)
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}
110 changes: 85 additions & 25 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ dependencies {
implementation "libs:rgp_client:1.0.6"
}

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

// Deps
Expand Down Expand Up @@ -146,27 +145,88 @@ idea {
}
}

//publishMods {
// dryRun = providers.environmentVariable("CURSEFORGE_KEY").getOrNull() == null
// changelog = createChangelog(project)
// version = "${mod_version}"
// file = project.provider { project(":$projectName").tasks.remapJar }.flatMap { it.archiveFile }
//
// // TODO: Migrate to something else
// def tag = providers.environmentVariable("TAG").getOrElse("release")
// type = STABLE
//
// curseforge {
// displayName = "[${projectName.toUpperCase()}][${minecraft_version}] ${readable_name} ${mod_version}"
// modLoaders.add("neoforge")
//
// accessToken = providers.environmentVariable("CURSEFORGE_KEY")
// minecraftVersions.add("${minecraft_version}")
//
// projectId = curseforge_id_forge
// requires('architectury-api')
// requires('ftb-library-forge')
// requires('ftb-teams-forge')
// optional('ftb-xmod-compat')
// }
//}
def createChangelog() {
def commitHistory = file("COMMIT_HISTORY")
if (!commitHistory.exists()) {
return ""
}

def line = commitHistory.readLines()
Map<String, List<String>> changes = [
"added" : [],
"fixed" : [],
"changed": [],
"removed": [],
]

def reading = false
for (def commit : line) {
if (commit.startsWith("Date:")) {
reading = true
continue
}

if (commit.startsWith("commit")) {
reading = false
continue
}

if (!reading) {
continue
}

commit = commit.trim()
if (commit.empty) {
continue
}

if (commit.startsWith("feat: ")) changes.get("added") << commit.substring(6)
if (commit.startsWith("fix: ")) changes.get("fixed") << commit.substring(5)
if (commit.startsWith("chore: ")) changes.get("changed") << commit.substring(7)
if (commit.startsWith("refactor: ")) changes.get("changed") << commit.substring(10)
if (commit.startsWith("removed: ")) changes.get("removed") << commit.substring(9)
}

def changelog = ""
def changesKeys = changes.keySet()
for (def key : changesKeys) {
def changeList = changes[key]
if (changeList.size() > 0) {
changelog += "### ${key.capitalize()}\n\n"
for (def change : changeList) {
// Titlecase the change
change = change.substring(0, 1).toUpperCase() + change.substring(1)
changelog += "- $change\n"
}
}

changelog += "\n"
}

def output = changelog.trim()
if (output.empty) {
return "No changelog provided"
}

return output
}

publishMods {
dryRun = true
changelog = createChangelog()
file = jar.archiveFile
displayName = "[NEOFORGE] FTB Promoter ${project.version}"
modLoaders.add("neoforge")

type = STABLE

curseforge {
accessToken = providers.environmentVariable("CURSEFORGE_KEY")
minecraftVersions.add(minecraft_version)

projectId = curseforge_id

optional('fancymenu')
optional('bisecthosting-server-integration-menu-neoforge')
}
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ parchment_minecraft_version=1.21.1
parchment_mappings_version=2024.11.17

mod_id=ftbpromoter
curseforge_id=126

minecraft_version=1.21.1
minecraft_version_range=[1.21.1]
Expand Down

0 comments on commit 52050a4

Please sign in to comment.