Skip to content

Commit c429ab8

Browse files
committed
Add publishing Workflow
1 parent 1cb6e06 commit c429ab8

File tree

6 files changed

+159
-2
lines changed

6 files changed

+159
-2
lines changed

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
github: thedarkcolour
2+
patreon: thedarkcolour
3+
ko_fi: thedarkcolour

.github/ISSUE_TEMPLATE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Thank you for reporting!
2+
3+
For issues:
4+
* Try the latest version, it may have fixed the issue already.
5+
* If you crashed, please paste the crash log to [gist](https://gist.github.com/) and link it here.

.github/workflows/build.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build
2+
on:
3+
- pull_request
4+
- push
5+
6+
jobs:
7+
build:
8+
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v3
13+
- name: Validate Gradle wrapper
14+
uses: gradle/wrapper-validation-action@v1
15+
- name: Set up JDK 17
16+
uses: actions/setup-java@v3
17+
with:
18+
distribution: temurin
19+
java-version: 17
20+
- name: Use Gradle cache for faster builds
21+
uses: actions/cache@v3
22+
with:
23+
path: ~/.gradle/caches
24+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
25+
- name: Cleanup Gradle Cache
26+
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
27+
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
28+
run: |
29+
rm -f ~/.gradle/caches/modules-2/modules-2.lock
30+
rm -f ~/.gradle/caches/modules-2/gc.properties
31+
- name: Setup Gradle Wrapper Cache
32+
uses: actions/cache@v3
33+
with:
34+
path: ~/.gradle/wrapper
35+
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
36+
- name: Build
37+
run: ./gradlew build --max-workers 1
38+
- name: Upload artifacts
39+
uses: actions/upload-artifact@v3
40+
with:
41+
name: Forestry
42+
path: build/libs/

.github/workflows/publish.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Release for 1.20.1
2+
3+
on:
4+
push:
5+
branches: [ '1.20.1' ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
release:
10+
name: Publish release JAR for Gendustry
11+
runs-on: ubuntu-latest
12+
if: "startsWith(github.event.head_commit.message, '[Release]')"
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Java
18+
uses: actions/setup-java@v4
19+
with:
20+
distribution: 'microsoft'
21+
java-version: '17'
22+
23+
- name: Setup Gradle
24+
uses: gradle/actions/setup-gradle@v4
25+
26+
- name: Upload to CurseForge
27+
run: ./gradlew curseforge
28+
env:
29+
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
30+
31+
- name: Upload to Modrinth
32+
run: ./gradlew modrinth
33+
env:
34+
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}

build.gradle

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ plugins {
44
id "maven-publish"
55
id "org.parchmentmc.librarian.forgegradle" version "1.+"
66
id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.9"
7+
id('com.modrinth.minotaur') version '2.+'
8+
id('com.matthewprenger.cursegradle') version '1.4.0'
79
}
810

9-
version = gendustryVersion
1011
group = "thedarkcolour.gendustry"
12+
version = gendustryVersion
1113
base.archivesName = "gendustry-$minecraftVersion"
1214

1315
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
@@ -142,4 +144,72 @@ idea {
142144
downloadSources = true
143145
downloadJavadoc = true
144146
}
147+
}
148+
149+
if (System.getenv("CURSEFORGE_TOKEN")) {
150+
curseforge {
151+
apiKey = System.getenv("CURSEFORGE_TOKEN")
152+
153+
project {
154+
id = project.curseforgeId
155+
changelogType = "markdown"
156+
changelog = getChangelog(version)
157+
158+
releaseType = "release"
159+
160+
addGameVersion(project.minecraftVersion)
161+
addGameVersion("Forge")
162+
addGameVersion("Java 17")
163+
164+
mainArtifact(jar.archiveFile) {
165+
displayName = "Gendustry: Community Edition ${project.version}"
166+
relations {
167+
requiredDependency 'forestry-community-edition'
168+
}
169+
}
170+
}
171+
}
172+
}
173+
174+
modrinth {
175+
token = System.getenv("MODRINTH_TOKEN")
176+
projectId = project.modrinthId
177+
versionName = "Gendustry: Community Edition $version"
178+
versionNumber = version.toString()
179+
versionType = "release"
180+
gameVersions = [minecraftVersion]
181+
loaders = ["forge"]
182+
changelog = getChangelog(project.version)
183+
184+
uploadFile = jar
185+
186+
dependencies {
187+
required.project("forestry-community-edition")
188+
}
189+
}
190+
191+
static def getChangelog(Object version) {
192+
version = version.toString()
193+
194+
def file = new File('changelog.md')
195+
if (!file.exists()) {
196+
return "Changelog file not found"
197+
}
198+
199+
// Relies on the changelog block being "##blahblahblah_VERSION" where _ is a space
200+
def content = file.text.normalize().split("##.* ")
201+
202+
for (final def chunk in content) {
203+
if (chunk.isEmpty()) continue
204+
205+
def lineTerminatorIndex = chunk.findIndexOf { c -> c == '\n' || c == '\r' }
206+
def versionString = chunk.substring(0, lineTerminatorIndex)
207+
208+
if (versionString == version) {
209+
return "## Gendustry $version\n" + chunk.substring(lineTerminatorIndex + 1)
210+
}
211+
}
212+
213+
// Fallback in case this fails
214+
return "Gendustry Update ${version}"
145215
}

gradle.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
org.gradle.daemon=false
22
org.gradle.jvmargs=-Xmx3G
33

4+
curseforgeId=1179084
5+
modrinthId=2zkSGMyK
6+
47
# Gendustry
5-
gendustryVersion=1.0.0
8+
gendustryVersion=1.0.1
69

710
# Minecraft
811
minecraftVersion=1.20.1

0 commit comments

Comments
 (0)