Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,24 @@ jobs:
- name: Build JAR with Gradle
run: ./gradlew build

- name: Build ZIP archive
run: ./package-zip.sh

- name: Build Windows package with bundled JRE
run: ./package-win.sh

- name: Build macOS package with bundled JRE
run: ./package-mac.sh

- name: Build Linux package with bundled JRE
run: ./package-linux.sh
Comment on lines 26 to +39
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the addition of these packaging steps, ./gradlew build is now executed once in the workflow (line 26) and again inside each of package-zip.sh, package-win.sh, package-mac.sh, and package-linux.sh. This causes up to five Gradle builds per release, which is unnecessary work on CI; consider either dropping the standalone "Build JAR" step and relying on the packaging scripts, or parameterizing the scripts so they can reuse an existing build when run from the workflow.

Copilot uses AI. Check for mistakes.

- name: Upload release assets
uses: softprops/action-gh-release@v2
with:
files: |
./app/build/libs/app-all.jar
./app/build/libs/app-all.jar
./JavaAppTemplate.zip
./JavaAppTemplate-windows.zip
./JavaAppTemplate-macos.zip
./JavaAppTemplate-linux.tar.xz
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2025 Project516
Copyright (c) 2025 - 2026 Project516

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
66 changes: 66 additions & 0 deletions package-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/sh

set -e

# Configuration
PACKAGE_NAME="JavaAppTemplate-linux"
JRE_DIR="jre-linux"
ADOPTIUM_BASE_URL="https://api.adoptium.net/v3/binary/latest/25/ga"

# Clean up any previous builds
rm -rf ${PACKAGE_NAME}
rm -rf ${JRE_DIR}
rm -f ${PACKAGE_NAME}.tar.xz
rm -f ${PACKAGE_NAME}.tar.gz

# Build the application using Gradle
echo "Building application..."
./gradlew build

# Download JRE for Linux from Eclipse Adoptium
echo "Downloading JRE for Linux..."
mkdir -p ${JRE_DIR}
curl -L "${ADOPTIUM_BASE_URL}/linux/x64/jre/hotspot/normal/eclipse?project=jdk" -o ${JRE_DIR}/jre-linux.tar.gz
Comment on lines +8 to +23
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script downloads a Linux JRE from ADOPTIUM_BASE_URL using curl with a mutable latest selector and immediately bundles it without any checksum or signature verification. If an attacker compromises the Adoptium endpoint or the network path, the build will silently package and distribute a malicious JRE that end users execute via the generated run.sh, enabling a supply-chain compromise. To harden this, pin to a specific JRE build and verify its integrity (e.g., checksum or signature) before extraction, failing the build on mismatch.

Copilot uses AI. Check for mistakes.

# Extract the downloaded JRE
echo "Extracting JRE..."
cd ${JRE_DIR}
tar -xzf jre-linux.tar.gz
JRE_EXTRACTED=$(ls -d jdk* 2>/dev/null || ls -d jre* 2>/dev/null)
cd ..

# Create package directory structure
echo "Creating package structure..."
mkdir -p ${PACKAGE_NAME}
cp app/build/libs/app-all.jar ${PACKAGE_NAME}/app.jar
cp README.md ${PACKAGE_NAME}/README.txt
cp LICENSE ${PACKAGE_NAME}/LICENSE

# Copy the JRE into the package
echo "Copying JRE into package..."
cp -r ${JRE_DIR}/${JRE_EXTRACTED} ${PACKAGE_NAME}/jre

# Create a shell script that uses the bundled JRE
cat > ${PACKAGE_NAME}/run.sh << 'EOF'
#!/bin/sh
# Get the directory where the script is located
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
"${SCRIPT_DIR}/jre/bin/java" -jar "${SCRIPT_DIR}/app.jar"
EOF

# Make the run script executable
chmod +x ${PACKAGE_NAME}/run.sh

# Create the final tar.xz archive with maximum compression
echo "Creating tar.xz archive..."
tar -cJf ${PACKAGE_NAME}.tar.xz ${PACKAGE_NAME}/

# Clean up temporary directories
rm -rf ${PACKAGE_NAME}
rm -rf ${JRE_DIR}

echo ""
echo "✓ Linux package with bundled JRE created: ${PACKAGE_NAME}.tar.xz"
echo ""
65 changes: 65 additions & 0 deletions package-mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/sh

set -e

# Configuration
PACKAGE_NAME="JavaAppTemplate-macos"
JRE_DIR="jre-macos"
ADOPTIUM_BASE_URL="https://api.adoptium.net/v3/binary/latest/25/ga"

# Clean up any previous builds
rm -rf ${PACKAGE_NAME}
rm -rf ${JRE_DIR}
rm -f ${PACKAGE_NAME}.zip

# Build the application using Gradle
echo "Building application..."
./gradlew build

# Download JRE for macOS from Eclipse Adoptium
echo "Downloading JRE for macOS..."
mkdir -p ${JRE_DIR}
curl -L "${ADOPTIUM_BASE_URL}/mac/x64/jre/hotspot/normal/eclipse?project=jdk" -o ${JRE_DIR}/jre-macos.tar.gz
Comment on lines +8 to +22
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script downloads a macOS JRE from ADOPTIUM_BASE_URL using curl with a mutable latest selector and immediately bundles it without any checksum or signature verification. If an attacker compromises the Adoptium endpoint or the network path, the build will silently package and distribute a malicious JRE that end users execute via the generated run.sh, enabling a supply-chain compromise. To harden this, pin to a specific JRE build and verify its integrity (e.g., checksum or signature) before extraction, failing the build on mismatch.

Copilot uses AI. Check for mistakes.

