Skip to content

Commit

Permalink
Now compatible with java 8!
Browse files Browse the repository at this point in the history
  • Loading branch information
Miniontoby committed May 13, 2023
1 parent dd686f2 commit 2287800
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 23 deletions.
77 changes: 61 additions & 16 deletions .github/workflows/deploy-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,78 @@ on:
push:
branches:
- main
- test

permissions:
contents: write

jobs:
build:
name: Upload Release Asset
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]')"

steps:
- uses: actions/checkout@v1

- name: Build and Test
uses: qcastel/github-actions-maven-cmd@master
# OLD CODE:
#- name: Build and Test
# uses: qcastel/github-actions-maven-cmd@master
# env:
# api_key: ${{ secrets.API_KEY }}
# with:
# maven-args: "clean package"

#- name: Release
# uses: qcastel/github-actions-maven-release@master
# env:
# JAVA_HOME: /usr/lib/jvm/java-1.8-openjdk/
# with:
# git-release-bot-name: "bot-idhub"
# git-release-bot-email: "[email protected]"
# release-branch-name: main
# version-patch: true
# maven-development-version-number: ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.nextPatchVersion}-SNAPSHOT
# maven-release-version-number: ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.patchVersion}
# maven-args: "-Dmaven.javadoc.skip=true -DskipTests -DskipITs -Dmaven.deploy.skip=true -Dmaven.site.skip=true"
# ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}


# NEW CODE:
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: maven

- name: Build with Maven
run: mvn clean compile assembly:single package
env:
api_key: ${{ secrets.API_KEY }}
with:
maven-args: "clean package"

- name: Release
uses: qcastel/github-actions-maven-release@master
- name: Get Project Version
run: echo "PROJECT_VERSION=`mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | sed -n -e '/^\[.*\]/ !{ /^[0-9]/ { p; q } }'`" >> $GITHUB_ENV

- name: Create Release
id: create_release
uses: joutvhu/create-release@v1
with:
tag_name: v${{env.PROJECT_VERSION}}
name: Release ${{env.PROJECT_VERSION}}
draft: true
prerelease: false
remove_assets: true
env:
JAVA_HOME: /usr/lib/jvm/java-11-openjdk/
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
with:
git-release-bot-name: "bot-idhub"
git-release-bot-email: "[email protected]"
release-branch-name: main
version-patch: true
maven-development-version-number: ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.nextPatchVersion}-SNAPSHOT
maven-release-version-number: ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.patchVersion}

maven-args: "-Dmaven.javadoc.skip=true -DskipTests -DskipITs -Dmaven.deploy.skip=true -Dmaven.site.skip=true"
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./target/modupdater-${{env.PROJECT_VERSION}}-jar-with-dependencies.jar
asset_name: modupdater-${{env.PROJECT_VERSION}}-jar-with-dependencies.jar
asset_content_type: application/java-archive
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Binary file not shown.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.miniontoby</groupId>
<artifactId>modupdater</artifactId>
<version>1.3.${parsedVersion.nextPatchVersion}-SNAPSHOT</version>
<version>1.3.3-SNAPSHOT</version>

<name>ModUpdater</name>
<description>Java app to update your minecraft mods</description>
Expand Down Expand Up @@ -43,9 +43,9 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.release>8</maven.compiler.release>
<maven-release-plugin.version>2.5.3</maven-release-plugin.version>
<github.global.server>github</github.global.server>
<project.scm.id>github</project.scm.id>
Expand Down
20 changes: 18 additions & 2 deletions src/main/java/com/miniontoby/ModUpdater/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.google.gson.*;
import java.io.File;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.text.DateFormat;
import java.util.Date;
Expand All @@ -22,9 +24,23 @@ private static JsonObject getJSON(String url) {
java.net.URLConnection uc = new java.net.URL(url).openConnection();
uc.setRequestProperty("User-Agent", "ModUpdater - https://github.com/Miniontoby/ModUpdater");
uc.setRequestProperty("x-api-key", api_key);
java.io.InputStream is = uc.getInputStream();

String contents = new String(is.readAllBytes());
// Java 8
BufferedReader in = new BufferedReader(
new InputStreamReader(
uc.getInputStream()));
StringBuilder response = new StringBuilder();
String inputLine;
while ((inputLine = in.readLine()) != null) response.append(inputLine);
in.close();
String contents = response.toString();


// Java 11
//InputStream is = uc.getInputStream();
//String contents = new String(is.readAllBytes());


JsonObject jsonObject = JsonParser.parseString(contents).getAsJsonObject();
return jsonObject;
} catch (java.io.FileNotFoundException e) {
Expand Down
Binary file modified target/classes/com/miniontoby/ModUpdater/App.class
Binary file not shown.
Binary file modified target/classes/com/miniontoby/ModUpdater/CheckModPanel$1.class
Binary file not shown.
Binary file modified target/classes/com/miniontoby/ModUpdater/CheckModPanel.class
Binary file not shown.
Binary file modified target/classes/com/miniontoby/ModUpdater/InstallModPanel$1.class
Binary file not shown.
Binary file modified target/classes/com/miniontoby/ModUpdater/InstallModPanel.class
Binary file not shown.
Binary file not shown.
Binary file modified target/classes/com/miniontoby/ModUpdater/UpdateAllModsPanel.class
Binary file not shown.
2 changes: 1 addition & 1 deletion target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Created by Apache Maven 3.8.4
groupId=com.miniontoby
artifactId=modupdater
version=1.3.4-SNAPSHOT
version=1.3.3-SNAPSHOT
Binary file modified target/test-classes/com/miniontoby/ModUpdater/AppTest.class
Binary file not shown.

0 comments on commit 2287800

Please sign in to comment.