Skip to content

Commit 72e6a4d

Browse files
CI: Improve build script to use jq
1 parent 2137a48 commit 72e6a4d

1 file changed

Lines changed: 12 additions & 23 deletions

File tree

build.sh

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,14 @@ install_dxmt_runtime() {
137137
exit 1
138138
fi
139139

140-
dxmt_tag=$(printf '%s\n' "$release_json" | sed -n 's/.*"tag_name":[[:space:]]*"\([^"]*\)".*/\1/p' | head -n 1)
140+
if ! command -v jq &> /dev/null; then
141+
echo "ERROR: jq is required but not installed. Please install jq to continue."
142+
exit 1
143+
fi
141144

142-
dxmt_url=$(printf '%s\n' "$release_json" \
143-
| sed -n 's/.*"browser_download_url":[[:space:]]*"\([^"]*\)".*/\1/p' \
144-
| grep -E 'builtin.*\.tar\.gz$' \
145-
| head -n 1)
145+
dxmt_tag=$(printf '%s\n' "$release_json" | jq -r '.tag_name')
146146

147-
if [ -z "$dxmt_url" ]; then
148-
dxmt_url=$(printf '%s\n' "$release_json" \
149-
| sed -n 's/.*"browser_download_url":[[:space:]]*"\([^"]*\)".*/\1/p' \
150-
| grep -E '\.tar\.gz$' \
151-
| head -n 1)
152-
fi
147+
dxmt_url=$(printf '%s\n' "$release_json" | jq -r '.assets[].browser_download_url | select(test("builtin.*\\.tar\\.gz$"))' | head -n 1)
153148

154149
if [ -z "$dxmt_url" ]; then
155150
echo "ERROR: Could not find a DXMT .tar.gz asset in latest release"
@@ -209,20 +204,14 @@ download_wine_runtime() {
209204
exit 1
210205
fi
211206

212-
wine_tag=$(printf '%s\n' "$release_json" | sed -n 's/.*"tag_name":[[:space:]]*"\([^"]*\)".*/\1/p' | head -n 1)
207+
if ! command -v jq &> /dev/null; then
208+
echo "ERROR: jq is required but not installed. Please install jq to continue."
209+
exit 1
210+
fi
213211

214-
# Prefer wine-staging osx64 builds; fall back to any .tar.xz asset.
215-
wine_url=$(printf '%s\n' "$release_json" \
216-
| sed -n 's/.*"browser_download_url":[[:space:]]*"\([^"]*\)".*/\1/p' \
217-
| grep -E 'wine-staging.*osx64.*\.tar\.xz$' \
218-
| head -n 1)
212+
wine_tag=$(printf '%s\n' "$release_json" | jq -r '.tag_name')
219213

220-
if [ -z "$wine_url" ]; then
221-
wine_url=$(printf '%s\n' "$release_json" \
222-
| sed -n 's/.*"browser_download_url":[[:space:]]*"\([^"]*\)".*/\1/p' \
223-
| grep -E '\.tar\.xz$' \
224-
| head -n 1)
225-
fi
214+
wine_url=$(printf '%s\n' "$release_json" | jq -r '.assets[].browser_download_url | select(test("wine-staging.*osx64.*\\.tar\\.xz$"))' | head -n 1)
226215

227216
if [ -z "$wine_url" ]; then
228217
echo "ERROR: Could not find a Wine .tar.xz asset in latest Gcenx release"

0 commit comments

Comments
 (0)