Skip to content

Commit 966c8ef

Browse files
committed
Make it much easier to update the demo
1 parent 126d875 commit 966c8ef

2 files changed

Lines changed: 56 additions & 1 deletion

File tree

docs/HOW-TO-RELEASE.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
1+
# How to release
2+
13
- Pushed all changes
24
- Create a tag in the format `vX.Y.Z`
35
- Push the tag
4-
- The `deploy.yml` workflow will run and publish the artifacts to Maven Central
6+
- The `deploy.yml` workflow will run and publish the artifacts to Maven Central
7+
8+
## How to update the demo
9+
10+
1. Change to the `demo` branch in git
11+
12+
2. Run the updateDemo task:
13+
```bash
14+
./gradlew :sampleApp:updateDemo
15+
```
16+
17+
This will automatically:
18+
- Build the WASM distribution
19+
- Copy all files to the docs directory
20+
- Remove old WASM files that are no longer referenced
21+
22+
3. Commit and push the changes:
23+
```bash
24+
git add docs/
25+
git commit -m "Update demo site"
26+
git push
27+
```
28+
29+
4. The demo will be available at the GitHub Pages URL (typically
30+
`https://wavesonics.github.io/ComposeTextEditorLibrary/`)

sampleApp/build.gradle.kts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,35 @@ android {
169169
}
170170
}
171171
}
172+
173+
tasks.register<Copy>("updateDemo") {
174+
description = "Builds the WASM distribution and copies it to the docs directory for GitHub Pages"
175+
group = "distribution"
176+
177+
dependsOn("wasmJsBrowserDistribution")
178+
179+
from(layout.buildDirectory.dir("dist/wasmJs/productionExecutable"))
180+
into(layout.projectDirectory.dir("../docs"))
181+
182+
doLast {
183+
val docsDir = layout.projectDirectory.dir("../docs").asFile
184+
val buildDir = layout.buildDirectory.dir("dist/wasmJs/productionExecutable").get().asFile
185+
186+
// Get list of WASM files in build output
187+
val newWasmFiles =
188+
buildDir.listFiles { file -> file.extension == "wasm" }?.map { it.name }?.toSet() ?: emptySet()
189+
190+
// Remove old WASM files that are no longer in the build
191+
docsDir.listFiles { file -> file.extension == "wasm" }?.forEach { oldFile ->
192+
if (oldFile.name !in newWasmFiles) {
193+
println("Removing old WASM file: ${oldFile.name}")
194+
oldFile.delete()
195+
}
196+
}
197+
198+
println("Demo updated in docs/ directory")
199+
}
200+
}
172201
dependencies {
173202
implementation(libs.lifecycle.runtime.ktx)
174203
implementation(libs.activity.compose)

0 commit comments

Comments
 (0)