-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaction.yml
134 lines (122 loc) · 4.81 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: MC-Runtime-Test
description: Runs the MC client inside your CI
author: HeadlessHQ
branding:
icon: play
color: green
inputs:
mc:
description: Minecraft version to run
required: true
modloader:
description: Modloader to install (forge, neoforge, fabric)
required: true
regex:
description: Regex to match the modloader jar (i.e. .*fabric.*)
required: true
java:
description: Java version to use (8, 16, 17, 21)
required: true
dummy-assets:
description: Use dummy assets during testing
default: "true"
mc-runtime-test:
description: MC-Runtime-Test jar to download (none, lexforge, neoforge, fabric)
required: true
xvfb:
description: Runs the game with Xvfb (if false, add the -lwjgl argument)
default: "true"
headlessmc-command:
description: Command-line arguments for HeadlessMC
default: '--jvm "-Djava.awt.headless=true"'
fabric-api:
description: Fabric API version to download (e.g. 0.97.0) or none
default: "none"
fabric-gametest-api:
description: Fabric GameTest API version (e.g. 1.3.5+85d85a934f) or none
default: "none"
download-hmc:
description: Download HeadlessMC
default: "true"
hmc-version:
description: HeadlessMC version
default: "2.4.1"
cache-mc:
description: Cache .minecraft
default: "true"
runs:
using: composite
steps:
- name: Bootstrap HeadlessMC
run: |
mkdir -p HeadlessMC run/mods
cat <<EOF >> HeadlessMC/config.properties
hmc.java.versions=$JAVA_HOME/bin/java
hmc.gamedir=$PWD/run
hmc.offline=true
hmc.rethrow.launch.exceptions=true
hmc.exit.on.failed.command=true
EOF
shell: bash
- if: inputs.dummy-assets == 'true'
name: Configure Dummy Assets
run: echo hmc.assets.dummy=true >> HeadlessMC/config.properties
shell: bash
- if: inputs.download-hmc == 'true'
name: Get HeadlessMC
uses: robinraju/release-downloader@a96f54c1b5f5e09e47d9504526e96febd949d4c2 # v1.11
with:
repository: 3arthqu4ke/headlessmc
tag: ${{ inputs.hmc-version }}
fileName: headlessmc-launcher-${{ inputs.hmc-version }}.jar
- if: inputs.cache-mc == 'true'
name: Cache Minecraft
uses: useblacksmith/cache@c5fe29eb0efdf1cf4186b9f7fcbbcbc0cf025662 # v5
with:
path: /home/runner/.minecraft
key: hmc-${{ inputs.modloader }}-${{ inputs.mc }}
- name: Download ${{ inputs.modloader }}-${{ inputs.mc }}
run: |
if [ ! -f "$HOME/.minecraft/versions/${{ inputs.mc }}/${{ inputs.mc }}.json" ]; then
java -jar headlessmc-launcher-${{ inputs.hmc-version }}.jar --command download ${{ inputs.mc }}
java -jar headlessmc-launcher-${{ inputs.hmc-version }}.jar --command ${{ inputs.modloader }} ${{ inputs.mc }} --java ${{ inputs.java }}
fi
shell: bash
- id: get-mcrt
if: inputs.mc-runtime-test != 'none'
name: Get mc-runtime-test
uses: robinraju/release-downloader@a96f54c1b5f5e09e47d9504526e96febd949d4c2 # v1.11
with:
repository: headlesshq/mc-runtime-test
tag: "3.0.0" # x-release-please-version
fileName: 'mc-runtime-test-${{ inputs.mc }}-*-${{ inputs.mc-runtime-test }}-release.jar'
out-file-path: run/mods
- if: inputs.fabric-api != 'none'
name: Download fabric-api v${{ inputs.fabric-api }}
run: >
wget -O run/mods/fabric-api-${{ inputs.fabric-api }}+${{ inputs.mc }}.jar
https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api/${{ inputs.fabric-api }}+${{ inputs.mc }}/fabric-api-${{ inputs.fabric-api }}+${{ inputs.mc }}.jar
shell: bash
- if: inputs.fabric-gametest-api != 'none'
name: Download fabric-gametest-api v${{ inputs.fabric-gametest-api }}
run: >
wget -O run/mods/fabric-gametest-api-v1-${{ inputs.fabric-gametest-api }}.jar
https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-gametest-api-v1/${{ inputs.fabric-gametest-api }}/fabric-gametest-api-v1-${{ inputs.fabric-gametest-api }}.jar
shell: bash
- name: Configure game
run: |
cat <<EOF >> run/options.txt
onboardAccessibility:false
pauseOnLostFocus:false
EOF
shell: bash
- if: inputs.xvfb == 'true'
name: Run game with xvfb
run: | # TODO: install xrandr conditionally per #22
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y x11-xserver-utils
xvfb-run java -Dhmc.check.xvfb=true -jar headlessmc-launcher-${{ inputs.hmc-version }}.jar --command launch ${{ inputs.regex }} -regex ${{ inputs.headlessmc-command }}
shell: bash
- if: inputs.xvfb != 'true'
name: Run game
run: java -jar headlessmc-launcher-${{ inputs.hmc-version }}.jar --command launch ${{ inputs.regex }} -regex ${{ inputs.headlessmc-command }}
shell: bash