Skip to content

Commit 92740cc

Browse files
authored
Merge pull request #13 from Project516/package
add package scripts from https://github.com/Project516/NumberGuessing…
2 parents d70165e + 0364463 commit 92740cc

File tree

9 files changed

+243
-2
lines changed

9 files changed

+243
-2
lines changed

.github/workflows/release.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,24 @@ jobs:
2626
- name: Build JAR with Gradle
2727
run: ./gradlew build
2828

29+
- name: Build ZIP archive
30+
run: ./package-zip.sh
31+
32+
- name: Build Windows package with bundled JRE
33+
run: ./package-win.sh
34+
35+
- name: Build macOS package with bundled JRE
36+
run: ./package-mac.sh
37+
38+
- name: Build Linux package with bundled JRE
39+
run: ./package-linux.sh
40+
2941
- name: Upload release assets
3042
uses: softprops/action-gh-release@v2
3143
with:
3244
files: |
33-
./app/build/libs/app-all.jar
45+
./app/build/libs/app-all.jar
46+
./JavaAppTemplate.zip
47+
./JavaAppTemplate-windows.zip
48+
./JavaAppTemplate-macos.zip
49+
./JavaAppTemplate-linux.tar.xz

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2025 Project516
3+
Copyright (c) 2025 - 2026 Project516
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

package-linux.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
# Configuration
6+
PACKAGE_NAME="JavaAppTemplate-linux"
7+
JRE_DIR="jre-linux"
8+
ADOPTIUM_BASE_URL="https://api.adoptium.net/v3/binary/latest/25/ga"
9+
10+
# Clean up any previous builds
11+
rm -rf ${PACKAGE_NAME}
12+
rm -rf ${JRE_DIR}
13+
rm -f ${PACKAGE_NAME}.tar.xz
14+
rm -f ${PACKAGE_NAME}.tar.gz
15+
16+
# Build the application using Gradle
17+
echo "Building application..."
18+
./gradlew build
19+
20+
# Download JRE for Linux from Eclipse Adoptium
21+
echo "Downloading JRE for Linux..."
22+
mkdir -p ${JRE_DIR}
23+
curl -L "${ADOPTIUM_BASE_URL}/linux/x64/jre/hotspot/normal/eclipse?project=jdk" -o ${JRE_DIR}/jre-linux.tar.gz
24+
25+
# Extract the downloaded JRE
26+
echo "Extracting JRE..."
27+
cd ${JRE_DIR}
28+
tar -xzf jre-linux.tar.gz
29+
JRE_EXTRACTED=$(ls -d jdk* 2>/dev/null || ls -d jre* 2>/dev/null)
30+
cd ..
31+
32+
# Create package directory structure
33+
echo "Creating package structure..."
34+
mkdir -p ${PACKAGE_NAME}
35+
cp app/build/libs/app-all.jar ${PACKAGE_NAME}/app.jar
36+
cp README.md ${PACKAGE_NAME}/README.txt
37+
cp LICENSE ${PACKAGE_NAME}/LICENSE
38+
39+
# Copy the JRE into the package
40+
echo "Copying JRE into package..."
41+
cp -r ${JRE_DIR}/${JRE_EXTRACTED} ${PACKAGE_NAME}/jre
42+
43+
# Create a shell script that uses the bundled JRE
44+
cat > ${PACKAGE_NAME}/run.sh << 'EOF'
45+
#!/bin/sh
46+
47+
# Get the directory where the script is located
48+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
49+
50+
"${SCRIPT_DIR}/jre/bin/java" -jar "${SCRIPT_DIR}/app.jar"
51+
EOF
52+
53+
# Make the run script executable
54+
chmod +x ${PACKAGE_NAME}/run.sh
55+
56+
# Create the final tar.xz archive with maximum compression
57+
echo "Creating tar.xz archive..."
58+
tar -cJf ${PACKAGE_NAME}.tar.xz ${PACKAGE_NAME}/
59+
60+
# Clean up temporary directories
61+
rm -rf ${PACKAGE_NAME}
62+
rm -rf ${JRE_DIR}
63+
64+
echo ""
65+
echo "✓ Linux package with bundled JRE created: ${PACKAGE_NAME}.tar.xz"
66+
echo ""

