Skip to content

Commit f0eece3

Browse files
authored
Merge pull request #57 from Project516/copilot/bundle-jre-with-app
Add JRE bundling for Windows, macOS, and Linux releases
2 parents ef7dd51 + 019fb58 commit f0eece3

8 files changed

Lines changed: 255 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ jobs:
3030
run: ./package-deb.sh
3131

3232
- name: Build ZIP archive
33-
run: ./package.sh
33+
run: ./package-zip.sh
34+
35+
- name: Build Windows package with bundled JRE
36+
run: ./package-win.sh
37+
38+
- name: Build macOS package with bundled JRE
39+
run: ./package-macos.sh
40+
41+
- name: Build Linux package with bundled JRE
42+
run: ./package-linux.sh
3443

3544
- name: Upload release assets
3645
uses: softprops/action-gh-release@v2
@@ -39,3 +48,6 @@ jobs:
3948
./app/build/libs/app.jar
4049
./numberguessinggame.deb
4150
./archive.zip
51+
./NumberGuessingGame-windows.zip
52+
./NumberGuessingGame-macos.zip
53+
./NumberGuessingGame-linux.tar.gz

.gitignore

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,15 @@ gradle-app.setting
2424
build
2525

2626
archive.zip
27-
numberguessinggame.deb
27+
numberguessinggame.deb
28+
29+
# JRE bundling artifacts
30+
jre-windows/
31+
jre-macos/
32+
jre-linux/
33+
NumberGuessingGame-windows/
34+
NumberGuessingGame-macos/
35+
NumberGuessingGame-linux/
36+
NumberGuessingGame-windows.zip
37+
NumberGuessingGame-macos.zip
38+
NumberGuessingGame-linux.tar.gz

README.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,25 @@ sudo apt remove numberguessinggame
3232
sudo apt autoremove -y # Remove dependencies
3333
```
3434

35-
### Manual Installation
35+
### Standalone Packages with Bundled JRE (Recommended)
3636

37-
Download the `zip` archive from the [latest release](https://github.com/project516/numberguessinggame/releases)
37+
Download the platform-specific package with bundled JRE from the [latest release](https://github.com/project516/numberguessinggame/releases):
38+
39+
- **Windows**: `NumberGuessingGame-windows.zip` (no Java installation required)
40+
- **macOS**: `NumberGuessingGame-macos.zip` (no Java installation required)
41+
- **Linux**: `NumberGuessingGame-linux.tar.gz` (no Java installation required)
42+
43+
Extract the downloaded archive and run:
44+
45+
**On Windows:**
46+
Run `run.bat`
47+
48+
**On Linux/Mac:**
49+
Run `run.sh`
50+
51+
### Manual Installation (Requires Java)
52+
53+
Download the `archive.zip` from the [latest release](https://github.com/project516/numberguessinggame/releases)
3854

3955
#### Requirements
4056

@@ -89,7 +105,7 @@ gradle test
89105

90106
### Creating Release Archives
91107

92-
#### Zip Archive
108+
#### Zip Archive (Requires Java)
93109

94110
**On Windows:**
95111
Run `.\gradlew build` and `.\package.bat` from the project root.
@@ -105,3 +121,16 @@ This will create `archive.zip` containing the application, run scripts, README,
105121
Run `./package-deb.sh` from the project root.
106122

107123
This will create `numberguessinggame.deb` which can be installed via `apt`/`dpkg` on Debian-based systems. The package can be released to GitHub Releases for easy distribution.
124+
125+
#### Platform-Specific Packages with Bundled JRE
126+
127+
**On Linux:**
128+
Run the following scripts to create platform-specific packages with bundled JRE:
129+
130+
```bash
131+
./package-jre-windows.sh # Creates NumberGuessingGame-windows.zip
132+
./package-jre-macos.sh # Creates NumberGuessingGame-macos.zip
133+
./package-jre-linux.sh # Creates NumberGuessingGame-linux.tar.gz
134+
```
135+
136+
These packages include a bundled JRE and do not require Java to be installed on the target system. They are automatically built and uploaded to GitHub Releases via GitHub Actions.

package-linux.sh

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

package-macos.sh

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

package-win.sh

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

0 commit comments

Comments
 (0)