Skip to content

Commit 29a9868

Browse files
committed
update with java versions
1 parent 5605d70 commit 29a9868

1 file changed

Lines changed: 11 additions & 218 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 11 additions & 218 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,26 @@
1-
# Build the mod for every Stonecutter variant, then launch-test the built jars
2-
# on EVERY supported Minecraft version concurrently: each launch job boots a
3-
# real production Fabric client under XVFB with the covering variant's jar and
4-
# version-matched runtime mods, enters a survival singleplayer world with the
5-
# HUD active, screenshots it, and fails if anything crashes on the way.
6-
# The screenshot report job embeds all screenshots in a PR comment (via the
7-
# ci-screenshots branch) and in the job summary, and the modrinth bundle job
8-
# packages the release jars with their per-jar Minecraft version lists.
9-
#
10-
# Both job matrices are generated from supported-versions.json — add a version
11-
# there (see README) and every job picks it up.
12-
131
name: build
142
on: push
153

16-
# contents: write lets the screenshot report push to the ci-screenshots branch,
17-
# pull-requests: write lets it comment on the associated pull request.
184
permissions:
195
contents: write
206
pull-requests: write
217

228
jobs:
23-
matrices:
24-
name: compute matrices
25-
runs-on: ubuntu-24.04
26-
outputs:
27-
build: ${{ steps.gen.outputs.build }}
28-
launch: ${{ steps.gen.outputs.launch }}
29-
steps:
30-
- name: checkout repository
31-
uses: actions/checkout@v6
32-
33-
- name: generate matrices from supported-versions.json
34-
id: gen
35-
run: bash .github/scripts/generate-matrices.sh
36-
379
build:
3810
name: build mc${{ matrix.mc }}
3911
runs-on: ubuntu-24.04
40-
needs: matrices
4112
strategy:
4213
fail-fast: false
4314
matrix:
44-
include: ${{ fromJson(needs.matrices.outputs.build) }}
15+
include:
16+
- mc: "1.21"
17+
java: "21"
18+
- mc: "1.21.6"
19+
java: "21"
20+
- mc: "26.1"
21+
java: "25"
22+
- mc: "26.2"
23+
java: "25"
4524
steps:
4625
- name: checkout repository
4726
uses: actions/checkout@v6
@@ -56,202 +35,16 @@ jobs:
5635
distribution: 'microsoft'
5736

5837
- name: setup gradle with dependency caching
59-
# Caches Gradle dependencies between runs (written on the default
60-
# branch, read everywhere), so a flaky maven rarely has to be hit.
6138
uses: gradle/actions/setup-gradle@v6
6239

6340
- name: make gradle wrapper executable
6441
run: chmod +x ./gradlew
6542

6643
- name: build :${{ matrix.mc }}:build
67-
# retry.sh reruns the build on transient failures (flaky maven downloads).
68-
run: bash .github/scripts/retry.sh ./gradlew :${{ matrix.mc }}:build --stacktrace
44+
run: ./gradlew :${{ matrix.mc }}:build
6945

