Skip to content

Commit a1b66ca

Browse files
committed
Auto modrinth publishing
1 parent 2da49fc commit a1b66ca

File tree

4 files changed

+88
-23
lines changed

4 files changed

+88
-23
lines changed

.github/workflows/build.yml

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,73 @@
44
# against bad commits.
55

66
name: build
7-
on: [pull_request, push]
7+
8+
on:
9+
release:
10+
types:
11+
- published
12+
push:
13+
branches:
14+
- '**'
15+
tags-ignore:
16+
- '**'
17+
pull_request:
18+
workflow_dispatch:
19+
20+
permissions:
21+
id-token: write
22+
attestations: write
23+
contents: write
824

925
jobs:
10-
build:
11-
strategy:
12-
matrix:
13-
# Use these Java versions
14-
java: [
15-
17, # Current Java LTS & minimum supported by Minecraft
16-
21, # Current Java LTS
17-
]
18-
runs-on: ubuntu-22.04
26+
release:
27+
runs-on: ubuntu-latest
1928
steps:
20-
- name: checkout repository
29+
- name: Checkout
2130
uses: actions/checkout@v4
22-
- name: validate gradle wrapper
23-
uses: gradle/wrapper-validation-action@v2
24-
- name: setup jdk ${{ matrix.java }}
31+
32+
- name: JDK Setup
2533
uses: actions/setup-java@v4
2634
with:
27-
java-version: ${{ matrix.java }}
28-
distribution: 'microsoft'
29-
- name: make gradle wrapper executable
35+
java-version: 21
36+
distribution: 'temurin'
37+
38+
- name: Gradle Setup
39+
uses: gradle/actions/setup-gradle@v4
40+
with:
41+
validate-wrappers: true
42+
43+
- name: Enable gradlew execution
3044
run: chmod +x ./gradlew
31-
- name: build
45+
46+
- name: Gradle Build
3247
run: ./gradlew build
33-
- name: capture build artifacts
34-
if: ${{ matrix.java == '21' }} # Only upload artifacts built from latest java
48+
49+
- name: Attest Build Provenance
50+
uses: actions/attest-build-provenance@v2
51+
with:
52+
subject-path: '**/build/libs/*.jar, !**/build/libs/*-sources.jar'
53+
54+
- name: Upload Artifacts
3555
uses: actions/upload-artifact@v4
3656
with:
3757
name: Artifacts
38-
path: build/libs/
58+
path: |
59+
**/build/libs/*.jar
60+
!**/build/libs/*-sources.jar
61+
62+
- name: Github Publish
63+
if: github.event_name == 'release' && github.event.action == 'published'
64+
uses: AButler/upload-release-assets@v2.0
65+
with:
66+
files: '**/build/libs/*.jar;!**/build/libs/*-sources.jar'
67+
repo-token: ${{ secrets.GITHUB_TOKEN }}
68+
69+
- name: Modrinth Publish
70+
env:
71+
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
72+
CHANGELOG: ${{ github.event.release.body }}
73+
if: ${{ github.event_name == 'release' && github.event.action == 'published' && env.MODRINTH_TOKEN != '' }}
74+
run: |
75+
./gradlew --no-configuration-cache modrinth
76+
./gradlew --no-configuration-cache modrinthSyncBody

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Shield Surf
2+
3+
Adds new shield enchantments to Minecraft:
4+
- Shield Surf : Allows the user to ride the shield, somewhat like a surfboard
5+
- Aegis : Shields with this enchantment with automatically block for you when they are in the inventory, but will be put on cooldown upon activation
6+
- Rapid : Using the shield does not slow you down
7+
- Expulsion : Casts out shields around the user
8+
- Orbit : Summons orbiting shields that block attacks
9+
- Rebound : Projectiles will ricochet and bounce in the direction they came from upon hitting the shield
10+
11+
Detailed descriptions of the enchantments can be viewed in the mod's language file or through an enchantment description mod.
12+
13+
This mod is configurable through gamerules. Install YACL for more client configuration options.

build.gradle.kts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import java.io.BufferedReader
22
import java.io.FileReader
3+
import org.gradle.jvm.tasks.Jar
34

45
plugins {
56
id("fabric-loom") version "1.13-SNAPSHOT"
@@ -107,7 +108,7 @@ tasks.register("autoVersionChangelog") {
107108
val changelog = File("changelog.md")
108109
val reader = BufferedReader(FileReader(changelog))
109110
val lines = reader.readLines().toMutableList()
110-
val title = "Laseredstone ${project.property("mod_version")}"
111+
val title = "Shield Surf ${project.property("mod_version")}"
111112
lines[0] = title
112113
changelog.bufferedWriter().use { writer ->
113114
for (i in 0..<lines.size) {
@@ -157,4 +158,15 @@ tasks.jar {
157158
from("LICENSE") {
158159
rename { "${it}_${base.archivesName}"}
159160
}
161+
}
162+
163+
modrinth {
164+
token = providers.environmentVariable("MODRINTH_TOKEN")
165+
projectId = project.base.archivesName
166+
version = project.version
167+
uploadFile.set(tasks.named<Jar>("remapJar").get().archiveFile)
168+
gameVersions.addAll("${project.property("deps.compatibleVersions")}".split(", ").toList())
169+
loaders.addAll("${project.property("deps.compatibleLoaders")}".split(", ").toList())
170+
changelog = providers.environmentVariable("CHANGELOG")
171+
syncBodyFrom = "<!--DO NOT EDIT MANUALLY: synced from gh readme-->\n" + rootProject.file("README.md").readText()
160172
}

changelog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
Shield Surf 1.0.2
22
- Fix [#1](https://github.com/ekulxam/shield_surf/issues/1)
33
- Port to stonecutter (multiversion)
4-
- Port to 1.21.1 (closes [#3](https://github.com/ekulxam/shield_surf/issues/3))
4+
- Port to 1.21.1 (closes [#3](https://github.com/ekulxam/shield_surf/issues/3))
5+
- Cleanup code
6+
- Orbiting shields now rotate more smoothly

0 commit comments

Comments
 (0)