Skip to content

Commit df384f2

Browse files
committed
Useful for people who want to dynamically import libOpenCOR (and thus saving a lot of space when deploying their app/package). Regarding the `webassembly` job, we now run it on `ubunutu-22.04` rather than `macos-14` because the `milanmk/actions-file-deployer` action requires access to `realpath` and the version of `realpath` on macOS is not the same in that it doesn't support the `--canonicalize-missing` option for instance.
1 parent c062ad7 commit df384f2

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

.github/workflows/cd.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ jobs:
197197
uses: pypa/gh-action-pypi-publish@release/v1
198198
webassembly:
199199
name: WebAssembly
200-
runs-on: macos-14
200+
runs-on: ubuntu-22.04
201201
env:
202202
BUILDCACHE_ACCURACY: STRICT
203203
BUILDCACHE_COMPRESS_FORMAT: ZSTD
@@ -208,7 +208,7 @@ jobs:
208208
- name: Set the timezone to New Zealand
209209
uses: szenius/set-timezone@v2.0
210210
with:
211-
timezoneMacos: 'Pacific/Auckland'
211+
timezoneLinux: 'Pacific/Auckland'
212212
- name: Check out libOpenCOR
213213
uses: actions/checkout@v4
214214
- name: Install CMake and Ninja
@@ -218,7 +218,7 @@ jobs:
218218
with:
219219
cache_key: cd-webassembly
220220
- name: Install Emscripten
221-
run: brew install emscripten
221+
uses: mymindstorm/setup-emsdk@v14
222222
- name: Configure libOpenCOR
223223
run: cmake -G Ninja -S . -B build -DBUILD_TYPE=Release -DCODE_ANALYSIS=OFF -DCODE_COVERAGE=OFF -DDOCUMENTATION=OFF -DJAVASCRIPT_BINDINGS=ON -DJAVASCRIPT_UNIT_TESTING=OFF -DMEMORY_CHECKS=OFF -DPYTHON_BINDINGS=OFF -DPYTHON_UNIT_TESTING=OFF -DSHARED_LIBS=OFF -DUNIT_TESTING=OFF
224224
- name: Build WebAssembly
@@ -234,6 +234,17 @@ jobs:
234234
uses: softprops/action-gh-release@v2
235235
with:
236236
files: ./build/libopencor-*
237+
- name: Deploy to https://opencor.ws/libopencor/downloads/wasm
238+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
239+
uses: milanmk/actions-file-deployer@master
240+
with:
241+
remote-protocol: sftp
242+
remote-host: ${{ secrets.REMOTE_HOST }}
243+
remote-user: ${{ secrets.REMOTE_USER }}
244+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
245+
local-path: ./build/src/bindings/javascript/build/src/wasm
246+
remote-path: /home/www/opencor.ws/libopencor/downloads/wasm
247+
sync: full
237248
- name: Publish libOpenCOR
238249
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
239250
run: |

src/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,13 @@ if(EMSCRIPTEN)
313313
message(WARNING "npm could not be found, so libOpenCOR's JavaScript bindings could not be packaged.")
314314
endif()
315315

316+
# Copy our generated .js file over so that it can be deployed.
317+
318+
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
319+
COMMAND ${CMAKE_COMMAND} -E make_directory wasm
320+
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_PROJECT_NAME}.js
321+
wasm/${CMAKE_PROJECT_NAME}-${CMAKE_PROJECT_VERSION}.js)
322+
316323
# Copy our generated .js file over so that it can be used by our test Web page.
317324

318325
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD

0 commit comments

Comments
 (0)