Skip to content

Commit b7e8cd3

Browse files
committed
try fixing build.yml #2
1 parent f63ce37 commit b7e8cd3

File tree

1 file changed

+69
-123
lines changed

1 file changed

+69
-123
lines changed

.github/workflows/build.yml

Lines changed: 69 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build
1+
name: Build All Versions
22

33
on:
44
push:
@@ -8,148 +8,94 @@ on:
88
workflow_dispatch:
99

1010
jobs:
11-
build:
11+
build-all:
1212
runs-on: ubuntu-latest
13-
continue-on-error: true
14-
strategy:
15-
fail-fast: false
16-
matrix:
17-
include:
18-
# MC 1.16.x requires Java 8 or 11
19-
- version: "1.16"
20-
java: "11"
21-
- version: "1.16.1"
22-
java: "11"
23-
- version: "1.16.2"
24-
java: "11"
25-
- version: "1.16.3"
26-
java: "11"
27-
- version: "1.16.4"
28-
java: "11"
29-
- version: "1.16.5"
30-
java: "11"
31-
# MC 1.17.x requires Java 16
32-
- version: "1.17"
33-
java: "17"
34-
- version: "1.17.1"
35-
java: "17"
36-
# MC 1.18.x requires Java 17
37-
- version: "1.18"
38-
java: "17"
39-
- version: "1.18.1"
40-
java: "17"
41-
- version: "1.18.2"
42-
java: "17"
43-
# MC 1.19.x requires Java 17
44-
- version: "1.19"
45-
java: "17"
46-
- version: "1.19.1"
47-
java: "17"
48-
- version: "1.19.2"
49-
java: "17"
50-
- version: "1.19.3"
51-
java: "17"
52-
- version: "1.19.4"
53-
java: "17"
54-
# MC 1.20.x requires Java 17
55-
- version: "1.20"
56-
java: "17"
57-
- version: "1.20.1"
58-
java: "17"
59-
- version: "1.20.2"
60-
java: "17"
61-
- version: "1.20.4"
62-
java: "17"
63-
# MC 1.20.5+ requires Java 21
64-
- version: "1.20.6"
65-
java: "21"
66-
- version: "1.21"
67-
java: "21"
68-
- version: "1.21.1"
69-
java: "21"
70-
- version: "1.21.2"
71-
java: "21"
72-
- version: "1.21.3"
73-
java: "21"
74-
- version: "1.21.4"
75-
java: "21"
76-
- version: "1.21.5"
77-
java: "21"
78-
- version: "1.21.8"
79-
java: "21"
8013

81-
name: Build MC ${{ matrix.version }}
8214
steps:
8315
- uses: actions/checkout@v4
8416

85-
- name: Set up JDK ${{ matrix.java }}
17+
- name: Set up JDK 21
8618
uses: actions/setup-java@v4
8719
with:
88-
java-version: ${{ matrix.java }}
20+
java-version: '21'
8921
distribution: 'temurin'
9022

9123
- name: Grant execute permission for gradlew
9224
run: chmod +x gradlew
9325

