diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1345f66..d4b6d07 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,10 +9,41 @@ on: types: [created] jobs: - build-and-upload: + build-assets: runs-on: ubuntu-latest - permissions: - contents: write + strategy: + fail-fast: true + matrix: + target: + - name: jar + command: ./gradlew build && cp app/build/libs/app-all.jar NumberGuessingGame.jar + artifact: NumberGuessingGame.jar + path: ./NumberGuessingGame.jar + - name: deb + command: ./package-deb.sh + artifact: NumberGuessingGame.deb + path: ./NumberGuessingGame.deb + - name: rpm + command: ./package-rpm.sh + artifact: NumberGuessingGame.rpm + path: ./NumberGuessingGame.rpm + needsRpmTools: true + - name: zip + command: ./package-zip.sh + artifact: NumberGuessingGame-archive.zip + path: ./NumberGuessingGame-archive.zip + - name: windows + command: ./package-win.sh + artifact: NumberGuessingGame-windows.zip + path: ./NumberGuessingGame-windows.zip + - name: macos + command: ./package-macos.sh + artifact: NumberGuessingGame-macos.zip + path: ./NumberGuessingGame-macos.zip + - name: linux + command: ./package-linux.sh + artifact: NumberGuessingGame-linux.tar.xz + path: ./NumberGuessingGame-linux.tar.xz steps: - name: Checkout code @@ -27,38 +58,40 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v5 - - name: Build JAR with Gradle - run: ./gradlew build - - - name: Build Debian package - run: ./package-deb.sh - - name: Install RPM build tools + if: ${{ matrix.target.needsRpmTools }} 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 + - name: Build ${{ matrix.target.name }} + run: ${{ matrix.target.command }} - - name: Build Windows package with bundled JRE - run: ./package-win.sh + - name: Upload ${{ matrix.target.name }} artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.target.artifact }} + path: ${{ matrix.target.path }} + if-no-files-found: error - - name: Build macOS package with bundled JRE - run: ./package-macos.sh + create-release: + runs-on: ubuntu-latest + needs: build-assets + permissions: + contents: write - - name: Build Linux package with bundled JRE - run: ./package-linux.sh + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + path: dist - name: Upload release assets uses: softprops/action-gh-release@v2 with: files: | - ./app/build/libs/app-all.jar - ./numberguessinggame.deb - ./numberguessinggame.rpm - ./archive.zip - ./NumberGuessingGame-windows.zip - ./NumberGuessingGame-macos.zip - ./NumberGuessingGame-linux.tar.xz \ No newline at end of file + dist/NumberGuessingGame.jar/NumberGuessingGame.jar + dist/NumberGuessingGame.deb/NumberGuessingGame.deb + dist/NumberGuessingGame.rpm/NumberGuessingGame.rpm + dist/NumberGuessingGame-archive.zip/NumberGuessingGame-archive.zip + dist/NumberGuessingGame-windows.zip/NumberGuessingGame-windows.zip + dist/NumberGuessingGame-macos.zip/NumberGuessingGame-macos.zip + dist/NumberGuessingGame-linux.tar.xz/NumberGuessingGame-linux.tar.xz \ No newline at end of file diff --git a/.gitignore b/.gitignore index a2d29e7..0fa0a77 100644 --- a/.gitignore +++ b/.gitignore @@ -27,18 +27,20 @@ gradle-app.setting # Ignore Gradle build output directory build -archive.zip -numberguessinggame.deb -numberguessinggame-*.rpm - # JRE bundling artifacts jre-windows/ jre-macos/ jre-linux/ + +# Unzipped artifacts NumberGuessingGame-windows/ NumberGuessingGame-macos/ NumberGuessingGame-linux/ + +# Packaged artifacts NumberGuessingGame-windows.zip NumberGuessingGame-macos.zip NumberGuessingGame-linux.tar.xz -numberguessinggame.rpm \ No newline at end of file +NumberGuessingGame.rpm +NumberGuessingGame.deb +NumberGuessingGame.jar \ No newline at end of file diff --git a/package-deb.sh b/package-deb.sh index d2e9b30..216edfe 100755 --- a/package-deb.sh +++ b/package-deb.sh @@ -7,7 +7,7 @@ # Script to create a Debian package (.deb) for Number Guessing Game # This package can be installed on Debian-based Linux distributions (Ubuntu, Mint, etc.) # Usage: ./package-deb.sh -# Output: numberguessinggame.deb +# Output: NumberGuessingGame.deb # Exit immediately if any command fails set -e @@ -17,7 +17,7 @@ echo "Building Number Guessing Game Debian package..." # Clean up any previous build artifacts echo "Cleaning up previous builds..." rm -rf debian-package/usr/share/games/numberguessinggame/* -rm -f numberguessinggame.deb +rm -f NumberGuessingGame.deb # Build the application using Gradle echo "Building application..." @@ -40,16 +40,16 @@ chmod 755 debian-package/usr/games/numberguessinggame # Build the .deb package using dpkg-deb echo "Building .deb package..." -dpkg-deb --build debian-package numberguessinggame.deb +dpkg-deb --build debian-package NumberGuessingGame.deb # Display success message with installation instructions echo "" -echo "✓ Debian package created: numberguessinggame.deb" +echo "✓ Debian package created: NumberGuessingGame.deb" echo "" echo "To install, run:" -echo " sudo apt install ./numberguessinggame.deb" +echo " sudo apt install ./NumberGuessingGame.deb" echo " sudo apt install -f # to install any missing dependencies" echo "" echo "After installation, run the game with:" echo " numberguessinggame" -echo "" +echo "" \ No newline at end of file diff --git a/package-rpm.sh b/package-rpm.sh index 80b2d8c..ed9f8e6 100755 --- a/package-rpm.sh +++ b/package-rpm.sh @@ -7,7 +7,7 @@ # 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 +# Output: NumberGuessingGame.rpm # Exit immediately if any command fails set -e @@ -27,7 +27,7 @@ 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 +rm -f NumberGuessingGame.rpm # Build the application using Gradle echo "Building application..." @@ -55,18 +55,18 @@ 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 ./numberguessinggame.rpm +cp ~/rpmbuild/RPMS/noarch/numberguessinggame-*.rpm ./NumberGuessingGame.rpm # Display success message with installation instructions echo "" -echo "✓ RPM package created: $(ls numberguessinggame.rpm)" +echo "✓ RPM package created: $(ls NumberGuessingGame.rpm)" echo "" echo "To install on Fedora/RHEL/CentOS, run:" -echo " sudo dnf install ./numberguessinggame.rpm" +echo " sudo dnf install ./NumberGuessingGame.rpm" echo "" echo "Or on older systems:" -echo " sudo yum install ./numberguessinggame.rpm" +echo " sudo yum install ./NumberGuessingGame.rpm" echo "" echo "After installation, run the game with:" echo " numberguessinggame" -echo "" +echo "" \ No newline at end of file diff --git a/package-zip.sh b/package-zip.sh index 1e6ceec..fcbd745 100755 --- a/package-zip.sh +++ b/package-zip.sh @@ -10,7 +10,7 @@ # Clean up any previous builds rm -rf NumberGuessingGame rm -rf temp -rm -f archive.zip +rm -f NumberGuessingGame-archive.zip # Build the application cd app @@ -28,7 +28,7 @@ cp -r README.md NumberGuessingGame/README.txt cp -r LICENSE NumberGuessingGame/LICENSE # Create the ZIP archive with maximum compression -zip -9 -r archive.zip NumberGuessingGame/ +zip -9 -r NumberGuessingGame-archive.zip NumberGuessingGame/ # Clean up temporary directory -rm -rf NumberGuessingGame +rm -rf NumberGuessingGame \ No newline at end of file