Skip to content

Commit

Permalink
Update to a new build and release system.
Browse files Browse the repository at this point in the history
  • Loading branch information
KiriCattus committed Aug 16, 2023
1 parent 5c58b06 commit a76a987
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 90 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/build-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build Artifacts

on: [ push, pull_request ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew

- name: Build with Gradle
run: ./gradlew clean build

- name: Upload build artifacts
uses: actions/[email protected]
with:
name: build-artifacts
path: build/libs
40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Upload Release Artifacts

on:
push:
tags:
- '*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew

- name: Build with Gradle
run: ./gradlew clean assemble

- name: Upload assets to Modrinth and CurseForge
uses: Kir-Antipov/[email protected]
with:
name: "${archivesBaseName}-${version}.jar"
version-type: release
changelog-file: changelog.*

modrinth-featured: true
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}

curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}

retry-attempts: 2
retry-delay: 10000
fail-mode: fail
57 changes: 6 additions & 51 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import java.time.OffsetDateTime
import java.time.ZoneOffset
import net.darkhax.curseforgegradle.TaskPublishCurseForge

plugins {
id 'idea'
id 'eclipse'
id 'maven-publish'
id 'fabric-loom' version '1.3-SNAPSHOT'
id 'com.modrinth.minotaur' version '2.+'
id 'org.cadixdev.licenser' version '0.6.1'
id 'net.darkhax.curseforgegradle' version '1.1.15'
}

archivesBaseName = mod_id
Expand Down Expand Up @@ -145,11 +142,15 @@ java {

// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
if (project.hasProperty('make_sources_jar') && project.findProperty('make_sources_jar').toBoolean()) {
withSourcesJar()
}

// If this mod is going to be a library, then it should also generate Javadocs in order to aid with development.
// Uncomment this line to generate them.
withJavadocJar()
if (project.hasProperty('make_javadoc_jar') && project.findProperty('make_javadoc_jar').toBoolean()) {
withJavadocJar()
}
}

var manifestAttributes = [
Expand Down Expand Up @@ -208,49 +209,3 @@ license {
author = mod_author
}
}

modrinth {
token = project.MODRINTH_TOKEN ?: "Invalid/No Modrinth API key could be found!" // This is the default.
projectId = modrinth_project_id // This can be the project ID or the slug. Either will work!
versionNumber = version // You don't need to set this manually. Will fail if Modrinth has this version already
versionType = modrinth_release_type // This is the default -- can also be `beta` or `alpha`
versionName = "${archivesBaseName}-${version}"
changelog = rootProject.file("changelog.md").text
uploadFile = remapJar // With Loom, this MUST be set to `remapJar` instead of `jar`!
gameVersions = [minecraft_version] // Must be an array, even with only one version
loaders = ["fabric", "quilt"] // Must also be an array - no need to specify this if you're using Loom or ForgeGradle
dependencies { // A special DSL for creating dependencies
// scope.type
// The scope can be `required`, `optional`, `incompatible`, or `embedded`
// The type can either be `project` or `version`
required.project "fabric-api" // Creates a new required dependency on Fabric API
optional.project "modmenu"
}
syncBodyFrom = rootProject.file("README.md").text
}

tasks.modrinth.dependsOn tasks.modrinthSyncBody
tasks.modrinth.dependsOn tasks.assemble

