Skip to content

Commit 099e6ff

Browse files
committed
Fix build script
1 parent b1749c4 commit 099e6ff

2 files changed

Lines changed: 42 additions & 14 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,43 @@ jobs:
2727
distribution: temurin
2828
java-version: "22"
2929

30-
- name: Grant execute permission for gradlew
31-
run: chmod +x ./gradlew
30+
- name: Make gradlew executable (if present)
31+
run: |
32+
if [ -f "./gradlew" ]; then
33+
chmod +x ./gradlew
34+
fi
3235
33-
# Generic KMP build for all JS browser targets
34-
- name: Build all JS browser distributions
36+
- name: Build all web apps (per subproject)
3537
run: |
36-
./gradlew jsBrowserDistribution --continue
38+
set -e
39+
40+
# Optional: ensure jq exists (Ubuntu images usually have it already)
41+
if ! command -v jq >/dev/null 2>&1; then
42+
sudo apt-get update
43+
sudo apt-get install -y jq
44+
fi
45+
46+
# Find all webapp.json files
47+
while IFS= read -r meta; do
48+
app_dir="$(dirname "$meta")"
49+
50+
build_cmd="$(jq -r '.build.command // empty' "$meta")"
51+
52+
if [ -z "$build_cmd" ]; then
53+
echo "[INFO] $meta has no build.command, skipping build step."
54+
continue
55+
fi
56+
57+
echo "[INFO] Building app in $app_dir with: $build_cmd"
58+
59+
(
60+
cd "$app_dir"
61+
# Execute the command as defined in webapp.json
62+
set -e
63+
eval "$build_cmd"
64+
)
65+
66+
done < <(find . -name webapp.json -print)
3767
3868
- name: Prepare static site folder (scan apps & generate index)
3969
run: |
@@ -71,12 +101,11 @@ jobs:
71101
description = meta.get("description", "")
72102
screenshot_rel = meta.get("screenshot")
73103
74-
# NEW: allow distDirs list, fallback to single distDir string for compatibility
104+
# Allow distDirs list, fallback to single distDir
75105
dist_dirs_rel = []
76-
77-
if "distDirs" in meta and isinstance(meta["distDirs"], list):
106+
if isinstance(meta.get("distDirs"), list):
78107
dist_dirs_rel = meta["distDirs"]
79-
elif "distDir" in meta and isinstance(meta["distDir"], str):
108+
elif isinstance(meta.get("distDir"), str):
80109
dist_dirs_rel = [meta["distDir"]]
81110
82111
if not app_id:
@@ -89,7 +118,7 @@ jobs:
89118
90119
project_root = dirpath
91120
92-
# Choose the first distDir that contains index.html
121+
# Choose first distDir that contains index.html
93122
chosen_dist_dir = None
94123
for rel in dist_dirs_rel:
95124
cand_dist = os.path.join(project_root, rel)
@@ -99,7 +128,7 @@ jobs:
99128
break
100129
101130
if not chosen_dist_dir:
102-
print(f"[INFO] No index.html found in any distDir for app {app_id}, skipping.")
131+
print(f"[INFO] No index.html in any distDir for {app_id}, skipping.")
103132
continue
104133
105134
print(f"[OK] Using dist dir {chosen_dist_dir} for app {app_id}")

SinusApproximator/webapp.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
"composeApp/build/processedResources/wasmJs/main"
88
],
99
"build": {
10-
"type": "gradle",
11-
"task": ":composeApp:wasmJsBrowserProductionWebpack",
12-
"command": "./gradlew --stacktrace --no-daemon :composeApp:wasmJsBrowserProductionWebpack"
10+
"command": "./gradlew :composeApp:wasmJsBrowserProductionWebpack",
11+
"description": "Builds the JS browser distribution for Foo from the repo root."
1312
},
1413
"screenshot": "docs/screenshots/wasm.png"
1514
}

0 commit comments

Comments
 (0)