package-mac.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
# Configuration
6+
PACKAGE_NAME="JavaAppTemplate-macos"
7+
JRE_DIR="jre-macos"
8+
ADOPTIUM_BASE_URL="https://api.adoptium.net/v3/binary/latest/25/ga"
9+
10+
# Clean up any previous builds
11+
rm -rf ${PACKAGE_NAME}
12+
rm -rf ${JRE_DIR}
13+
rm -f ${PACKAGE_NAME}.zip
14+
15+
# Build the application using Gradle
16+
echo "Building application..."
17+
./gradlew build
18+
19+
# Download JRE for macOS from Eclipse Adoptium
20+
echo "Downloading JRE for macOS..."
21+
mkdir -p ${JRE_DIR}
22+
curl -L "${ADOPTIUM_BASE_URL}/mac/x64/jre/hotspot/normal/eclipse?project=jdk" -o ${JRE_DIR}/jre-macos.tar.gz
23+
24+
# Extract the downloaded JRE
25+
echo "Extracting JRE..."
26+
cd ${JRE_DIR}
27+
tar -xzf jre-macos.tar.gz
28+
JRE_EXTRACTED=$(ls -d jdk* 2>/dev/null || ls -d jre* 2>/dev/null)
29+
cd ..
30+
31+
# Create package directory structure
32+
echo "Creating package structure..."
33+
mkdir -p ${PACKAGE_NAME}
34+
cp app/build/libs/app-all.jar ${PACKAGE_NAME}/app.jar
35+
cp README.md ${PACKAGE_NAME}/README.txt
36+
cp LICENSE ${PACKAGE_NAME}/LICENSE
37+
38+
# Copy the JRE into the package
39+
echo "Copying JRE into package..."
40+
cp -r ${JRE_DIR}/${JRE_EXTRACTED} ${PACKAGE_NAME}/jre
41+
42+
# Create a shell script that uses the bundled JRE (macOS JRE structure: Contents/Home)
43+
cat > ${PACKAGE_NAME}/run.sh << 'EOF'
44+
#!/bin/sh
45+
46+
# Get the directory where the script is located
47+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
48+
49+
"${SCRIPT_DIR}/jre/Contents/Home/bin/java" -jar "${SCRIPT_DIR}/app.jar"
50+
EOF
51+
52+
# Make the run script executable
53+
chmod +x ${PACKAGE_NAME}/run.sh
54+
55+
# Create the final zip archive with maximum compression
56+
echo "Creating zip archive..."
57+
zip -9 -r ${PACKAGE_NAME}.zip ${PACKAGE_NAME}/
58+
59+
# Clean up temporary directories
60+
rm -rf ${PACKAGE_NAME}
61+
rm -rf ${JRE_DIR}
62+
63+
echo ""
64+
echo "✓ macOS package with bundled JRE created: ${PACKAGE_NAME}.zip"
65+
echo ""

package-win.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
# Configuration
6+
PACKAGE_NAME="JavaAppTemplate-windows"
7+
JRE_DIR="jre-windows"
8+
ADOPTIUM_BASE_URL="https://api.adoptium.net/v3/binary/latest/25/ga"
9+
10+
# Clean up any previous builds
11+
rm -rf ${PACKAGE_NAME}
12+
rm -rf ${JRE_DIR}
13+
rm -f ${PACKAGE_NAME}.zip
14+
15+
# Build the application using Gradle
16+
echo "Building application..."
17+
./gradlew build
18+
19+
# Download JRE for Windows from Eclipse Adoptium
20+
echo "Downloading JRE for Windows..."
21+
mkdir -p ${JRE_DIR}
22+
curl -L "${ADOPTIUM_BASE_URL}/windows/x64/jre/hotspot/normal/eclipse?project=jdk" -o ${JRE_DIR}/jre-windows.zip
23+
24+
# Extract the downloaded JRE
25+
echo "Extracting JRE..."
26+
cd ${JRE_DIR}
27+
unzip -q jre-windows.zip
28+
JRE_EXTRACTED=$(ls -d jdk* 2>/dev/null || ls -d jre* 2>/dev/null)
29+
cd ..
30+
31+
# Create package directory structure
32+
echo "Creating package structure..."
33+
mkdir -p ${PACKAGE_NAME}
34+
cp app/build/libs/app-all.jar ${PACKAGE_NAME}/app.jar
35+
cp README.md ${PACKAGE_NAME}/README.txt
36+
cp LICENSE ${PACKAGE_NAME}/LICENSE
37+
38+
# Copy the JRE into the package
39+
echo "Copying JRE into package..."
40+
cp -r ${JRE_DIR}/${JRE_EXTRACTED} ${PACKAGE_NAME}/jre
41+
42+
# Create a Windows batch file that uses the bundled JRE
43+
cat > ${PACKAGE_NAME}/run.bat << 'EOF'
44+
@echo off
45+
46+
jre\bin\java.exe -jar app.jar
47+
48+
@pause
49+
EOF
50+
51+
# Create the final zip archive with maximum compression
52+
echo "Creating zip archive..."
53+
zip -9 -r ${PACKAGE_NAME}.zip ${PACKAGE_NAME}/
54+
55+
# Clean up temporary directories
56+
rm -rf ${PACKAGE_NAME}
57+
rm -rf ${JRE_DIR}
58+
59+
echo ""
60+
echo "✓ Windows package with bundled JRE created: ${PACKAGE_NAME}.zip"
61+
echo ""

package-zip.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
3+
# Clean up any previous builds
4+
rm -rf package-zip
5+
rm -f JavaAppTemplate.zip
6+
7+
# Build the application
8+
./gradlew build
9+
10+
# Create distribution directory structure
11+
mkdir package-zip
12+
13+
# Copy the game JAR and necessary files
14+
cp -r app/build/libs/app-all.jar package-zip/app.jar
15+
cp -r scripts/run.bat package-zip/run.bat
16+
cp -r scripts/run.sh package-zip/run.sh
17+
cp -r README.md package-zip/README.txt
18+
cp -r LICENSE package-zip/LICENSE
19+
20+
# Create the ZIP archive with maximum compression
21+
zip -9 -r JavaAppTemplate.zip package-zip/
22+
23+
# Clean up temporary directory
24+
rm -rf package-zip

scripts/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Scripts used in packaging

scripts/run.bat

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@echo off
2+
3+
java -jar app.jar
4+
5+
@pause

scripts/run.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
java -jar app.jar

0 commit comments

Comments
 (0)