Update ci and versioning

This commit is contained in:
UnfamiliarLegacy 2024-06-23 20:38:03 +02:00
parent 8d495347ba
commit d951f1cbad
6 changed files with 101 additions and 45 deletions

View File

@ -17,17 +17,17 @@ jobs:
steps:
- name: Checkout G-Earth
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Checkout G-Wasm
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: sirjonasxx/G-Wasm
path: gwasm
ref: minimal
- name: Set up JDK 8
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: '8'
java-package: jdk+fx
@ -38,52 +38,33 @@ jobs:
run: mvn -B install
- name: Build G-Earth
run: mvn -B package
- name: Zip Build/Mac
run: |
cd ${{ github.workspace }}/Build/Mac/
zip -r ../../build-mac.zip *
- name: Zip Build/Linux
run: |
cd ${{ github.workspace }}/Build/Linux/
zip -r ../../build-linux.zip *
- name: Zip Build/Windows_32bit
run: |
cd ${{ github.workspace }}/Build/Windows_32bit/
zip -r ../../build-win32.zip *
- name: Zip Build/Windows_64bit
run: |
cd ${{ github.workspace }}/Build/Windows_64bit/
zip -r ../../build-win64.zip *
mvn -B package -Drepository=${GITHUB_REPOSITORY}
- name: Upload Mac OSX
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Mac OSX
path: build-mac.zip
path: Build/Mac/*
retention-days: 7
- name: Upload Linux
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Linux
path: build-linux.zip
path: Build/Linux/*
retention-days: 7
- name: Upload Windows x32
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Windows x32
path: build-win32.zip
path: Build/Windows_32bit/*
retention-days: 7
- name: Upload Windows x64
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Windows x64
path: build-win64.zip
path: Build/Windows_64bit/*
retention-days: 7

View File

@ -17,11 +17,27 @@
<parent>
<groupId>G-Earth</groupId>
<artifactId>G-Earth-Parent</artifactId>
<version>1.5.3</version>
<version>${revision}</version>
</parent>
<build>
<finalName>G-Earth</finalName>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/build.properties</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/build.properties</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>

View File

@ -19,12 +19,18 @@ import javafx.scene.control.Alert;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Properties;
public class GEarth extends Application {
private static final Logger logger = LoggerFactory.getLogger(GEarth.class);
public static GEarth main;
public static String version = "1.5.3";
public static String gitApi = "https://api.github.com/repos/sirjonasxx/G-Earth/releases/latest";
public static String version;
public static String repository;
public static ObservableObject<Theme> observableTheme;
private Stage stage;
@ -36,6 +42,19 @@ public class GEarth extends Application {
ThemeFactory.themeForTitle(Cacher.getCacheContents().getString("theme")) :
ThemeFactory.getDefaultTheme()
);
// Load build.properties
try {
final Properties buildProperties = new Properties();
buildProperties.load(GEarth.class.getResourceAsStream("/build.properties"));
version = buildProperties.getProperty("build.version");
repository = buildProperties.getProperty("build.github");
logger.info("Starting G-Earth {} from repository {}", version, repository);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override

View File

@ -8,32 +8,35 @@ import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Hyperlink;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.Region;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import org.apache.commons.io.IOUtils;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import static gearth.GEarth.gitApi;
import static gearth.GEarth.version;
public class UpdateChecker {
private static final Logger logger = LoggerFactory.getLogger(UpdateChecker.class);
public static void checkForUpdates() {
final String currentVersion = GEarth.version;
final String latestReleaseApi = String.format("https://api.github.com/repos/%s/releases/latest", GEarth.repository);
final String latestRelease = String.format("https://github.com/%s/releases/latest", GEarth.repository);
new Thread(() -> {
try {
JSONObject object = new JSONObject(IOUtils.toString(
new URL(gitApi).openStream(), StandardCharsets.UTF_8));
new URL(latestReleaseApi).openStream(), StandardCharsets.UTF_8));
String gitv = (String)object.get("tag_name");
if (new ComparableVersion(version).compareTo(new ComparableVersion(gitv)) < 0) {
if (new ComparableVersion(currentVersion).compareTo(new ComparableVersion(gitv)) < 0) {
Platform.runLater(() -> {
String body = (String)object.get("body");
boolean isForcedUpdate = body.contains("(!)");
@ -42,7 +45,7 @@ public class UpdateChecker {
FlowPane fp = new FlowPane();
Label lbl = new Label(LanguageBundle.get("alert.outdated.content.newversion") + " ("+gitv+")" + System.lineSeparator()+ System.lineSeparator() + LanguageBundle.get("alert.outdated.content.update") + ":");
Hyperlink link = new Hyperlink("https://github.com/sirjonasxx/G-Earth/releases");
Hyperlink link = new Hyperlink(latestRelease);
fp.getChildren().addAll( lbl, link);
link.setOnAction(event -> {
GEarth.main.getHostServices().showDocument(link.getText());
@ -52,7 +55,12 @@ public class UpdateChecker {
WebView webView = new WebView();
webView.getEngine().loadContent(String.format("<html>%s (%s)<br><br>%s:<br><a href=\"https://github.com/sirjonasxx/G-Earth/releases\">https://github.com/sirjonasxx/G-Earth/releases</a></html>", LanguageBundle.get("alert.outdated.content.newversion"), gitv, LanguageBundle.get("alert.outdated.content.update")));
webView.getEngine().loadContent(String.format("<html>%s (%s)<br><br>%s:<br><a href=\"%s\">%s</a></html>",
LanguageBundle.get("alert.outdated.content.newversion"),
gitv,
LanguageBundle.get("alert.outdated.content.update"),
latestRelease,
latestRelease));
webView.setPrefSize(500, 200);
alert.setResizable(false);
@ -71,7 +79,7 @@ public class UpdateChecker {
}
} catch (IOException e) {
// e.printStackTrace();
logger.error("Failed to check for updates", e);
}
}).start();
}

View File

@ -0,0 +1,2 @@
build.version=${project.version}
build.github=${project.repository}

32
pom.xml
View File

@ -7,7 +7,12 @@
<groupId>G-Earth</groupId>
<artifactId>G-Earth-Parent</artifactId>
<packaging>pom</packaging>
<version>1.5.3</version>
<version>${revision}</version>
<properties>
<revision>1.5.4-beta-1</revision>
<repository>sirjonasxx/G-Earth</repository>
</properties>
<name>G-Earth-Parent</name>
<url>https://github.com/sirjonasxx/G-Earth</url>
@ -20,6 +25,31 @@
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.1.0</version>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
</configuration>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>