diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 963b313..26c2b64 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,6 +29,12 @@ jobs: - name: Build Debian package run: ./package-deb.sh + - name: Install RPM build tools + run: sudo apt-get update && sudo apt-get install -y rpm + + - name: Build Fedora/RPM package + run: ./package-rpm.sh + - name: Build ZIP archive run: ./package-zip.sh @@ -47,6 +53,7 @@ jobs: files: | ./app/build/libs/app-all.jar ./numberguessinggame.deb + ./numberguessinggame-*.rpm ./archive.zip ./NumberGuessingGame-windows.zip ./NumberGuessingGame-macos.zip diff --git a/.gitignore b/.gitignore index 20409e3..2effbd3 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ build archive.zip numberguessinggame.deb +numberguessinggame-*.rpm # JRE bundling artifacts jre-windows/ @@ -35,4 +36,4 @@ NumberGuessingGame-macos/ NumberGuessingGame-linux/ NumberGuessingGame-windows.zip NumberGuessingGame-macos.zip -NumberGuessingGame-linux.tar.gz +NumberGuessingGame-linux.tar.xz diff --git a/README.md b/README.md index 4973e5f..829a2e2 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ For Debian/Ubuntu and derivatives (recommended for terminal usage): You can use curl to do it from the command line: ```bash - curl -s -L -o numberguessingame.deb https://github.com/Project516/NumberGuessingGame/releases/download/0.x.y/numberguessinggame.deb + curl -s -L -o numberguessinggame.deb https://github.com/Project516/NumberGuessingGame/releases/download/0.x.y/numberguessinggame.deb ``` where `x` and `y` is the version you want. 2. Install it: @@ -41,6 +41,39 @@ sudo apt remove numberguessinggame sudo apt autoremove -y # Remove dependencies ``` +### Installation via Fedora/RPM Package (DNF/YUM) + +For Fedora, RHEL, CentOS, and other RPM-based distributions: + +1. Download the `.rpm` package from the [latest release](https://github.com/Project516/NumberGuessingGame/releases) + + You can use curl to do it from the command line: + ```bash + curl -s -L -o numberguessinggame.rpm https://github.com/Project516/NumberGuessingGame/releases/download/0.x.y/numberguessinggame-1.0.0-1.noarch.rpm + ``` + where `x` and `y` is the version you want. +2. Install it: + ```bash + sudo dnf install ./numberguessinggame-*.rpm + ``` + Or on older systems: + ```bash + sudo yum install ./numberguessinggame-*.rpm + ``` +3. Run from anywhere in your terminal: + ```bash + numberguessinggame + ``` + +To uninstall: +```bash +sudo dnf remove numberguessinggame +``` +Or on older systems: +```bash +sudo yum remove numberguessinggame +``` + ### Standalone Packages with Bundled JRE (Recommended) Download the platform-specific package with bundled JRE from the [latest release](https://github.com/project516/numberguessinggame/releases): @@ -63,7 +96,7 @@ Download the `archive.zip` from the [latest release](https://github.com/project5 #### Requirements -- Java 8 or higher +- Java 17 or higher #### How to Run @@ -167,6 +200,13 @@ Run `./package-deb.sh` from the project root. 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. +#### Fedora/RPM Package + +**On Linux (requires rpm-build):** +Run `./package-rpm.sh` from the project root. + +This will create `numberguessinggame-1.0.0-1.noarch.rpm` which can be installed via `dnf`/`yum`/`rpm` on Fedora, RHEL, CentOS, and other RPM-based systems. The package can be released to GitHub Releases for easy distribution. + #### Platform-Specific Packages with Bundled JRE **On Linux:** diff --git a/app/build.gradle b/app/build.gradle index bb67428..a50d06a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,22 +1,19 @@ plugins { - // Apply the application plugin to add support for building a CLI application in Java. - id 'application' - //Spotless + id 'application' id 'com.diffplug.spotless' version '8.1.0' - id 'com.gradleup.shadow' version '9.2.2' } repositories { - // Use Maven Central for resolving dependencies. + mavenCentral() gradlePluginPortal() google() } dependencies { - // This dependency is used by the application. + implementation libs.guava } @@ -25,7 +22,7 @@ testing { // Configure the built-in test suite test { // Use JUnit Jupiter test framework - useJUnitJupiter('5.14.1') + useJUnitJupiter('6.0.1') } } } @@ -33,8 +30,8 @@ testing { // Apply a specific Java toolchain to ease working on different environments. java { toolchain { - // Use JDK 25 - languageVersion = JavaLanguageVersion.of(8) + + languageVersion = JavaLanguageVersion.of(17) } } diff --git a/debian-package/DEBIAN/control b/debian-package/DEBIAN/control index 2805dfe..d1cdc72 100644 --- a/debian-package/DEBIAN/control +++ b/debian-package/DEBIAN/control @@ -3,7 +3,7 @@ Version: 1.0.0 Section: games Priority: optional Architecture: all -Depends: default-jre | java8-runtime +Depends: default-jre Maintainer: project516 Description: A simple number guessing game A simple number guessing game where you try to guess a randomly diff --git a/fedora-package/SOURCES/.gitignore b/fedora-package/SOURCES/.gitignore new file mode 100644 index 0000000..d2d3f64 --- /dev/null +++ b/fedora-package/SOURCES/.gitignore @@ -0,0 +1,4 @@ +# Ignore all build artifacts in this directory +* +# But keep this .gitignore file +!.gitignore diff --git a/fedora-package/SPECS/numberguessinggame.spec b/fedora-package/SPECS/numberguessinggame.spec new file mode 100644 index 0000000..7df051d --- /dev/null +++ b/fedora-package/SPECS/numberguessinggame.spec @@ -0,0 +1,54 @@ +# SPDX-FileCopyrightText: 2025 Project516 <138796702+Project516@users.noreply.github.com> +# +# SPDX-License-Identifier: GPL-3.0-or-later + +Name: numberguessinggame +Version: 1.0.0 +Release: 1%{?dist} +Summary: A simple number guessing game + +License: GPL-3.0-or-later +URL: https://github.com/Project516/NumberGuessingGame +Source0: game.jar + +BuildArch: noarch +Requires: java-17-openjdk-headless + +%description +A simple number guessing game where you try to guess a randomly +generated number. The game features both a user-friendly graphical +user interface (GUI) and a classic console mode. High scores are +tracked and stored persistently. + +%prep +# No prep needed for prebuilt JAR + +%build +# No build needed for prebuilt JAR + +%install +rm -rf %{buildroot} + +# Create directories +mkdir -p %{buildroot}%{_datadir}/games/%{name} +mkdir -p %{buildroot}%{_bindir} + +# Install JAR file +install -m 644 %{SOURCE0} %{buildroot}%{_datadir}/games/%{name}/game.jar + +# Create wrapper script +cat > %{buildroot}%{_bindir}/%{name} <<'EOF' +#!/bin/sh +# Wrapper script to launch Number Guessing Game +java -jar %{_datadir}/games/%{name}/game.jar "$@" +EOF + +chmod 755 %{buildroot}%{_bindir}/%{name} + +%files +%{_bindir}/%{name} +%{_datadir}/games/%{name}/game.jar + +%changelog +* Tue Dec 03 2024 Project516 <138796702+Project516@users.noreply.github.com> - 1.0.0-1 +- Initial Fedora package release diff --git a/package-linux.sh b/package-linux.sh index 44f7d56..9d800d3 100755 --- a/package-linux.sh +++ b/package-linux.sh @@ -16,7 +16,7 @@ echo "Building Number Guessing Game for Linux with bundled JRE..." # Configuration PACKAGE_NAME="NumberGuessingGame-linux" JRE_DIR="jre-linux" -ADOPTIUM_BASE_URL="https://api.adoptium.net/v3/binary/latest/8/ga" +ADOPTIUM_BASE_URL="https://api.adoptium.net/v3/binary/latest/17/ga" # Clean up any previous builds rm -rf ${PACKAGE_NAME} diff --git a/package-macos.sh b/package-macos.sh index 14ce181..a89f3bc 100755 --- a/package-macos.sh +++ b/package-macos.sh @@ -16,7 +16,7 @@ echo "Building Number Guessing Game for macOS with bundled JRE..." # Configuration PACKAGE_NAME="NumberGuessingGame-macos" JRE_DIR="jre-macos" -ADOPTIUM_BASE_URL="https://api.adoptium.net/v3/binary/latest/8/ga" +ADOPTIUM_BASE_URL="https://api.adoptium.net/v3/binary/latest/17/ga" # Clean up any previous builds rm -rf ${PACKAGE_NAME} diff --git a/package-rpm.sh b/package-rpm.sh new file mode 100755 index 0000000..28e9218 --- /dev/null +++ b/package-rpm.sh @@ -0,0 +1,72 @@ +#!/bin/sh + +# SPDX-FileCopyrightText: 2025 Project516 <138796702+Project516@users.noreply.github.com> +# +# SPDX-License-Identifier: GPL-3.0-or-later + +# Script to create a Fedora/RPM package (.rpm) for Number Guessing Game +# This package can be installed on Fedora, RHEL, CentOS, and other RPM-based distributions +# Usage: ./package-rpm.sh +# Output: numberguessinggame-1.0.0-1.noarch.rpm + +# Exit immediately if any command fails +set -e + +echo "Building Number Guessing Game RPM package..." + +# Check if rpmbuild is installed +if ! command -v rpmbuild >/dev/null 2>&1; then + echo "Error: rpmbuild not found. Please install rpm-build:" + echo " Fedora/RHEL: sudo dnf install rpm-build" + echo " Ubuntu/Debian: sudo apt install rpm" + exit 1 +fi + +# Clean up any previous build artifacts +echo "Cleaning up previous builds..." +rm -rf ~/rpmbuild/RPMS/noarch/numberguessinggame-*.rpm +rm -rf ~/rpmbuild/BUILD/numberguessinggame-* +rm -rf ~/rpmbuild/BUILDROOT/numberguessinggame-* +rm -f numberguessinggame-*.rpm + +# Build the application using Gradle +echo "Building application..." +./gradlew build + +# Create RPM build directory structure +echo "Setting up RPM build environment..." +mkdir -p ~/rpmbuild/BUILD +mkdir -p ~/rpmbuild/RPMS +mkdir -p ~/rpmbuild/SOURCES +mkdir -p ~/rpmbuild/SPECS +mkdir -p ~/rpmbuild/SRPMS + +# Copy the spec file to the SPECS directory +echo "Copying spec file..." +cp fedora-package/SPECS/numberguessinggame.spec ~/rpmbuild/SPECS/numberguessinggame.spec + +# Copy the JAR file to the SOURCES directory +echo "Copying JAR file..." +cp app/build/libs/app-all.jar ~/rpmbuild/SOURCES/game.jar + +# Build the RPM package +echo "Building RPM package..." +rpmbuild -bb ~/rpmbuild/SPECS/numberguessinggame.spec + +# Copy the built RPM to the current directory +echo "Copying RPM package to current directory..." +cp ~/rpmbuild/RPMS/noarch/numberguessinggame-*.rpm . + +# Display success message with installation instructions +echo "" +echo "✓ RPM package created: $(ls numberguessinggame-*.rpm)" +echo "" +echo "To install on Fedora/RHEL/CentOS, run:" +echo " sudo dnf install ./numberguessinggame-*.rpm" +echo "" +echo "Or on older systems:" +echo " sudo yum install ./numberguessinggame-*.rpm" +echo "" +echo "After installation, run the game with:" +echo " numberguessinggame" +echo "" diff --git a/package-win.sh b/package-win.sh index 46be321..6d004dd 100755 --- a/package-win.sh +++ b/package-win.sh @@ -16,7 +16,7 @@ echo "Building Number Guessing Game for Windows with bundled JRE..." # Configuration PACKAGE_NAME="NumberGuessingGame-windows" JRE_DIR="jre-windows" -ADOPTIUM_BASE_URL="https://api.adoptium.net/v3/binary/latest/8/ga" +ADOPTIUM_BASE_URL="https://api.adoptium.net/v3/binary/latest/17/ga" # Clean up any previous builds rm -rf ${PACKAGE_NAME}