94-
- name: Setup Gradle
95-
uses: gradle/actions/setup-gradle@v3
96-
with:
97-
cache-disabled: true # Disable cache to avoid issues
98-
99-
- name: Build with Gradle for MC ${{ matrix.version }}
100-
id: build
101-
continue-on-error: true
26+
- name: Build all versions
10227
run: |
103-
# Retry logic for downloads
104-
for i in 1 2 3; do
105-
echo "Attempt $i for MC ${{ matrix.version }}"
28+
mkdir -p all-builds
29+
30+
# List of all versions
31+
VERSIONS=(
32+
"1.16" "1.16.1" "1.16.2" "1.16.3" "1.16.4" "1.16.5"
33+
"1.17" "1.17.1" "1.18" "1.18.1" "1.18.2"
34+
"1.19" "1.19.1" "1.19.2" "1.19.3" "1.19.4"
35+
"1.20" "1.20.1" "1.20.2" "1.20.4" "1.20.6"
36+
"1.21" "1.21.1" "1.21.2" "1.21.3" "1.21.4" "1.21.5" "1.21.8"
37+
)
38+
39+
FAILED=""
40+
SUCCESS_COUNT=0
41+
42+
for VERSION in "${VERSIONS[@]}"; do
43+
echo "========================================="
44+
echo "Building MC $VERSION"
45+
echo "========================================="
46+
47+
BUILD_SUCCESS=false
48+
for attempt in 1 2 3; do
49+
echo "Attempt $attempt for MC $VERSION"
10650
107-
if ./gradlew "Set active project to ${{ matrix.version }}" --stacktrace; then
108-
if ./gradlew build --stacktrace; then
109-
echo "Build successful"
110-
echo "build_status=success" >> $GITHUB_OUTPUT
51+
if ./gradlew "Set active project to $VERSION" --no-daemon && \
52+
./gradlew build --no-daemon; then
53+
cp build/libs/*.jar all-builds/ 2>/dev/null || true
54+
./gradlew clean --no-daemon
55+
BUILD_SUCCESS=true
56+
SUCCESS_COUNT=$((SUCCESS_COUNT + 1))
57+
echo "✓ Successfully built MC $VERSION"
11158
break
11259
fi
113-
fi
11460
115-
if [ $i -lt 3 ]; then
116-
echo "Retrying in 10 seconds..."
117-
sleep 10
118-
./gradlew clean --stacktrace || true
119-
else
120-
echo "Build failed after 3 attempts"
121-
echo "build_status=failed" >> $GITHUB_OUTPUT
61+
if [ $attempt -lt 3 ]; then
62+
echo "Build failed, retrying in 10 seconds..."
63+
sleep 10
64+
./gradlew clean --no-daemon || true
65+
fi
66+
done
67+
68+
if [ "$BUILD_SUCCESS" = false ]; then
69+
echo "✗ Failed to build MC $VERSION after 3 attempts"
70+
FAILED="$FAILED $VERSION"
12271
fi
72+
73+
echo ""
12374
done
75+
76+
# Reset to default version
77+
./gradlew "Reset active project" --no-daemon || true
78+
79+
echo "========================================="
80+
echo "Build Summary"
81+
echo "========================================="
82+
echo "Successfully built: $SUCCESS_COUNT/${#VERSIONS[@]} versions"
83+
echo "JAR files created: $(ls -1 all-builds/*.jar 2>/dev/null | wc -l)"
84+
85+
if [ -n "$FAILED" ]; then
86+
echo "Failed versions:$FAILED"
87+
echo "::warning::Some versions failed to build:$FAILED"
88+
fi
89+
90+
# List all built files
91+
echo ""
92+
echo "Built files:"
93+
ls -la all-builds/*.jar 2>/dev/null || echo "No JAR files found"
12494
125-
- name: Upload artifacts
126-
if: steps.build.outputs.build_status == 'success'
127-
uses: actions/upload-artifact@v4
128-
with:
129-
name: GreenTextMod-${{ matrix.version }}
130-
path: build/libs/*.jar
131-
if-no-files-found: ignore
132-
133-
collect-artifacts:
134-
needs: build
135-
runs-on: ubuntu-latest
136-
if: always()
137-
steps:
138-
- name: Download all artifacts
139-
uses: actions/download-artifact@v4
140-
with:
141-
path: artifacts
142-
continue-on-error: true
143-
144-
- name: Organize artifacts
145-
run: |
146-
mkdir -p all-versions
147-
find artifacts -name "*.jar" -exec cp {} all-versions/ \; 2>/dev/null || true
148-
echo "Found $(ls -1 all-versions/*.jar 2>/dev/null | wc -l) jar files"
149-
150-
- name: Upload combined artifacts
151-
if: ${{ hashFiles('all-versions/*.jar') != '' }}
95+
- name: Upload all builds
15296
uses: actions/upload-artifact@v4
15397
with:
15498
name: GreenTextMod-all-versions
155-
path: all-versions/*.jar
99+
path: all-builds/*.jar
100+
if-no-files-found: warn
101+
retention-days: 30

0 commit comments

Comments
 (0)