Skip to content

Commit 8fd0c77

Browse files
committed
use matrix build for release artifact creation
1 parent 4aa912c commit 8fd0c77

5 files changed

Lines changed: 83 additions & 48 deletions

File tree

.github/workflows/release.yml

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,41 @@ on:
99
types: [created]
1010

1111
jobs:
12-
build-and-upload:
12+
build-assets:
1313
runs-on: ubuntu-latest
14-
permissions:
15-
contents: write
14+
strategy:
15+
fail-fast: true
16+
matrix:
17+
target:
18+
- name: jar
19+
command: ./gradlew build && cp app/build/libs/app-all.jar NumberGuessingGame.jar
20+
artifact: NumberGuessingGame.jar
21+
path: ./NumberGuessingGame.jar
22+
- name: deb
23+
command: ./package-deb.sh
24+
artifact: NumberGuessingGame.deb
25+
path: ./NumberGuessingGame.deb
26+
- name: rpm
27+
command: ./package-rpm.sh
28+
artifact: NumberGuessingGame.rpm
29+
path: ./NumberGuessingGame.rpm
30+
needsRpmTools: true
31+
- name: zip
32+
command: ./package-zip.sh
33+
artifact: NumberGuessingGame-archive.zip
34+
path: ./NumberGuessingGame-archive.zip
35+
- name: windows
36+
command: ./package-win.sh
37+
artifact: NumberGuessingGame-windows.zip
38+
path: ./NumberGuessingGame-windows.zip
39+
- name: macos
40+
command: ./package-macos.sh
41+
artifact: NumberGuessingGame-macos.zip
42+
path: ./NumberGuessingGame-macos.zip
43+
- name: linux
44+
command: ./package-linux.sh
45+
artifact: NumberGuessingGame-linux.tar.xz
46+
path: ./NumberGuessingGame-linux.tar.xz
1647

1748
steps:
1849
- name: Checkout code
@@ -27,38 +58,40 @@ jobs:
2758
- name: Setup Gradle
2859
uses: gradle/actions/setup-gradle@v5
2960

30-
- name: Build JAR with Gradle
31-
run: ./gradlew build
32-
33-
- name: Build Debian package
34-
run: ./package-deb.sh
35-
3661
- name: Install RPM build tools
62+
if: ${{ matrix.target.needsRpmTools }}
3763
run: sudo apt-get update && sudo apt-get install -y rpm
3864

39-
- name: Build Fedora/RPM package
40-
run: ./package-rpm.sh
41-
42-
- name: Build ZIP archive
43-
run: ./package-zip.sh
65+
- name: Build ${{ matrix.target.name }}
66+
run: ${{ matrix.target.command }}
4467

45-
- name: Build Windows package with bundled JRE
46-
run: ./package-win.sh
68+
- name: Upload ${{ matrix.target.name }} artifact
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: ${{ matrix.target.artifact }}
72+
path: ${{ matrix.target.path }}
73+
if-no-files-found: error
4774

48-
- name: Build macOS package with bundled JRE
49-
run: ./package-macos.sh
75+
create-release:
76+
runs-on: ubuntu-latest
77+
needs: build-assets
78+
permissions:
79+
contents: write
5080

51-
- name: Build Linux package with bundled JRE
52-
run: ./package-linux.sh
81+
steps:
82+
- name: Download artifacts
83+
uses: actions/download-artifact@v4
84+
with:
85+
path: dist
5386

5487
- name: Upload release assets
5588
uses: softprops/action-gh-release@v2
5689
with:
5790
files: |
58-
./app/build/libs/app-all.jar
59-
./numberguessinggame.deb
60-
./numberguessinggame.rpm
61-
./archive.zip
62-
./NumberGuessingGame-windows.zip
63-
./NumberGuessingGame-macos.zip
64-
./NumberGuessingGame-linux.tar.xz
91+
dist/NumberGuessingGame.jar/NumberGuessingGame.jar
92+
dist/NumberGuessingGame.deb/NumberGuessingGame.deb
93+
dist/NumberGuessingGame.rpm/NumberGuessingGame.rpm
94+
dist/NumberGuessingGame-archive.zip/NumberGuessingGame-archive.zip
95+
dist/NumberGuessingGame-windows.zip/NumberGuessingGame-windows.zip
96+
dist/NumberGuessingGame-macos.zip/NumberGuessingGame-macos.zip
97+
dist/NumberGuessingGame-linux.tar.xz/NumberGuessingGame-linux.tar.xz

.gitignore

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,20 @@ gradle-app.setting
2727
# Ignore Gradle build output directory
2828
build
2929

30-
archive.zip
31-
numberguessinggame.deb
32-
numberguessinggame-*.rpm
33-
3430
# JRE bundling artifacts
3531
jre-windows/
3632
jre-macos/
3733
jre-linux/
34+
35+
# Unzipped artifacts
3836
NumberGuessingGame-windows/
3937
NumberGuessingGame-macos/
4038
NumberGuessingGame-linux/
39+
40+
# Packaged artifacts
4141
NumberGuessingGame-windows.zip
4242
NumberGuessingGame-macos.zip
4343
NumberGuessingGame-linux.tar.xz
44-
numberguessinggame.rpm
44+
NumberGuessingGame.rpm
45+
NumberGuessingGame.deb
46+
NumberGuessingGame.jar