7046
- name: upload jar
7147
uses: actions/upload-artifact@v7
7248
with:
7349
name: betterhud-mc${{ matrix.mc }}
74-
path: versions/${{ matrix.mc }}/build/libs/*.jar
75-
76-
# One job per supported Minecraft version (not per build variant): the
77-
# 1.21 variant jar is launch-tested on 1.21-1.21.5, the 1.21.6 variant jar
78-
# on 1.21.6-1.21.11, and so on.
79-
#
80-
# pregen_world marks versions whose Fabric API has no client gametest module
81-
# (before 1.21.4): for those a vanilla world save is generated first with
82-
# that version's dedicated server, and the client auto-joins it instead of
83-
# creating one through the gametest API.
84-
launch-test:
85-
name: launch mc${{ matrix.mc }}
86-
runs-on: ubuntu-24.04
87-
needs: matrices
88-
timeout-minutes: 40
89-
strategy:
90-
fail-fast: false
91-
matrix:
92-
include: ${{ fromJson(needs.matrices.outputs.launch) }}
93-
steps:
94-
- name: checkout repository
95-
uses: actions/checkout@v6
96-
97-
- name: validate gradle wrapper
98-
uses: gradle/actions/wrapper-validation@v6
99-
100-
- name: setup jdk ${{ matrix.java }}
101-
uses: actions/setup-java@v5
102-
with:
103-
java-version: ${{ matrix.java }}
104-
distribution: 'microsoft'
105-
106-
- name: setup gradle with dependency caching
107-
uses: gradle/actions/setup-gradle@v6
108-
109-
- name: make gradle wrapper executable
110-
run: chmod +x ./gradlew
111-
112-
- name: install xvfb
113-
# Provides a virtual display so the Minecraft client can launch headlessly.
114-
run: sudo apt-get update && sudo apt-get install -y xvfb
115-
116-
- name: generate singleplayer test world
117-
if: ${{ matrix.pregen_world }}
118-
run: bash .github/scripts/generate-test-world.sh ${{ matrix.mc }}
119-
120-
- name: launch minecraft ${{ matrix.mc }} with mod
121-
# Two attempts (not the default three): a real game crash fails both,
122-
# and a second full launch still fits the 40-minute job timeout.
123-
env:
124-
RETRY_ATTEMPTS: '2'
125-
run: bash .github/scripts/retry.sh ./gradlew :launchtest:runProductionClientGameTest -PtestMcVersion=${{ matrix.mc }} --stacktrace
126-
127-
- name: check survival world screenshot was taken
128-
run: test -n "$(find launchtest/run/screenshots -name '*betterhud-survival-world.png' -print -quit 2>/dev/null)"
129-
130-
- name: upload screenshots
131-
# Consumed by the screenshot-report job below.
132-
if: always()
133-
uses: actions/upload-artifact@v7
134-
with:
135-
name: launch-screenshots-mc${{ matrix.mc }}
136-
path: launchtest/run/screenshots/
137-
if-no-files-found: ignore
138-
139-
- name: upload game logs
140-
if: always()
141-
uses: actions/upload-artifact@v7
142-
with:
143-
name: launch-logs-mc${{ matrix.mc }}
144-
path: launchtest/run/logs/
145-
if-no-files-found: ignore
146-
147-
screenshot-report:
148-
name: screenshot report
149-
runs-on: ubuntu-24.04
150-
needs: launch-test
151-
if: ${{ always() }}
152-
steps:
153-
- name: checkout repository
154-
uses: actions/checkout@v6
155-
156-
- name: publish screenshots to the ci-screenshots branch
157-
env:
158-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159-
run: bash .github/scripts/publish-screenshots.sh
160-
161-
- name: post screenshot grid to pull request and job summary
162-
uses: actions/github-script@v8
163-
with:
164-
script: |
165-
const fs = require('fs');
166-
167-
const versions = Object.keys(JSON.parse(fs.readFileSync('supported-versions.json', 'utf8')));
168-
const dir = `screenshots-publish/${context.sha}`;
169-
const base = `https://raw.githubusercontent.com/${context.repo.owner}/${context.repo.repo}/ci-screenshots/${context.sha}`;
170-
171-
const cells = versions.map(v => {
172-
const file = `mc-${v}-survival.png`;
173-
const ok = fs.existsSync(`${dir}/${file}`);
174-
return ok
175-
? `<td align="center"><b>${v}</b><br><a href="${base}/${file}"><img src="${base}/${file}" width="200" alt="BetterHUD on Minecraft ${v}"></a></td>`
176-
: `<td align="center"><b>${v}</b><br>❌ no screenshot</td>`;
177-
});
178-
let rows = '';
179-
for (let i = 0; i < cells.length; i += 4) {
180-
rows += `<tr>${cells.slice(i, i + 4).join('')}</tr>\n`;
181-
}
182-
183-
const marker = '<!-- betterhud-launch-screenshots -->';
184-
const body = [
185-
marker,
186-
`The game launched and entered a survival singleplayer world with the HUD active, on every supported Minecraft version, for \`${context.sha.slice(0, 7)}\`. A ❌ means that version's launch test did not produce a screenshot — check its job. Title-screen screenshots and game logs are in the run artifacts.`,
187-
'',
188-
`<table>\n${rows}</table>`,
189-
].join('\n');
190-
191-
// Always show the grid in the job summary, even without a PR.
192-
await core.summary.addRaw(body).write();
193-
194-
const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
195-
owner: context.repo.owner,
196-
repo: context.repo.repo,
197-
commit_sha: context.sha,
198-
});
199-
const pr = prs.find(p => p.state === 'open');
200-
if (!pr) {
201-
core.info('No open pull request for this commit, skipping comment');
202-
return;
203-
}
204-
205-
// Keep a single comment up to date instead of posting one per push.
206-
const { data: comments } = await github.rest.issues.listComments({
207-
owner: context.repo.owner, repo: context.repo.repo,
208-
issue_number: pr.number, per_page: 100,
209-
});
210-
const existing = comments.find(c => c.body && c.body.includes(marker));
211-
if (existing) {
212-
await github.rest.issues.updateComment({
213-
owner: context.repo.owner, repo: context.repo.repo,
214-
comment_id: existing.id, body,
215-
});
216-
} else {
217-
await github.rest.issues.createComment({
218-
owner: context.repo.owner, repo: context.repo.repo,
219-
issue_number: pr.number, body,
220-
});
221-
}
222-
223-
# Builds every variant and bundles the release jars together with UPLOAD.md,
224-
# which lists exactly which Minecraft versions to select for each jar when
225-
# uploading to Modrinth. Download the "modrinth-upload" artifact and follow it.
226-
modrinth-bundle:
227-
name: modrinth bundle
228-
runs-on: ubuntu-24.04
229-
steps:
230-
- name: checkout repository
231-
uses: actions/checkout@v6
232-
233-
- name: validate gradle wrapper
234-
uses: gradle/actions/wrapper-validation@v6
235-
236-
- name: setup jdk 21 and 25
237-
uses: actions/setup-java@v5
238-
with:
239-
java-version: |
240-
21
241-
25
242-
distribution: 'microsoft'
243-
244-
- name: setup gradle with dependency caching
245-
uses: gradle/actions/setup-gradle@v6
246-
247-
- name: make gradle wrapper executable
248-
run: chmod +x ./gradlew
249-
250-
- name: build all variants and write the upload guide
251-
run: bash .github/scripts/retry.sh ./gradlew modrinthBundle --stacktrace "-Porg.gradle.java.installations.paths=$JAVA_HOME_21_X64,$JAVA_HOME_25_X64"
252-
253-
- name: upload modrinth bundle
254-
uses: actions/upload-artifact@v7
255-
with:
256-
name: modrinth-upload
257-
path: build/modrinth/
50+
path: versions/${{ matrix.mc }}/build/libs/*.jar

0 commit comments

Comments
 (0)