# Extract the downloaded JRE
echo "Extracting JRE..."
cd ${JRE_DIR}
tar -xzf jre-macos.tar.gz
JRE_EXTRACTED=$(ls -d jdk* 2>/dev/null || ls -d jre* 2>/dev/null)
cd ..

# Create package directory structure
echo "Creating package structure..."
mkdir -p ${PACKAGE_NAME}
cp app/build/libs/app-all.jar ${PACKAGE_NAME}/app.jar
cp README.md ${PACKAGE_NAME}/README.txt
cp LICENSE ${PACKAGE_NAME}/LICENSE

# Copy the JRE into the package
echo "Copying JRE into package..."
cp -r ${JRE_DIR}/${JRE_EXTRACTED} ${PACKAGE_NAME}/jre

# Create a shell script that uses the bundled JRE (macOS JRE structure: Contents/Home)
cat > ${PACKAGE_NAME}/run.sh << 'EOF'
#!/bin/sh
# Get the directory where the script is located
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
"${SCRIPT_DIR}/jre/Contents/Home/bin/java" -jar "${SCRIPT_DIR}/app.jar"
EOF

# Make the run script executable
chmod +x ${PACKAGE_NAME}/run.sh

# Create the final zip archive with maximum compression
echo "Creating zip archive..."
zip -9 -r ${PACKAGE_NAME}.zip ${PACKAGE_NAME}/

# Clean up temporary directories
rm -rf ${PACKAGE_NAME}
rm -rf ${JRE_DIR}

echo ""
echo "✓ macOS package with bundled JRE created: ${PACKAGE_NAME}.zip"
echo ""
61 changes: 61 additions & 0 deletions package-win.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/sh

set -e

# Configuration
PACKAGE_NAME="JavaAppTemplate-windows"
JRE_DIR="jre-windows"
ADOPTIUM_BASE_URL="https://api.adoptium.net/v3/binary/latest/25/ga"

# Clean up any previous builds
rm -rf ${PACKAGE_NAME}
rm -rf ${JRE_DIR}
rm -f ${PACKAGE_NAME}.zip

# Build the application using Gradle
echo "Building application..."
./gradlew build

# Download JRE for Windows from Eclipse Adoptium
echo "Downloading JRE for Windows..."
mkdir -p ${JRE_DIR}
curl -L "${ADOPTIUM_BASE_URL}/windows/x64/jre/hotspot/normal/eclipse?project=jdk" -o ${JRE_DIR}/jre-windows.zip
Comment on lines +8 to +22
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script downloads a Windows JRE from ADOPTIUM_BASE_URL using curl with a mutable latest selector and immediately bundles it without any checksum or signature verification. If an attacker compromises the Adoptium endpoint or the network path, the build will silently package and distribute a malicious JRE that end users execute via run.bat, enabling a supply-chain compromise. To harden this, pin to a specific JRE build and verify its integrity (e.g., checksum or signature) before extraction, failing the build on mismatch.

Copilot uses AI. Check for mistakes.

# Extract the downloaded JRE
echo "Extracting JRE..."
cd ${JRE_DIR}
unzip -q jre-windows.zip
JRE_EXTRACTED=$(ls -d jdk* 2>/dev/null || ls -d jre* 2>/dev/null)
cd ..

# Create package directory structure
echo "Creating package structure..."
mkdir -p ${PACKAGE_NAME}
cp app/build/libs/app-all.jar ${PACKAGE_NAME}/app.jar
cp README.md ${PACKAGE_NAME}/README.txt
cp LICENSE ${PACKAGE_NAME}/LICENSE

# Copy the JRE into the package
echo "Copying JRE into package..."
cp -r ${JRE_DIR}/${JRE_EXTRACTED} ${PACKAGE_NAME}/jre

# Create a Windows batch file that uses the bundled JRE
cat > ${PACKAGE_NAME}/run.bat << 'EOF'
@echo off

jre\bin\java.exe -jar app.jar
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this packaging script the JAR is copied as game.jar (line 34), but the generated run.bat below invokes java.exe -jar app.jar (line 46). This mismatch means the bundled Windows package will fail at runtime with "Unable to access jarfile app.jar" because that file does not exist in the package; the name used in the copy command and the batch launcher should be made consistent (either both app.jar or both game.jar).

Suggested change
jre\bin\java.exe -jar app.jar
jre\bin\java.exe -jar game.jar

Copilot uses AI. Check for mistakes.

@pause
EOF

# Create the final zip archive with maximum compression
echo "Creating zip archive..."
zip -9 -r ${PACKAGE_NAME}.zip ${PACKAGE_NAME}/

# Clean up temporary directories
rm -rf ${PACKAGE_NAME}
rm -rf ${JRE_DIR}

echo ""
echo "✓ Windows package with bundled JRE created: ${PACKAGE_NAME}.zip"
echo ""
24 changes: 24 additions & 0 deletions package-zip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

# Clean up any previous builds
rm -rf package-zip
rm -f JavaAppTemplate.zip

# Build the application
./gradlew build

# Create distribution directory structure
mkdir package-zip

# Copy the game JAR and necessary files
cp -r app/build/libs/app-all.jar package-zip/app.jar
cp -r scripts/run.bat package-zip/run.bat
cp -r scripts/run.sh package-zip/run.sh
cp -r README.md package-zip/README.txt
cp -r LICENSE package-zip/LICENSE

# Create the ZIP archive with maximum compression
zip -9 -r JavaAppTemplate.zip package-zip/

# Clean up temporary directory
rm -rf package-zip
1 change: 1 addition & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Scripts used in packaging
5 changes: 5 additions & 0 deletions scripts/run.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off

java -jar app.jar

@pause
3 changes: 3 additions & 0 deletions scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

java -jar app.jar
Loading