-
Notifications
You must be signed in to change notification settings - Fork 0
add package scripts from https://github.com/Project516/NumberGuessing… #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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
|
||
|
|
||
| # 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 "" | ||
| 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
|
||
|
|
||
| # 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 "" | ||
| 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
|
||||||
|
|
||||||
| # 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 | ||||||
|
||||||
| jre\bin\java.exe -jar app.jar | |
| jre\bin\java.exe -jar game.jar |
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Scripts used in packaging |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| @echo off | ||
|
|
||
| java -jar app.jar | ||
|
|
||
| @pause |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| #!/bin/sh | ||
|
|
||
| java -jar app.jar |
There was a problem hiding this comment.
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 buildis now executed once in the workflow (line 26) and again inside each ofpackage-zip.sh,package-win.sh,package-mac.sh, andpackage-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.