diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6a31101..6952870 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 \ No newline at end of file diff --git a/G-Earth/pom.xml b/G-Earth/pom.xml index 7e199a3..55cd329 100644 --- a/G-Earth/pom.xml +++ b/G-Earth/pom.xml @@ -17,11 +17,27 @@ G-Earth G-Earth-Parent - 1.5.3 + ${revision} G-Earth + + + ${basedir}/src/main/resources + true + + **/build.properties + + + + ${basedir}/src/main/resources + false + + **/build.properties + + + diff --git a/G-Earth/src/main/java/gearth/GEarth.java b/G-Earth/src/main/java/gearth/GEarth.java index abddbd1..ac5d84c 100644 --- a/G-Earth/src/main/java/gearth/GEarth.java +++ b/G-Earth/src/main/java/gearth/GEarth.java @@ -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 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 diff --git a/G-Earth/src/main/java/gearth/misc/UpdateChecker.java b/G-Earth/src/main/java/gearth/misc/UpdateChecker.java index ec001b8..3f891eb 100644 --- a/G-Earth/src/main/java/gearth/misc/UpdateChecker.java +++ b/G-Earth/src/main/java/gearth/misc/UpdateChecker.java @@ -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("%s (%s)

%s:
https://github.com/sirjonasxx/G-Earth/releases", LanguageBundle.get("alert.outdated.content.newversion"), gitv, LanguageBundle.get("alert.outdated.content.update"))); + webView.getEngine().loadContent(String.format("%s (%s)

%s:
%s", + 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(); } diff --git a/G-Earth/src/main/resources/build.properties b/G-Earth/src/main/resources/build.properties new file mode 100644 index 0000000..15dfe64 --- /dev/null +++ b/G-Earth/src/main/resources/build.properties @@ -0,0 +1,2 @@ +build.version=${project.version} +build.github=${project.repository} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 879fa5f..45e9b65 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,12 @@ G-Earth G-Earth-Parent pom - 1.5.3 + ${revision} + + + 1.5.4-beta-1 + sirjonasxx/G-Earth + G-Earth-Parent https://github.com/sirjonasxx/G-Earth @@ -20,6 +25,31 @@ + + org.codehaus.mojo + flatten-maven-plugin + 1.1.0 + + true + resolveCiFriendliesOnly + + + + flatten + process-resources + + flatten + + + + flatten.clean + clean + + clean + + + + org.apache.maven.plugins maven-compiler-plugin