Skip to content

Commit d5f320e

Browse files
committed
New build workflow
1 parent 0fc01ed commit d5f320e

5 files changed

Lines changed: 121 additions & 33 deletions

File tree

.github/workflows/build.yml

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,58 @@ on: [ push, pull_request ]
55
jobs:
66
build:
77
runs-on: ubuntu-latest
8-
strategy:
9-
matrix:
10-
java: [ 11, 17 ]
11-
fail-fast: true
128
steps:
139
- name: Checkout
1410
uses: actions/checkout@v3.0.0
15-
- name: Set up JDK ${{ matrix.java }}
11+
- name: Set up JDK
1612
uses: actions/setup-java@v3.0.0
1713
with:
1814
distribution: adopt
19-
java-version: ${{ matrix.java }}
15+
java-version: 11
2016
- name: Build LimboAuth
2117
run: ./gradlew build
2218
- name: Upload LimboAuth
2319
uses: actions/upload-artifact@v3.0.0
2420
with:
25-
name: LimboAuth Built On ${{ matrix.java }} JDK
21+
name: LimboAuth
2622
path: "build/libs/limboauth*.jar"
2723
- uses: dev-drprasad/delete-tag-and-release@v0.2.0
2824
if: ${{ github.event_name == 'push' }}
2925
with:
3026
delete_release: true
31-
tag_name: dev-build-jdk-${{ matrix.java }}
27+
tag_name: dev-build
3228
env:
3329
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
- name: Find git version
31+
id: git-version
32+
run: echo "id=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
33+
- name: Find correct JAR
34+
if: ${{ github.event_name == 'push' }}
35+
id: find-jar
36+
run: |
37+
output="$(find build/libs/ ! -name "*-javadoc.jar" ! -name "*-sources.jar" -type f -printf "%f\n")"
38+
echo "::set-output name=jarname::$output"
3439
- name: Release the build
3540
if: ${{ github.event_name == 'push' }}
3641
uses: ncipollo/release-action@v1
3742
with:
38-
artifacts: "build/libs/limboauth*.jar"
43+
artifacts: build/libs/${{ steps.find-jar.outputs.jarname }}
3944
body: ${{ join(github.event.commits.*.message, '\n') }}
4045
prerelease: true
41-
name: JDK ${{ matrix.java }} Dev-build
42-
tag: dev-build-jdk-${{ matrix.java }}
46+
name: Dev-build ${{ steps.git-version.outputs.id }}
47+
tag: dev-build
48+
- name: Upload to Modrinth
49+
if: ${{ github.event_name == 'push' }}
50+
uses: RubixDev/modrinth-upload@v1.0.0
51+
with:
52+
token: ${{ secrets.MODRINTH_TOKEN }}
53+
file_path: build/libs/${{ steps.find-jar.outputs.jarname }}
54+
name: Dev-build ${{ steps.git-version.outputs.id }}
55+
version: ${{ steps.git-version.outputs.id }}
56+
changelog: ${{ join(github.event.commits.*.message, '\n') }}
57+
relations: TZOteSf2:required
58+
game_versions: 1.7.2
59+
release_type: beta
60+
loaders: velocity
61+
featured: false
62+
project_id: 4iChqdl8

