Skip to content

Commit

Permalink
Feature/#141 ci build (#142)
Browse files Browse the repository at this point in the history
CI build releases
  • Loading branch information
1-alex98 authored Jan 16, 2020
1 parent 383b67b commit fc31598
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 11 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build and relase

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: Auto generated release
draft: true
prerelease: false
- name: Build win zip
run: ./gradlew distZip -PprojVersion=${GITHUB_REF##*/} -PjavafxPlatform=win
- name: Build linux tar
run: ./gradlew distTar -PprojVersion=${GITHUB_REF##*/} -PjavafxPlatform=linux
- name: Build mac tar
run: ./gradlew distTar -PprojVersion=${GITHUB_REF##*/} -PjavafxPlatform=mac && ls ./build/distributions
- name: Upload Assets to Release with a wildcard
uses: axel1200/release-asset-action@v1
with:
pattern: "build/distributions/*"
github-token: ${{ secrets.GITHUB_TOKEN }}
release-url: ${{ steps.create_release.outputs.upload_url }}
File renamed without changes.
24 changes: 24 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 33 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ repositories {
}
}

if (javafxPlatform == "unspecified") {
switch (org.gradle.internal.os.OperatingSystem.current()) {
case org.gradle.internal.os.OperatingSystem.LINUX:
project.ext.javafxPlatform = "linux"
break
case org.gradle.internal.os.OperatingSystem.MAC_OS:
project.ext.javafxPlatform = "mac"
break
case org.gradle.internal.os.OperatingSystem.WINDOWS:
project.ext.javafxPlatform = "win"
break
}
}
println "Platform is: ${javafxPlatform}"

dependencies {

Expand All @@ -36,39 +50,52 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.0'

compile("org.openjfx:javafx-base:${javafxVersion}:${javafxPlatform}")
compile("org.openjfx:javafx-controls:${javafxVersion}:${javafxPlatform}")
compile("org.openjfx:javafx-graphics:${javafxVersion}:${javafxPlatform}")
compile("org.openjfx:javafx-fxml:${javafxVersion}:${javafxPlatform}")
}

project.version = project.projVersion.replace('v','')

distZip {
archiveName "${project.name}-v${project.version}-${javafxPlatform}.zip"
}

distTar {
archiveName "${project.name}-v${project.version}-${javafxPlatform}.tar"
}

test {
useJUnitPlatform()
}

javafx {
version = "11"
version = "${javafxVersion}"
modules = ['javafx.base', 'javafx.controls', 'javafx.fxml', 'javafx.graphics']
/**
* https://github.com/openjfx/javafx-gradle-plugin
* JavaFX modules require native binaries for each platform. The plugin only includes binaries for the platform
* running the build. By declaring the dependency configuration compileOnly, the native binaries will not be
* included. You will need to provide those separately during deployment for each target platform.
*/
// configuration = 'compileOnly'
configuration = 'compileOnly'
}

mainClassName = 'com.treasure.hunt.JavaFXLauncher'
mainClassName = 'com.treasure.hunt.Main'

group = 'com.treasure'
version = '0.8.2'
description = 'hunt'
sourceCompatibility = '11'

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}


jar {
manifest {
attributes 'Main-Class': 'com.treasure.hunt.JavaFXLauncher'
attributes 'Main-Class': 'com.treasure.hunt.Main',
'Implementation-Version': project.version
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
projVersion=snapshot
javafxPlatform=unspecified
javafxVersion=11
10 changes: 7 additions & 3 deletions src/main/java/com/treasure/hunt/service/io/FileService.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,21 @@ public void loadGameManager() {
}

private boolean correctVersion(DataWithVersion dataWithVersion) {
boolean divergentVersion = dataWithVersion.getVersion() != null && !dataWithVersion.getVersion().equals(GameManager.class.getPackage().getImplementationVersion());
boolean loadingDevelopmentVersion = dataWithVersion.getVersion() == null && GameManager.class.getPackage().getImplementationVersion() != null;
boolean divergentVersion = !isDevelopmentVersion(dataWithVersion.getVersion()) && !dataWithVersion.getVersion().equals(GameManager.class.getPackage().getImplementationVersion());
boolean loadingDevelopmentVersion = isDevelopmentVersion(dataWithVersion.getVersion()) && isDevelopmentVersion(GameManager.class.getPackage().getImplementationVersion());

return divergentVersion || loadingDevelopmentVersion;
}

private boolean isDevelopmentVersion(String version) {
return version == null || version.equalsIgnoreCase("snapshot") || version.equalsIgnoreCase("undefined");
}

private boolean askUserWhetherToLoadWrongVersion(String oldVersion) {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setTitle("Proceed loading wrong version");
alert.setHeaderText("The file was record with a different version than your program is running. Loading it might cause unexpected behaviour.");
alert.setContentText("Version of file was " + (oldVersion == null ? "development" : oldVersion));
alert.setContentText("Version of file was " + (oldVersion));

Optional<ButtonType> option = alert.showAndWait();

Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/treasure/hunt/view/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ public class MainController {
public HBox stepViewNavigator;

@FXML
public NavigationController stepViewNavigatorController;
private NavigationController stepViewNavigatorController;

@FXML
private Label versionLabel;

@FXML
private WidgetBarController leftWidgetBarController;

@FXML
private WidgetBarController rightWidgetBarController;

Expand All @@ -82,6 +86,8 @@ public class MainController {

public void initialize() {
canvasController.setGameManager(gameManager);
String implementationVersion = getClass().getPackage().getImplementationVersion();
versionLabel.setText(implementationVersion == null ? "snapshot" : "v" + implementationVersion);
setListStringConverters();
fillLists();
addPromptBindings();
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/layout/main.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
<children>
<HBox alignment="CENTER_LEFT" maxWidth="60000.0" spacing="5.0" HBox.hgrow="ALWAYS">
<children>
<Label text="TreasureHunt"/>
<Label text="TreasureHunt: "/>
<Label fx:id="versionLabel"/>
</children>
</HBox>
<HBox alignment="CENTER_RIGHT" maxWidth="60000.0" spacing="5.0" HBox.hgrow="ALWAYS">
Expand Down

0 comments on commit fc31598

Please sign in to comment.