diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cb92bc9..deaf708 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 + - name: Upload release assets uses: softprops/action-gh-release@v2 with: files: | - ./app/build/libs/app-all.jar \ No newline at end of file + ./app/build/libs/app-all.jar + ./JavaAppTemplate.zip + ./JavaAppTemplate-windows.zip + ./JavaAppTemplate-macos.zip + ./JavaAppTemplate-linux.tar.xz \ No newline at end of file diff --git a/LICENSE b/LICENSE index 8818022..9201a5f 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/package-linux.sh b/package-linux.sh new file mode 100644 index 0000000..2d54e08 --- /dev/null +++ b/package-linux.sh @@ -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 + +# 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 "" \ No newline at end of file diff --git a/package-mac.sh b/package-mac.sh new file mode 100644 index 0000000..170dbee --- /dev/null +++ b/package-mac.sh @@ -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 + +# 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 "" \ No newline at end of file diff --git a/package-win.sh b/package-win.sh new file mode 100644 index 0000000..abb8bae --- /dev/null +++ b/package-win.sh @@ -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 + +# 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 + +@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 "" \ No newline at end of file diff --git a/package-zip.sh b/package-zip.sh new file mode 100755 index 0000000..7413a77 --- /dev/null +++ b/package-zip.sh @@ -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 \ No newline at end of file diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..727fbfe --- /dev/null +++ b/scripts/README.md @@ -0,0 +1 @@ +Scripts used in packaging \ No newline at end of file diff --git a/scripts/run.bat b/scripts/run.bat new file mode 100644 index 0000000..3be3652 --- /dev/null +++ b/scripts/run.bat @@ -0,0 +1,5 @@ +@echo off + +java -jar app.jar + +@pause \ No newline at end of file diff --git a/scripts/run.sh b/scripts/run.sh new file mode 100755 index 0000000..2fe1e73 --- /dev/null +++ b/scripts/run.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +java -jar app.jar \ No newline at end of file