-
-
Notifications
You must be signed in to change notification settings - Fork 12
167 lines (139 loc) · 5.49 KB
/
hugo.yml
File metadata and controls
167 lines (139 loc) · 5.49 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# .github/workflows/hugo.yml
name: Deploy Hugo site to Pages
on:
push:
branches: ["main"]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.128.0
steps:
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Install Dart Sass
run: sudo snap install dart-sass
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
# ---------------------------
# Build Kotlin/WASM app
# ---------------------------
- name: Setup Java (Temurin 21)
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "21"
- name: Setup Gradle cache
uses: gradle/actions/setup-gradle@v4
- name: Setup Emscripten (emsdk)
uses: mymindstorm/setup-emsdk@v14
with:
emsdk-version: latest
- name: Build Llamatik WASM artifacts
run: |
chmod +x ./gradlew
# 1) Build the native wasm engine and copy it into library wasm resources
./gradlew :library:copyLlamatikWasmToResources
# 2) Build the browser distribution (Compose WASM output)
./gradlew :composeApp:wasmJsBrowserDistribution
- name: Copy WASM app into Hugo static (/prompt)
run: |
set -euo pipefail
# Kotlin/WASM distribution paths can vary a bit by Kotlin plugin version.
# We find the folder that contains index.html under composeApp/build/dist.
IDX="$(find composeApp/build/dist -type f -name index.html | head -n 1 || true)"
if [ -z "${IDX}" ]; then
echo "ERROR: Could not locate composeApp WASM distribution output (index.html not found)." >&2
echo "Listing composeApp/build/dist for debugging:" >&2
find composeApp/build/dist -maxdepth 6 -type d -print || true
exit 1
fi
DIST_DIR="$(dirname "${IDX}")"
echo "Using WASM dist folder: ${DIST_DIR}"
OUT_DIR="homepage/static/prompt"
rm -rf "${OUT_DIR}"
mkdir -p "${OUT_DIR}"
cp -R "${DIST_DIR}/"* "${OUT_DIR}/"
# Ensure the app works when hosted under /prompt/ instead of site root.
# Many Kotlin/Compose wasm templates use <base href="/"> or <base href="/" />.
if [ -f "${OUT_DIR}/index.html" ]; then
sed -i 's#<base href="/">#<base href="/prompt/">#g' "${OUT_DIR}/index.html" || true
sed -i 's#<base href="/" />#<base href="/prompt/" />#g' "${OUT_DIR}/index.html" || true
fi
# Optional: SPA refresh fallback under GitHub Pages.
# If your wasm app uses client-side routing, this prevents 404s on refresh.
if [ -f "${OUT_DIR}/index.html" ]; then
cp "${OUT_DIR}/index.html" "${OUT_DIR}/404.html"
fi
# ------------------------------------------------------------
# IMPORTANT FIX:
# Some Kotlin/Compose WASM builds (and/or your loader) request
# assets via absolute URLs like /kotlin/...
# Your screenshot shows:
# https://www.llamatik.com/kotlin/llamatik_wasm/llamatik_wasm.mjs (404)
#
# So we mirror the kotlin runtime folder to site root:
# homepage/static/kotlin/...
# ------------------------------------------------------------
ROOT_KOTLIN_DIR="homepage/static/kotlin"
rm -rf "${ROOT_KOTLIN_DIR}"
mkdir -p "${ROOT_KOTLIN_DIR}"
# 1) Copy kotlin runtime from the distribution if present
if [ -d "${DIST_DIR}/kotlin" ]; then
cp -R "${DIST_DIR}/kotlin/"* "${ROOT_KOTLIN_DIR}/"
fi
# 2) Safety net: also copy the engine artifacts generated into the library resources
# (this ensures kotlin/llamatik_wasm/llamatik_wasm.{mjs,wasm} exist)
if [ -d "library/src/wasmJsMain/resources/kotlin" ]; then
cp -R "library/src/wasmJsMain/resources/kotlin/"* "${ROOT_KOTLIN_DIR}/"
fi
echo "Root kotlin assets staged at: ${ROOT_KOTLIN_DIR}"
echo "Expecting engine at: ${ROOT_KOTLIN_DIR}/llamatik_wasm/llamatik_wasm.mjs"
# ---------------------------
# Hugo build
# ---------------------------
- name: Install Node.js dependencies
working-directory: homepage
run: |
npm install postcss postcss-cli autoprefixer
- name: Build with Hugo
working-directory: homepage
env:
HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache
HUGO_ENVIRONMENT: production
run: |
hugo \
--minify \
--baseURL "${{ steps.pages.outputs.base_url }}/"
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: homepage/public
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4