Skip to content

Commit

Permalink
Add devbuild ID
Browse files Browse the repository at this point in the history
  • Loading branch information
JFronny committed Jul 24, 2022
1 parent 2230f1d commit 4777b9b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 89 deletions.
71 changes: 23 additions & 48 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,36 @@
name: Build
name: Java CI with Gradle

on:
push:
branches:
- master
branches: [ master-ame ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Clone repo
uses: actions/checkout@v2

- name: Set up JDK 17
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '17'
distribution: 'adopt'

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

- name: Set up Node JS
uses: actions/setup-node@v3
- name: Run Gradle
uses: gradle/gradle-build-action@v2
with:
node-version: latest

- name: Get current dev build number
id: dev-build
run: |
cd .github/devbuilds
npm install
npm run get_number
- name: Build
run: ./gradlew build -Pcommit=${{ github.sha }} -Pdevbuild=${{ steps.dev-build.outputs.number }}

- name: Webhook Failure
if: ${{ failure() }}
run: |
cd .github/devbuilds
npm start ${{ github.ref_name }} https://api.github.com/repos/MeteorDevelopment/meteor-client/compare/${{ github.event.before }}...${{ github.event.after }} false
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}


- name: Publish
run: ./gradlew publish -Pcommit=${{ github.sha }} -Pdevbuild=${{ steps.dev-build.outputs.number }}
env:
MAVEN_METEOR_ALIAS: ${{ secrets.MAVEN_METEOR_ALIAS }}
MAVEN_METEOR_TOKEN: ${{ secrets.MAVEN_METEOR_TOKEN }}

- name: Upload file & Discord webhook
run: |
cd .github/devbuilds
npm start ${{ github.ref_name }} https://api.github.com/repos/MeteorDevelopment/meteor-client/compare/${{ github.event.before }}...${{ github.event.after }} true
env:
SERVER_TOKEN: ${{ secrets.SERVER_TOKEN }}
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
gradle-version: current
arguments: build -Pcommit=${{ github.sha }} -Pdevbuild=${{ steps.dev-build.outputs.number }}
- name: Upload build artifacts
uses: actions/upload-artifact@v1
with:
name: build-artifacts
path: build/libs
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest-1.18"
prerelease: false
title: "1.18 Build"
files: |
./build/libs/*.jar
36 changes: 0 additions & 36 deletions .github/workflows/gradle.yml

This file was deleted.

8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
version = project.mod_version + (project.hasProperty("devbuild") ? ("-" + project.findProperty("devbuild")) : "")
group = project.maven_group

repositories {
Expand Down Expand Up @@ -80,7 +80,9 @@ shadowJar {

processResources {
filesMatching("fabric.mod.json") {
expand "version": project.version
expand "version": project.version,
"devbuild": project.findProperty("devbuild") ?: "",
"commit": project.findProperty("commit") ?: ""
}
}

Expand Down Expand Up @@ -116,7 +118,7 @@ publishing {
publications {
java(MavenPublication) {
artifactId = "meteor-client"
version = project.mod_version
version = project.hasProperty("devbuild") ? (project.mod_version + "-SNAPSHOT") : project.mod_version

artifact(remapJar) {
builtBy remapJar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class MeteorClient implements ClientModInitializer {
public static final String MOD_ID = "meteor-client";
public static final ModMetadata MOD_META = FabricLoader.getInstance().getModContainer(MOD_ID).get().getMetadata();
public final static Version VERSION;
public final static String DEV_BUILD = "";
public final static String DEV_BUILD;
public static MeteorAddon ADDON;

public static MinecraftClient mc;
Expand All @@ -56,6 +56,7 @@ public class MeteorClient implements ClientModInitializer {
if (versionString.contains("-")) versionString = versionString.split("-")[0];

VERSION = new Version(versionString);
DEV_BUILD = MOD_META.getCustomValue(MeteorClient.MOD_ID + ":devbuild").getAsString();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ private void onAddStackTrace(StringBuilder sb, CallbackInfo info) {
sb.append("-- Meteor Client --\n");
sb.append("Version: ").append(MeteorClient.VERSION).append("\n");

if (!MeteorClient.DEV_BUILD.isEmpty()) {
sb.append("Dev Build: ").append(MeteorClient.DEV_BUILD).append("\n");
}

for (Category category : Modules.loopCategories()) {
List<Module> modules = Modules.get().getGroup(category);
boolean active = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void init() {
StandardLib.init(ss);

// General
ss.set("version", MeteorClient.VERSION != null ? MeteorClient.VERSION.toString() : "");
ss.set("version", MeteorClient.VERSION != null ? (MeteorClient.DEV_BUILD.isEmpty() ? MeteorClient.VERSION.toString() : MeteorClient.VERSION + " " + MeteorClient.DEV_BUILD) : "");
ss.set("mc_version", SharedConstants.getGameVersion().getName());
ss.set("fps", () -> Value.number(MinecraftClientAccessor.getFps()));
ss.set("ping", MeteorStarscript::ping);
Expand Down

0 comments on commit 4777b9b

Please sign in to comment.