Skip to content

Commit

Permalink
Test commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Slotterleet committed Apr 14, 2024
1 parent f4a8e95 commit 72432e2
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 25 deletions.
28 changes: 16 additions & 12 deletions .github/workflows/commitTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@ jobs:
- name: Make a tag name
if: github.ref == 'refs/heads/master'
run: |
echo "::set-output name=tag::$(date +%Y%m%d%H%M%S)"
echo "::set-output name=tag::$(jq '.version' mod.json -r)"
id: tag_make
- name: Create blank release
# - name: Create blank release
# if: github.ref == 'refs/heads/master'
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run:
# gh release create -t "FOS OST" "${{ steps.tag_make.outputs.tag }}"
- name: Check mod version
if: github.ref == 'refs/heads/master'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run:
gh release create -t "FOS OST" "${{ steps.tag_make.outputs.tag }}"
- name: Add jar into release
uses: softprops/action-gh-release@v1
if: github.ref == 'refs/heads/master'
with:
tag_name: ${{ steps.tag_make.outputs.tag }}
files: build/libs/${{ github.event.repository.name }}.jar
run: |
echo "${{ steps.tag_make.outputs.tag }}"
# - name: Add jar into release
# uses: softprops/action-gh-release@v1
# if: github.ref == 'refs/heads/master'
# with:
# tag_name: ${{ steps.tag_make.outputs.tag }}
# files: build/libs/${{ github.event.repository.name }}.jar
2 changes: 2 additions & 0 deletions assets/bundles/bundle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fosost.updateavailable.title = Update Available
fosost.updateavailable.description = An update for FOS OST was found. Download it now?
2 changes: 2 additions & 0 deletions assets/bundles/bundle_ru.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fosost.updateavailable.title = Доступно обновление
fosost.updateavailable.description = Найдено обновление для FOS OST. Загрузить его сейчас?
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jar{
}

from(rootDir){
include "mod.hjson"
include "mod.json"
include "icon.png"
}

Expand Down
12 changes: 0 additions & 12 deletions mod.hjson

This file was deleted.

16 changes: 16 additions & 0 deletions mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "fosost",
"displayName": "Fictional Octo System OST",
"author": "Team Oct",
"main": "fosost.FOSOSTMod",
"repo": "TeamOct/FOS-OST",
"description": "Original soundtrack (made by Saigo no-nozomi) for a Mindustry mod Fictional Octo System.",
"version": "1.0.1",
"minGameVersion": 140.3,
"java": true,
"hidden": true,
"hideBrowser": true,
"dependencies": [
"fos"
]
}
36 changes: 36 additions & 0 deletions src/AutoUpdater.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import arc.util.*;
import arc.util.serialization.Jval;
import fosost.FOSOSTMod;

import static mindustry.Vars.*;
import static mindustry.mod.Mods.LoadedMod;

// stolen from ApsZoldat/MindustryMappingUtilities, thanks
public class AutoUpdater {
public AutoUpdater() {
LoadedMod mod = mods.getMod(FOSOSTMod.class);
Http.get(ghApi + "/repos/" + mod.getRepo() + "/releases", result -> {
var json = Jval.read(result.getResultAsString());
Jval.JsonArray releases = json.asArray();

if(releases.size == 0) return;

String latest = releases.first().getString("tag_name");
String current = mod.meta.version;
float latestFloat = Float.parseFloat(latest.replace("v", ""));
float currentFloat = Float.parseFloat(current.replace("v", ""));
if(currentFloat >= latestFloat) {
Log.info("[FOS OST] Mod is on the latest version.");
return;
}

ui.showConfirm("@fosost.updateavailable.title", "@fosost.updateavailable.description", () -> {
ui.mods.githubImportMod(mod.getRepo(), true);
});
}, this::error);
}

void error(Throwable e) {
Log.err("[FOS OST] Failed to check for updates!\n@", e);
}
}

0 comments on commit 72432e2

Please sign in to comment.