.github/workflows/release.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Java CI with Gradle
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v3.0.0
13+
- name: Set up JDK
14+
uses: actions/setup-java@v3.0.0
15+
with:
16+
distribution: adopt
17+
java-version: 11
18+
- name: Build LimboAuth
19+
run: ./gradlew build
20+
- name: Upload LimboAuth
21+
uses: actions/upload-artifact@v3.0.0
22+
with:
23+
name: LimboAuth
24+
path: "build/libs/limboauth*.jar"
25+
- name: Find correct JAR
26+
id: find-jar
27+
run: |
28+
output="$(find build/libs/ ! -name "*-javadoc.jar" ! -name "*-sources.jar" -type f -printf "%f\n")"
29+
echo "::set-output name=jarname::$output"
30+
- name: Upload to the GitHub release
31+
uses: actions/upload-release-asset@v1
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
with:
35+
upload_url: ${{ github.event.release.upload_url }}
36+
asset_path: build/libs/${{ steps.find-jar.outputs.jarname }}
37+
asset_name: ${{ steps.find-jar.outputs.jarname }}
38+
asset_content_type: application/java-archive
39+
- name: Upload to Modrinth
40+
uses: RubixDev/modrinth-upload@v1.0.0
41+
with:
42+
token: ${{ secrets.MODRINTH_TOKEN }}
43+
file_path: build/libs/${{ steps.find-jar.outputs.jarname }}
44+
name: Release ${{ github.event.release.tag_name }}
45+
version: ${{ github.event.release.tag_name }}
46+
changelog: ${{ github.event.release.body }}
47+
relations: TZOteSf2:required
48+
game_versions: 1.7.2
49+
release_type: release
50+
loaders: velocity
51+
featured: true
52+
project_id: 4iChqdl8

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.5
1+
1.1.6

build.gradle

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,30 @@ artifacts {
195195
archives(sourcesJar)
196196
}
197197

198-
sourceSets.main.getJava().srcDir(getTasks().register("generateTemplates", Copy) { task ->
199-
task.getInputs().properties("version": getVersion())
200-
201-
task.from(file("src/main/templates"))
202-
.into(getLayout().getBuildDirectory().dir("generated/sources/templates"))
203-
.expand("version": getVersion())
204-
}.map {
205-
it.getOutputs()
206-
})
198+
sourceSets.main.getJava().srcDir(
199+
getTasks().register("generateTemplates", Copy) {
200+
task -> {
201+
String version = getVersion().contains("-") ? "${getVersion()} (git-${getCurrentShortRevision()})" : getVersion()
202+
task.getInputs().properties("version": version)
203+
task.from(file("src/main/templates")).into(getLayout().getBuildDirectory().dir("generated/sources/templates"))
204+
task.expand("version": version)
205+
}
206+
}.map {
207+
it.getOutputs()
208+
}
209+
)
207210

208211
assemble.dependsOn(shadowJar)
212+
213+
String getCurrentShortRevision() {
214+
OutputStream outputStream = new ByteArrayOutputStream()
215+
exec {
216+
if (System.getProperty("os.name").toLowerCase().contains("win")) {
217+
commandLine("cmd", "/c", "git rev-parse --short HEAD")
218+
} else {
219+
commandLine("bash", "-c", "git rev-parse --short HEAD")
220+
}
221+
222+
setStandardOutput(outputStream)
223+
}
224+
}

src/main/java/net/elytrium/limboauth/Settings.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,18 @@ public static class WORLD_COORDS {
245245
public int Z = 0;
246246
}
247247

248+
@Create
249+
public MAIN.AUTH_COORDS AUTH_COORDS;
250+
251+
public static class AUTH_COORDS {
252+
253+
public double X = 0;
254+
public double Y = 0;
255+
public double Z = 0;
256+
public double YAW = 0;
257+
public double PITCH = 0;
258+
}
259+
248260
@Create
249261
public Settings.MAIN.CRACKED_TITLE_SETTINGS CRACKED_TITLE_SETTINGS;
250262

@@ -398,18 +410,6 @@ public static class STRINGS {
398410

399411
public String MOD_SESSION_EXPIRED = "{PRFX} Your session has expired, log in again.";
400412
}
401-
402-
@Create
403-
public MAIN.AUTH_COORDS AUTH_COORDS;
404-
405-
public static class AUTH_COORDS {
406-
407-
public double X = 0;
408-
public double Y = 0;
409-
public double Z = 0;
410-
public double YAW = 0;
411-
public double PITCH = 0;
412-
}
413413
}
414414

415415
@Create

0 commit comments

Comments
 (0)