Skip to content

Fix wasm build

Fix wasm build #81

Workflow file for this run

name: wasm
on:
workflow_dispatch:
push:
#schedule:
# - cron: '*/120 8-18 * * *' # every 2 hours from 8:00 to 18:00 every day
jobs:
wasm-build: # the first job
# current job matrix. if modified, remember to UPDATE the strategy in the next job
strategy:
fail-fast: false
matrix:
os: [macos-14]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps: # job steps
- name: Check-out repository
uses: actions/checkout@v4
# https://doc.qt.io/qt-6/wasm.html
# Emsdk 3.1.50 is needed for Qt 6.7
# Emsdk 3.1.56 is needed for Qt 6.8
# Emsdk 3.1.70 is needed for Qt 6.9
- name: Set environment variables based on selected Qt version
id: set-env
shell: bash
run: |
# Select Qt version (change this to switch version)
QT_VERSION="6.8.2"
# Set matching installer and emsdk version
if [[ "$QT_VERSION" == "6.9.0" ]]; then
QT_VERSION_NO_DOTS="690"
QT_INSTALLER_VERSION="4.9.0"
EMSDK_VERSION="3.1.70"
elif [[ "$QT_VERSION" == "6.8.2" ]]; then
QT_VERSION_NO_DOTS="682"
QT_INSTALLER_VERSION="4.9.0"
EMSDK_VERSION="3.1.56"
else
echo "Unsupported Qt version: $QT_VERSION"
exit 1
fi
echo "QT_VERSION=$QT_VERSION" >> $GITHUB_ENV
echo "QT_VERSION_NO_DOTS=$QT_VERSION_NO_DOTS" >> $GITHUB_ENV
echo "QT_INSTALLER_VERSION=$QT_INSTALLER_VERSION" >> $GITHUB_ENV
echo "EMSDK_VERSION=$EMSDK_VERSION" >> $GITHUB_ENV
- name: Cache emsdk
id: cache-emsdk
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/emsdk
key: ${{ runner.os }}-emsdk
- name: Install emsdk
if: steps.cache-emsdk.outputs.cache-hit != 'true'
shell: bash
run: |
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
git pull
./emsdk install $EMSDK_VERSION
./emsdk activate $EMSDK_VERSION
- name: Cache Qt
id: cache-qt
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/Qt
key: ${{ runner.os }}-qt
- name: Install Qt for WebAssembly
if: steps.cache-qt.outputs.cache-hit != 'true'
shell: bash
run: |
curl -L -O https://download.qt.io/official_releases/online_installers/qt-online-installer-mac-x64-online.dmg
chmod u+x qt-online-installer-mac-x64-online.dmg
hdiutil attach qt-online-installer-mac-x64-online.dmg
/Volumes/qt-online-installer-macOS-x64-$QT_INSTALLER_VERSION/qt-online-installer-macOS-x64-$QT_INSTALLER_VERSION.app/Contents/MacOS/qt-online-installer-macOS-x64-$QT_INSTALLER_VERSION \
--email ${{ secrets.QT_ACCOUNT_EMAIL }} \
--pw ${{ secrets.QT_ACCOUNT_PASSWORD }} \
--root ${{ github.workspace }}/Qt \
--accept-licenses \
--accept-obligations \
--default-answer \
--confirm-command \
install qt.qt6.$QT_VERSION_NO_DOTS.wasm_singlethread qt.qt6.$QT_VERSION_NO_DOTS.addons.qt5compat
hdiutil detach /Volumes/qt-online-installer-macOS-x64-$QT_INSTALLER_VERSION
- name: Print some debug info
shell: bash
run: |
source ${{ github.workspace }}/emsdk/emsdk_env.sh
em++ --version
export PATH=$PATH:${{ github.workspace }}/Qt/$QT_VERSION/wasm_singlethread/bin
qmake -v
- name: Build WASM from BasicC++ example
shell: bash
run: |
source ${{ github.workspace }}/emsdk/emsdk_env.sh
export PATH=$PATH:${{ github.workspace }}/Qt/$QT_VERSION/wasm_singlethread/bin
cd examples/BasicC++/src
qmake BasicC++.pro -spec wasm-emscripten
make -j
- name: Copy the built WASM to the build/wasm folder
shell: bash
run: |
mkdir -p build/wasm
cp examples/BasicC++/src/*.wasm build/wasm
cp examples/BasicC++/src/*.html build/wasm
cp examples/BasicC++/src/*.js build/wasm
cp examples/BasicC++/src/*.svg build/wasm
- name: Upload the zipped wasm folder
uses: actions/upload-artifact@v4
with:
name: wasm # name of the zip file to be created and uploaded
path: build/wasm # directory whose content is to be zipped
compression-level: 0 # no compression
if-no-files-found: error
- name: Push the built wasm to the webapp branch
uses: s0/git-publish-subdir-action@develop
env:
GITHUB_TOKEN: ${{ secrets.GH_API_PERSONAL_ACESS_TOKEN }}
REPO: self
BRANCH: webapp
FOLDER: build/wasm # directory whose content is to be pushed