Skip to content

Commit 2287800

Browse files
committed
Now compatible with java 8!
1 parent dd686f2 commit 2287800

File tree

13 files changed

+84
-23
lines changed

13 files changed

+84
-23
lines changed

.github/workflows/deploy-release.yaml

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,78 @@ on:
44
push:
55
branches:
66
- main
7+
- test
8+
9+
permissions:
10+
contents: write
711

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

1318
steps:
1419
- uses: actions/checkout@v1
1520

16-
- name: Build and Test
17-
uses: qcastel/github-actions-maven-cmd@master
21+
# OLD CODE:
22+
#- name: Build and Test
23+
# uses: qcastel/github-actions-maven-cmd@master
24+
# env:
25+
# api_key: ${{ secrets.API_KEY }}
26+
# with:
27+
# maven-args: "clean package"
28+
29+
#- name: Release
30+
# uses: qcastel/github-actions-maven-release@master
31+
# env:
32+
# JAVA_HOME: /usr/lib/jvm/java-1.8-openjdk/
33+
# with:
34+
# git-release-bot-name: "bot-idhub"
35+
# git-release-bot-email: "bot@idhub.io"
36+
# release-branch-name: main
37+
# version-patch: true
38+
# maven-development-version-number: ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.nextPatchVersion}-SNAPSHOT
39+
# maven-release-version-number: ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.patchVersion}
40+
# maven-args: "-Dmaven.javadoc.skip=true -DskipTests -DskipITs -Dmaven.deploy.skip=true -Dmaven.site.skip=true"
41+
# ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
42+
43+
44+
# NEW CODE:
45+
- name: Set up JDK 11
46+
uses: actions/setup-java@v3
47+
with:
48+
java-version: '11'
49+
distribution: 'temurin'
50+
cache: maven
51+
52+
- name: Build with Maven
53+
run: mvn clean compile assembly:single package
1854
env:
1955
api_key: ${{ secrets.API_KEY }}
20-
with:
21-
maven-args: "clean package"
2256

23-
- name: Release
24-
uses: qcastel/github-actions-maven-release@master
57+
- name: Get Project Version
58+
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
59+
60+
- name: Create Release
61+
id: create_release
62+
uses: joutvhu/create-release@v1
63+
with:
64+
tag_name: v${{env.PROJECT_VERSION}}
65+
name: Release ${{env.PROJECT_VERSION}}
66+
draft: true
67+
prerelease: false
68+
remove_assets: true
2569
env:
26-
JAVA_HOME: /usr/lib/jvm/java-11-openjdk/
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
72+
- name: Upload Release Asset
73+
id: upload-release-asset
74+
uses: actions/upload-release-asset@v1
2775
with:
28-
git-release-bot-name: "bot-idhub"
29-
git-release-bot-email: "bot@idhub.io"
30-
release-branch-name: main
31-
version-patch: true
32-
maven-development-version-number: ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.nextPatchVersion}-SNAPSHOT
33-
maven-release-version-number: ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.patchVersion}
34-
35-
maven-args: "-Dmaven.javadoc.skip=true -DskipTests -DskipITs -Dmaven.deploy.skip=true -Dmaven.site.skip=true"
36-
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
76+
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
77+
asset_path: ./target/modupdater-${{env.PROJECT_VERSION}}-jar-with-dependencies.jar
78+
asset_name: modupdater-${{env.PROJECT_VERSION}}-jar-with-dependencies.jar
79+
asset_content_type: application/java-archive
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Binary file not shown.

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.miniontoby</groupId>
66
<artifactId>modupdater</artifactId>
7-
<version>1.3.${parsedVersion.nextPatchVersion}-SNAPSHOT</version>
7+
<version>1.3.3-SNAPSHOT</version>
88

99
<name>ModUpdater</name>
1010
<description>Java app to update your minecraft mods</description>
@@ -43,9 +43,9 @@
4343

4444
<properties>
4545
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
46-
<maven.compiler.source>11</maven.compiler.source>
47-
<maven.compiler.target>11</maven.compiler.target>
48-
<maven.compiler.release>11</maven.compiler.release>
46+
<maven.compiler.source>1.8</maven.compiler.source>
47+
<maven.compiler.target>1.8</maven.compiler.target>
48+
<maven.compiler.release>8</maven.compiler.release>
4949
<maven-release-plugin.version>2.5.3</maven-release-plugin.version>
5050
<github.global.server>github</github.global.server>
5151
<project.scm.id>github</project.scm.id>

src/main/java/com/miniontoby/ModUpdater/App.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import com.google.gson.*;
44
import java.io.File;
55
import java.io.FileReader;
6+
import java.io.BufferedReader;
7+
import java.io.InputStreamReader;
68
import java.text.SimpleDateFormat;
79
import java.text.DateFormat;
810
import java.util.Date;
@@ -22,9 +24,23 @@ private static JsonObject getJSON(String url) {
2224
java.net.URLConnection uc = new java.net.URL(url).openConnection();
2325
uc.setRequestProperty("User-Agent", "ModUpdater - https://github.com/Miniontoby/ModUpdater");
2426
uc.setRequestProperty("x-api-key", api_key);
25-
java.io.InputStream is = uc.getInputStream();
2627

27-
String contents = new String(is.readAllBytes());
28+
// Java 8
29+
BufferedReader in = new BufferedReader(
30+
new InputStreamReader(
31+
uc.getInputStream()));
32+
StringBuilder response = new StringBuilder();
33+
String inputLine;
34+
while ((inputLine = in.readLine()) != null) response.append(inputLine);
35+
in.close();
36+
String contents = response.toString();
37+
38+
39+
// Java 11
40+
//InputStream is = uc.getInputStream();
41+
//String contents = new String(is.readAllBytes());
42+
43+
2844
JsonObject jsonObject = JsonParser.parseString(contents).getAsJsonObject();
2945
return jsonObject;
3046
} catch (java.io.FileNotFoundException e) {
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

target/maven-archiver/pom.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#Created by Apache Maven 3.8.4
22
groupId=com.miniontoby
33
artifactId=modupdater
4-
version=1.3.4-SNAPSHOT
4+
version=1.3.3-SNAPSHOT
Binary file not shown.

0 commit comments

Comments
 (0)