package-deb.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Script to create a Debian package (.deb) for Number Guessing Game
88
# This package can be installed on Debian-based Linux distributions (Ubuntu, Mint, etc.)
99
# Usage: ./package-deb.sh
10-
# Output: numberguessinggame.deb
10+
# Output: NumberGuessingGame.deb
1111

1212
# Exit immediately if any command fails
1313
set -e
@@ -17,7 +17,7 @@ echo "Building Number Guessing Game Debian package..."
1717
# Clean up any previous build artifacts
1818
echo "Cleaning up previous builds..."
1919
rm -rf debian-package/usr/share/games/numberguessinggame/*
20-
rm -f numberguessinggame.deb
20+
rm -f NumberGuessingGame.deb
2121

2222
# Build the application using Gradle
2323
echo "Building application..."
@@ -40,16 +40,16 @@ chmod 755 debian-package/usr/games/numberguessinggame
4040

4141
# Build the .deb package using dpkg-deb
4242
echo "Building .deb package..."
43-
dpkg-deb --build debian-package numberguessinggame.deb
43+
dpkg-deb --build debian-package NumberGuessingGame.deb
4444

4545
# Display success message with installation instructions
4646
echo ""
47-
echo "✓ Debian package created: numberguessinggame.deb"
47+
echo "✓ Debian package created: NumberGuessingGame.deb"
4848
echo ""
4949
echo "To install, run:"
50-
echo " sudo apt install ./numberguessinggame.deb"
50+
echo " sudo apt install ./NumberGuessingGame.deb"
5151
echo " sudo apt install -f # to install any missing dependencies"
5252
echo ""
5353
echo "After installation, run the game with:"
5454
echo " numberguessinggame"
55-
echo ""
55+
echo ""

package-rpm.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Script to create a Fedora/RPM package (.rpm) for Number Guessing Game
88
# This package can be installed on Fedora, RHEL, CentOS, and other RPM-based distributions
99
# Usage: ./package-rpm.sh
10-
# Output: numberguessinggame-1.0.0-1.noarch.rpm
10+
# Output: NumberGuessingGame.rpm
1111

1212
# Exit immediately if any command fails
1313
set -e
@@ -27,7 +27,7 @@ echo "Cleaning up previous builds..."
2727
rm -rf ~/rpmbuild/RPMS/noarch/numberguessinggame-*.rpm
2828
rm -rf ~/rpmbuild/BUILD/numberguessinggame-*
2929
rm -rf ~/rpmbuild/BUILDROOT/numberguessinggame-*
30-
rm -f numberguessinggame.rpm
30+
rm -f NumberGuessingGame.rpm
3131

3232
# Build the application using Gradle
3333
echo "Building application..."
@@ -55,18 +55,18 @@ rpmbuild -bb ~/rpmbuild/SPECS/numberguessinggame.spec
5555

5656
# Copy the built RPM to the current directory
5757
echo "Copying RPM package to current directory..."
58-
cp ~/rpmbuild/RPMS/noarch/numberguessinggame-*.rpm ./numberguessinggame.rpm
58+
cp ~/rpmbuild/RPMS/noarch/numberguessinggame-*.rpm ./NumberGuessingGame.rpm
5959

6060
# Display success message with installation instructions
6161
echo ""
62-
echo "✓ RPM package created: $(ls numberguessinggame.rpm)"
62+
echo "✓ RPM package created: $(ls NumberGuessingGame.rpm)"
6363
echo ""
6464
echo "To install on Fedora/RHEL/CentOS, run:"
65-
echo " sudo dnf install ./numberguessinggame.rpm"
65+
echo " sudo dnf install ./NumberGuessingGame.rpm"
6666
echo ""
6767
echo "Or on older systems:"
68-
echo " sudo yum install ./numberguessinggame.rpm"
68+
echo " sudo yum install ./NumberGuessingGame.rpm"
6969
echo ""
7070
echo "After installation, run the game with:"
7171
echo " numberguessinggame"
72-
echo ""
72+
echo ""

package-zip.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# Clean up any previous builds
1111
rm -rf NumberGuessingGame
1212
rm -rf temp
13-
rm -f archive.zip
13+
rm -f NumberGuessingGame-archive.zip
1414

1515
# Build the application
1616
cd app
@@ -28,7 +28,7 @@ cp -r README.md NumberGuessingGame/README.txt
2828
cp -r LICENSE NumberGuessingGame/LICENSE
2929

3030
# Create the ZIP archive with maximum compression
31-
zip -9 -r archive.zip NumberGuessingGame/
31+
zip -9 -r NumberGuessingGame-archive.zip NumberGuessingGame/
3232

3333
# Clean up temporary directory
34-
rm -rf NumberGuessingGame
34+
rm -rf NumberGuessingGame

0 commit comments

Comments
 (0)