@@ -41,62 +41,11 @@ jobs:
4141 ref : build-state
4242 fetch-depth : 0
4343
44- - name : Fetch new builds
45- id : fetch
46- run : |
47- set -euo pipefail
48- echo "Fetching builds from PaperMC API..."
49- if ! curl -fsSL "https://fill.papermc.io/v3/projects/velocity/versions/${{ vars.PAPERMC_VELOCITY_VERSION }}/builds" -o builds.json; then
50- echo "::error::Failed to fetch builds.json from PaperMC API."
51- exit 1
52- fi
53- if ! jq empty builds.json 2>/dev/null; then
54- echo "::error::Invalid JSON received from API."
55- cat builds.json
56- exit 1
57- fi
58- echo "Builds successfully fetched."
59- - name : Determine new builds
44+ - name : Fetch builds to matrix
6045 id : set-matrix
61- run : |
62- set -euo pipefail
63-
64- if [ ! -f builds.json ]; then
65- echo "::error::Missing builds.json file. Previous step may have failed."
66- exit 1
67- fi
68-
69- echo "Extracting build IDs and download URLs..."
70- jq -c '.[] | {id: .id, url: .downloads["server:default"].url}' builds.json > all_builds.txt
71-
72- touch .last_builds
73- sort -u .last_builds -o .last_builds || true
74-
75- NEW_BUILDS_FILE=new_builds.txt
76- > "$NEW_BUILDS_FILE"
77- while read line; do
78- ID=$(echo "$line" | jq -r '.id')
79- if ! grep -qx "$ID" .last_builds; then
80- echo "$line" >> "$NEW_BUILDS_FILE"
81- fi
82- done < all_builds.txt
83-
84- if [ ! -s "$NEW_BUILDS_FILE" ]; then
85- echo "No new builds found."
86- echo "matrix=[]" >> "$GITHUB_OUTPUT"
87- exit 0
88- fi
89-
90- echo "New builds detected:"
91- cat "$NEW_BUILDS_FILE"
92-
93- MATRIX_JSON=$(jq -c -s '.' "$NEW_BUILDS_FILE")
94- echo "matrix=$MATRIX_JSON" >> "$GITHUB_OUTPUT"
95-
96- while read line; do
97- echo "$line" | jq -r '.id' >> .last_builds
98- done < "$NEW_BUILDS_FILE"
99- sort -u .last_builds -o .last_builds
46+ uses : actions/github-script@v8
47+ with :
48+ script : await require('.github/workflows/scripts/fetch-builds.js')();
10049
10150 - name : Commit updated .last_builds
10251 if : steps.set-matrix.outputs.matrix != '[]'
@@ -216,7 +165,7 @@ jobs:
216165 FIRST_LINE=$(timeout "$RCON_TIMEOUT" ./tools/rcon-cli --host 127.0.0.1 --port 25575 --password PASSWORD velocity info | tee rcon.log | head -n 1)
217166 FIRST_LINE=$(echo "$FIRST_LINE" | sed -r 's/\x1B\[[0-9;]*[mK]//g' | tr -d '\r' | sed 's/^[[:space:]]*//; s/[[:space:]]*$//')
218167
219- VERSION="${{ vars.PAPERMC_VELOCITY_VERSION }}"
168+ VERSION="${{ matrix.version }}"
220169 BUILD="${{ matrix.id }}"
221170 if echo "$FIRST_LINE" | grep -E -q "^Velocity ${VERSION} \(git-[0-9a-fA-F]+-b${BUILD}\)$"; then
222171 echo "RCON test succeeded! First line matches pattern."
@@ -251,7 +200,7 @@ jobs:
251200 # Test failure report
252201
253202 **Velocity Build ID:** ${{ matrix.id }}
254- **Velocity Version:** ${{ vars.PAPERMC_VELOCITY_VERSION }}
203+ **Velocity Version:** ${{ matrix.version }}
255204 **Velocity Build URL:** [Download Link](${{ matrix.url }})
256205 **Velocircon Release:** ${{ needs.prepare.outputs.latest_release }}
257206
0 commit comments