Skip to content

Commit d69db44

Browse files
committed
Auto mod publishing?
1 parent a71ef39 commit d69db44

File tree

5 files changed

+109
-2
lines changed

5 files changed

+109
-2
lines changed

.github/workflows/release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: 'Release'
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Set up JDK 17
14+
uses: actions/setup-java@v1
15+
with:
16+
java-version: 17
17+
- name: Grant execute permission for gradlew
18+
run: chmod +x gradlew
19+
- name: Generate assets
20+
run: ./gradlew runData --no-daemon
21+
- name: Build with Gradle
22+
env:
23+
MOD_VERSION: ${{ github.event.release.tag_name }}
24+
run: ./gradlew build
25+
- name: Upload Release Artifact
26+
uses: actions/upload-release-asset@v1.0.1
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
with:
30+
upload_url: ${{ github.event.release.upload_url }}
31+
asset_path: ./build/libs/Modern-Dynamics-${{ github.event.release.tag_name }}.jar
32+
asset_name: moderndynamics-${{ github.event.release.tag_name }}.jar
33+
asset_content_type: application/zip
34+
- name: Upload to Curseforge
35+
env:
36+
MI_VERSION: ${{ github.event.release.tag_name }}
37+
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
38+
run: ./gradlew curseforge552758
39+
- name: Upload to Modrinth
40+
env:
41+
MI_VERSION: ${{ github.event.release.tag_name }}
42+
MODRINTH_API_KEY: ${{ secrets.MODRINTH_API_KEY }}
43+
run: ./gradlew publishModrinth

build.gradle

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@ plugins {
22
id 'fabric-loom' version '0.12-SNAPSHOT'
33
id 'maven-publish'
44
id 'com.diffplug.spotless' version '5.14.0'
5+
id 'com.matthewprenger.cursegradle' version '1.4.0'
6+
id "com.modrinth.minotaur" version "1.2.1"
57
}
68

79
sourceCompatibility = JavaVersion.VERSION_17
810
targetCompatibility = JavaVersion.VERSION_17
911

1012
archivesBaseName = project.archives_base_name
11-
version = project.mod_version
13+
version = System.getenv("MOD_VERSION")
14+
? System.getenv("MOD_VERSION")
15+
: "local"
1216
group = project.maven_group
1317

1418
repositories {
@@ -205,3 +209,60 @@ final class JsonOrderStep {
205209
private final int formatVersion = 1;
206210
}
207211
}
212+
213+
def releaseChannel = "release"
214+
def changelog = "Please visit our github repository for a changelog: https://github.com/Technici4n/Modern-Dynamics/releases."
215+
if (version.toLowerCase().contains("alpha")) {
216+
releaseChannel = "alpha"
217+
changelog = "THIS IS AN ALPHA RELEASE, MAKE A BACKUP BEFORE INSTALLING AND FREQUENTLY WHILE PLAYING, AND PLEASE REPORT ANY ISSUE YOU MAY FIND ON OUR ISSUE TRACKER.\n\n" + changelog
218+
} else if (version.toLowerCase().contains("beta")) {
219+
releaseChannel = "beta"
220+
changelog = "This is a beta release. It is expected to be mostly stable, but in any case please report any issue you may find.\n\n" + changelog
221+
}
222+
223+
// Publishing
224+
if (System.getenv("CURSEFORGE_API_KEY") && !version.endsWith("-SNAPSHOT")) {
225+
curseforge {
226+
apiKey = System.getenv().get("CURSEFORGE_API_KEY")
227+
project {
228+
id = project.curseforge_project
229+
releaseType = releaseChannel
230+
changelogType = "markdown"
231+
delegate.changelog = changelog
232+
233+
addGameVersion "1.18.2"
234+
addGameVersion "Fabric"
235+
addGameVersion "Java 17"
236+
237+
relations {
238+
requiredDependency "fabric-api"
239+
}
240+
mainArtifact(remapJar.archiveFile) {
241+
displayName = "Modern Dynamics v${version}"
242+
}
243+
}
244+
options {
245+
forgeGradleIntegration = false
246+
}
247+
afterEvaluate {
248+
tasks.getByName("curseforge${project.curseforge_project}").dependsOn remapJar
249+
}
250+
}
251+
}
252+
253+
import com.modrinth.minotaur.TaskModrinthUpload
254+
255+
task publishModrinth (type: TaskModrinthUpload){
256+
onlyIf {
257+
System.getenv("MODRINTH_API_KEY") && !version.endsWith("-SNAPSHOT")
258+
}
259+
token = System.getenv("MODRINTH_API_KEY")
260+
projectId = project.modrinth_project
261+
versionNumber = version
262+
versionName = "Modern Dynamics v${version}"
263+
delegate.changelog = changelog
264+
versionType = releaseChannel.toUpperCase()
265+
uploadFile = remapJar.archiveFile
266+
addGameVersion "1.18.2"
267+
addLoader "fabric"
268+
}

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ minecraft_version=1.18.2
1313
loader_version=0.13.3
1414

1515
# Mod Properties
16-
mod_version = 0.1.2-alpha
1716
maven_group = dev.technici4n
1817
archives_base_name = moderndynamics
18+
curseforge_project = 552758
19+
modrinth_project = fMpvLrnF
1920

2021
# Dependencies
2122
fabric_version=0.51.1+1.18.2

settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ pluginManagement {
77
gradlePluginPortal()
88
}
99
}
10+
11+
rootProject.name = "Modern-Dynamics"
6.98 KB
Loading

0 commit comments

Comments
 (0)