Skip to content

Commit

Permalink
ci: Add Github Actions workflows & remove outdated templates (#36)
Browse files Browse the repository at this point in the history
* Delete .github directory

* Create build-and-test.yml

* Create create-release

* Change gradlew permissions

* Bring build.gradle file up to date

* Update create-release
  • Loading branch information
crykn authored Oct 15, 2023
1 parent 34ef61f commit c2ae02e
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 93 deletions.
12 changes: 0 additions & 12 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

19 changes: 0 additions & 19 deletions .github/ISSUE_TEMPLATE/BUGS.md

This file was deleted.

13 changes: 0 additions & 13 deletions .github/ISSUE_TEMPLATE/NEW_FEATURE.md

This file was deleted.

18 changes: 0 additions & 18 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build & Test

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
with:
arguments: build
50 changes: 50 additions & 0 deletions .github/workflows/create-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Create release

on:
push:
tags:
- 'v*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'

# - name: Fix permissions
# run: chmod +x gradlew

- name: Build zip
run: ./gradlew desktop:dist

- name: Simplify file name
run: mv desktop/build/libs/*.zip ProjektGG.zip

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ProjektGG ${{ github.ref }}
draft: false
prerelease: false

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./ProjektGG.zip
asset_name: ProjektGG.zip
asset_content_type: application/zip
59 changes: 28 additions & 31 deletions desktop/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,65 @@ apply plugin: "java"
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

import org.gradle.internal.os.OperatingSystem

project.ext.mainClassName = "de.gg.desktop.DesktopLauncher"
project.ext.assetsDir = new File("../game/assets");

task run(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
tasks.register('run', JavaExec) {
dependsOn classes
mainClass = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true

if (OperatingSystem.current() == OperatingSystem.MAC_OS) {
jvmArgs += "-XstartOnFirstThread"
}
}

task debug(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
tasks.register('debug', JavaExec) {
dependsOn classes
mainClass = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
debug = true
}

jar {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
// Generate a fat jar
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }

manifest {
attributes (
"Main-Class": project.mainClassName,
"Implementation-Version": project.version
)
}
}
jar.dependsOn classes


task dist(type: Zip){
archiveName appName+"_"+version+".zip"
jar.dependsOn configurations.runtimeClasspath

from fileTree(project.assetsDir) {
exclude("CONTRIBUTORS.md")
}
from file("../LICENSE");
from file("../CONTRIBUTORS.md");
from jar.outputs.files
tasks.register('dist', Jar) {
archiveName appName + "_" + version + ".zip"

//duplicatesStrategy(DuplicatesStrategy.INCLUDE)

from fileTree(project.assetsDir) {
exclude("CONTRIBUTORS.md")
}
from file("../LICENSE");
from file("../CONTRIBUTORS.md");
from jar.outputs.files
}

dist.dependsOn jar


eclipse {
project {
name = appName + "-desktop"
linkedResource name: "assets", type: "2", location: "PARENT-1-PROJECT_LOC/game/assets"
}
}

task afterEclipseImport(description: "Post processing after project generation", group: "IDE") {
doLast {
def classpath = new XmlParser().parse(file(".classpath"))
new Node(classpath, "classpathentry", [ kind: "src", path: "assets" ]);
def writer = new FileWriter(file(".classpath"))
def printer = new XmlNodePrinter(new PrintWriter(writer))
printer.setPreserveWhitespace(true)
printer.print(classpath)
}
}
Empty file modified gradlew
100644 → 100755
Empty file.

0 comments on commit c2ae02e

Please sign in to comment.