task curseforge(type: TaskPublishCurseForge) {
apiToken = project.CURSEFORGE_TOKEN ?: "Invalid/No CurseForge API key could be found!"

def mainFile = upload(curseforge_project_id, file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"))

mainFile.displayName = "${archivesBaseName}-${version}"
mainFile.releaseType = curseforge_release_type
mainFile.addModLoader("Fabric")
mainFile.addGameVersion(minecraft_version)
mainFile.addJavaVersion(curseforge_java_version)
mainFile.addRequirement('fabric-api') //Fabric API slug
mainFile.addOptional('modmenu')
mainFile.changelog = rootProject.file("changelog.md").text
mainFile.changelogType = 'text'
}

tasks.curseforge.dependsOn tasks.assemble

task publishToModHosts {
publishToModHosts.dependsOn modrinth
publishToModHosts.dependsOn curseforge
}
25 changes: 5 additions & 20 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ mod_id=kirislib
mod_group=dev.tophatcat.kirislib
mod_credits=KiriCattus
mod_author=KiriCattus
mod_homepage=https://modrinth.com/mod/kirislib
mod_cf=https://www.curseforge.com/minecraft/mc-mods/kiris-lib
mod_source=https://github.com/tophatcats-mods/kiris-lib
mod_issue_tracker=https://github.com/tophatcats-mods/kiris-lib/issues
mod_description=A library mod containing things that all my mods use to save time duplicating code that I already have.
mod_license_id=LGPL-2.1
mod_license_long=GNU Lesser General Public License v2.1
mod_discord=https://discord.tophatcat.dev

make_javadoc_jar=true
make_sources_jar=true

# Fabric properties
fabric_aws_enabled=false
Expand All @@ -22,20 +18,9 @@ fabric_loader_version=0.14.22
# Fabric API version numer is shared between all the modules.
fabric_api_version=0.86.1+1.20.1

# Modrinth properties.
modrinth_project_id=M6agkTxA
# Can also be beta or alpha
modrinth_release_type=release

# CurseForge properties.
curseforge_project_id=280547
#Can accept "alpha", "beta" or "release".
curseforge_release_type=release
curseforge_java_version=Java 17
# Dependencies are managed at gradle/libs.versions.toml
modmenu_version=7.2.1

# Gradle Properties.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=true

# Dependencies are managed at gradle/libs.versions.toml
modmenu_version=7.2.1
File renamed without changes
55 changes: 36 additions & 19 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,54 @@
{
"schemaVersion": 1,
"id": "${mod_id}",
"id": "kirislib",
"version": "${version}",
"name": "${mod_name}",
"description": "${mod_description}",
"authors": [
"${mod_author}"
],
"contact": {
"homepage": "${mod_homepage}",
"issues": "${mod_issue_tracker}",
"sources": "${mod_source}"
},
"license": "${mod_license_id}",
"icon": "assets/${mod_id}/icon.png",
"name": "Kiri's Lib",
"description": "A library mod containing things that all my mods use to save time duplicating code that I already have.",
"authors": [
{
"name": "KiriCattus",
"contact": {
"github": "KiriCattus",
"homepage": "https://tophatcat.dev"
}
}
],
"contact": {
"homepage": "https://modrinth.com/mod/kirislib",
"issues": "https://github.com/tophatcats-mods/kiris-lib/issues",
"sources": "https://github.com/tophatcats-mods/kiris-lib"
},
"license": "LGPL-2.1",
"icon": "assets/kirislib/logo.png",
"environment": "*",
"entrypoints": {
"main": [
"dev.tophatcat.kirislib.KirisLib"
]
},

"depends": {
"fabricloader": ">=${fabric_loader_version}",
"minecraft": "${minecraft_version}",
"fabricloader": ">=0.14.22",
"minecraft": ">=1.20",
"java": ">=17",
"fabric-api": "${fabric_api_version}"
"fabric-api": ">=0.86.1+1.20.1"
},

"suggests": {
"modmenu": "*"
},

"custom": {
"mc-publish": {
"loaders": ["fabric", "quilt"],
"curseforge": 280547,
"modrinth": "M6agkTxA"
},
"modmenu": {
"links": {
"modmenu.discord": "${mod_discord}",
"modmenu.modrinth": "${mod_homepage}",
"modmenu.curseforge": "${mod_cf}"
"modmenu.discord": "https://discord.tophatcat.dev",
"modmenu.modrinth": "https://modrinth.com/mod/kirislib",
"modmenu.curseforge": "https://www.curseforge.com/minecraft/mc-mods/kiris-lib"
},
"update_checker": true
}
Expand Down

0 comments on commit a76a987

Please sign in to comment.