Skip to content

Commit a6f8537

Browse files
committed
added wasm workflow to CI
1 parent e33580a commit a6f8537

File tree

5 files changed

+238
-3
lines changed

5 files changed

+238
-3
lines changed

.github/workflows/build_wasm.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: 'Build: Wasm'
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
inputs:
7+
build_mode:
8+
description: 'Build mode: devel, nightly, testing, stable'
9+
default: 'devel'
10+
required: true
11+
workflow_call:
12+
inputs:
13+
build_mode:
14+
description: 'Build mode: devel, nightly, testing, stable'
15+
default: 'devel'
16+
type: string
17+
required: true
18+
19+
jobs:
20+
build:
21+
runs-on: ubuntu-24.04
22+
steps:
23+
- name: Cancel Previous Runs
24+
uses: styfle/cancel-workflow-action@0.12.1
25+
with:
26+
access_token: ${{ github.token }}
27+
- name: Clone repository
28+
uses: actions/checkout@v4
29+
- name: Configure workflow
30+
env:
31+
pull_request_title: ${{ github.event.pull_request.title }}
32+
run: |
33+
bash ./buildscripts/ci/tools/make_build_mode_env.sh -e ${{ github.event_name }} -m ${{ inputs.build_mode }}
34+
BUILD_MODE=$(cat ./build.artifacts/env/build_mode.env)
35+
36+
bash ./buildscripts/ci/tools/make_build_number.sh
37+
BUILD_NUMBER=$(cat ./build.artifacts/env/build_number.env)
38+
39+
DO_UPDATE_TS='false'
40+
if [[ "$BUILD_MODE" == "testing" || "$BUILD_MODE" == "stable" ]]; then
41+
DO_UPDATE_TS='true'
42+
if [ -z "${{ secrets.TRANSIFEX_API_TOKEN }}" ]; then
43+
echo "::warning::TRANSIFEX_API_TOKEN is empty; updating .ts files disabled"
44+
DO_UPDATE_TS='false'
45+
fi
46+
fi
47+
48+
DO_PLACEHOLDER_TRANSLATIONS='false'
49+
if [[ "$BUILD_MODE" == "nightly" || "$BUILD_MODE" == "devel" ]]; then
50+
DO_PLACEHOLDER_TRANSLATIONS='true'
51+
fi
52+
53+
ADD_INFO="_${GITHUB_REF#refs/heads/}"
54+
if [ "${{ github.event_name }}" == "pull_request" ]; then
55+
ADD_INFO="_${{ github.event.pull_request.number }}_${pull_request_title}"
56+
fi
57+
UPLOAD_ARTIFACT_NAME="$(tr '":<>|*?/\\’' '_' <<<"MU4_${BUILD_NUMBER}_Wasm${ADD_INFO}")"
58+
59+
echo "github.repository: ${{ github.repository }}"
60+
echo "BUILD_MODE=$BUILD_MODE" | tee -a $GITHUB_ENV
61+
echo "BUILD_NUMBER=$BUILD_NUMBER" | tee -a $GITHUB_ENV
62+
echo "DO_UPDATE_TS=$DO_UPDATE_TS" | tee -a $GITHUB_ENV
63+
echo "DO_PLACEHOLDER_TRANSLATIONS=$DO_PLACEHOLDER_TRANSLATIONS" | tee -a $GITHUB_ENV
64+
echo "UPLOAD_ARTIFACT_NAME=$UPLOAD_ARTIFACT_NAME" | tee -a $GITHUB_ENV
65+
66+
echo "CCACHE_TIMESTAMP=$(date -u +"%F-%T")" | tee -a $GITHUB_ENV
67+
68+
- name: Restore ccache files
69+
uses: actions/cache@v4
70+
with:
71+
path: ${{ github.workspace }}/.ccache
72+
key: ${{runner.os}}-${{runner.arch}}-ccache-${{ env.CCACHE_TIMESTAMP }}
73+
restore-keys: ${{runner.os}}-${{runner.arch}}-ccache-
74+
- name: Setup ccache
75+
run: |
76+
sudo apt-get update && sudo apt-get install -y ccache
77+
bash ./buildscripts/ci/tools/setup_ccache_config.sh
78+
79+
- name: Register gcc problem matcher
80+
run: echo "::add-matcher::.github/problem_matchers/gcc.json"
81+
82+
- name: Install Qt
83+
uses: jurplel/install-qt-action@v4
84+
with:
85+
version: '6.9.*'
86+
host: all_os
87+
target: 'wasm'
88+
arch: wasm
89+
modules: 'qt5compat qtscxml'
90+
- name: Setup environment
91+
run: |
92+
bash ./buildscripts/ci/linux/setup.sh --arch wasm
93+
94+
- name: Generate _en.ts files
95+
env:
96+
LUPDATE_ARGS: ""
97+
POSTPROCESS_ARGS: ${{ env.DO_PLACEHOLDER_TRANSLATIONS == 'true' && '--generate-placeholder-translations' || '' }}
98+
run: |
99+
bash ./tools/translations/run_lupdate.sh
100+
- name: Update .ts files (tx pull)
101+
if: env.DO_UPDATE_TS == 'true'
102+
uses: transifex/cli-action@v2
103+
with:
104+
token: ${{ secrets.TRANSIFEX_API_TOKEN }}
105+
args: "pull -f"
106+
- name: Build
107+
run: |
108+
bash ./buildscripts/ci/wasm/build.sh -n ${{ env.BUILD_NUMBER }}
109+
echo "============== ccache ==============="
110+
ccache -sv
111+
- name: Package
112+
run: |
113+
bash ./buildscripts/ci/wasm/package.sh
114+
- name: Upload artifacts on GitHub
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: ${{ env.UPLOAD_ARTIFACT_NAME }}
118+
path: ./build.artifacts/

buildscripts/ci/linux/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ df -h .
2828
BUILD_TOOLS=$HOME/build_tools
2929
ARTIFACTS_DIR=build.artifacts
3030
CRASH_REPORT_URL=""
31+
BUILD_NUMBER=""
3132
BUILD_MODE=""
3233
SUFFIX="" # appended to `mscore` command name to avoid conflicts (e.g. `mscoredev`)
3334

buildscripts/ci/linux/setup.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ df -h .
2626

2727
BUILD_TOOLS=$HOME/build_tools
2828
ENV_FILE=$BUILD_TOOLS/environment.sh
29-
PACKARCH="x86_64" # x86_64, armv7l, aarch64
29+
PACKARCH="x86_64" # x86_64, armv7l, aarch64, wasm
3030
COMPILER="gcc" # gcc, clang
3131

3232
while [[ "$#" -gt 0 ]]; do
@@ -164,7 +164,7 @@ fi
164164
# CMAKE
165165
# Get newer CMake (only used cached version if it is the same)
166166
case "$PACKARCH" in
167-
x86_64)
167+
x86_64 | wasm)
168168
cmake_version="3.24.0"
169169
cmake_dir="$BUILD_TOOLS/cmake/${cmake_version}"
170170
if [[ ! -d "$cmake_dir" ]]; then
@@ -183,7 +183,7 @@ cmake --version
183183

184184
# Ninja
185185
case "$PACKARCH" in
186-
x86_64)
186+
x86_64 | wasm)
187187
echo "Get Ninja"
188188
ninja_dir=$BUILD_TOOLS/Ninja
189189
if [[ ! -d "$ninja_dir" ]]; then
@@ -201,6 +201,18 @@ esac
201201
echo "ninja version"
202202
ninja --version
203203

204+
if [[ "$PACKARCH" == "wasm" ]]; then
205+
git clone https://github.com/emscripten-core/emsdk.git $BUILD_TOOLS/emsdk
206+
origin_dir=$(pwd)
207+
cd $BUILD_TOOLS/emsdk
208+
git pull
209+
./emsdk install $EMSDK_VERSION
210+
./emsdk activate $EMSDK_VERSION
211+
echo "source $BUILD_TOOLS/emsdk/emsdk_env.sh" >> ${ENV_FILE}
212+
echo export CMAKE_TOOLCHAIN_FILE=${BUILD_TOOLS}/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
213+
cd $origin_dir
214+
fi
215+
204216
##########################################################################
205217
# POST INSTALL
206218
##########################################################################

buildscripts/ci/wasm/build.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env bash
2+
# SPDX-License-Identifier: GPL-3.0-only
3+
# MuseScore-Studio-CLA-applies
4+
#
5+
# MuseScore Studio
6+
# Music Composition & Notation
7+
#
8+
# Copyright (C) 2025 MuseScore Limited
9+
#
10+
# This program is free software: you can redistribute it and/or modify
11+
# it under the terms of the GNU General Public License version 3 as
12+
# published by the Free Software Foundation.
13+
#
14+
# This program is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU General Public License
20+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
21+
22+
trap 'echo Build failed; exit 1' ERR
23+
24+
BUILD_TOOLS=$HOME/build_tools
25+
ARTIFACTS_DIR=build.artifacts
26+
BUILD_DIR=build.release
27+
BUILD_NUMBER=""
28+
BUILD_MODE=""
29+
30+
while [[ "$#" -gt 0 ]]; do
31+
case $1 in
32+
-n|--number) BUILD_NUMBER="$2"; shift ;;
33+
--build_mode) BUILD_MODE="$2"; shift ;;
34+
*) echo "Unknown parameter passed: $1"; exit 1 ;;
35+
esac
36+
shift
37+
done
38+
39+
if [ -z "$BUILD_NUMBER" ]; then echo "error: not set BUILD_NUMBER"; exit 1; fi
40+
if [ -z "$BUILD_MODE" ]; then BUILD_MODE=$(cat $ARTIFACTS_DIR/env/build_mode.env); fi
41+
42+
MUSE_APP_BUILD_MODE=dev
43+
44+
case "${BUILD_MODE}" in
45+
"devel") MUSE_APP_BUILD_MODE=dev; SUFFIX=dev;;
46+
"nightly") MUSE_APP_BUILD_MODE=dev; SUFFIX=nightly;;
47+
"testing") MUSE_APP_BUILD_MODE=testing; SUFFIX=testing;;
48+
"stable") MUSE_APP_BUILD_MODE=release; SUFFIX="";;
49+
esac
50+
51+
echo "MUSE_APP_BUILD_MODE: $MUSE_APP_BUILD_MODE"
52+
echo "BUILD_MODE: $BUILD_MODE"
53+
echo "BUILD_NUMBER: $BUILD_NUMBER"
54+
55+
echo "=== ENVIRONMENT === "
56+
57+
cat $BUILD_TOOLS/environment.sh
58+
source $BUILD_TOOLS/environment.sh
59+
60+
# =========== Build =======================
61+
echo "=== BUILD ==="
62+
63+
MUSESCORE_REVISION=$(git rev-parse --short=7 HEAD)
64+
65+
# Build portable AppImage
66+
MUSE_APP_BUILD_MODE=$MUSE_APP_BUILD_MODE \
67+
MUSESCORE_BUILD_CONFIGURATION="app-web" \
68+
MUSESCORE_BUILD_NUMBER=$BUILD_NUMBER \
69+
MUSESCORE_REVISION=$MUSESCORE_REVISION \
70+
bash ./ninja_build.sh -t release
71+
72+
bash ./buildscripts/ci/tools/make_release_channel_env.sh -c $MUSE_APP_BUILD_MODE
73+
bash ./buildscripts/ci/tools/make_version_env.sh $BUILD_NUMBER
74+
bash ./buildscripts/ci/tools/make_revision_env.sh $MUSESCORE_REVISION
75+
bash ./buildscripts/ci/tools/make_branch_env.sh
76+

buildscripts/ci/wasm/package.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
# SPDX-License-Identifier: GPL-3.0-only
3+
# MuseScore-Studio-CLA-applies
4+
#
5+
# MuseScore Studio
6+
# Music Composition & Notation
7+
#
8+
# Copyright (C) 2025 MuseScore Limited
9+
#
10+
# This program is free software: you can redistribute it and/or modify
11+
# it under the terms of the GNU General Public License version 3 as
12+
# published by the Free Software Foundation.
13+
#
14+
# This program is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU General Public License
20+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
21+
echo "Package MuseScore Wasm"
22+
trap 'echo Package failed; exit 1' ERR
23+
24+
BUILD_TOOLS=$HOME/build_tools
25+
ARTIFACTS_DIR=build.artifacts
26+
BUILD_DIR=build.release
27+
28+
cp -r $BUILD_DIR/public_html $ARTIFACTS_DIR/public_html

0 commit comments

Comments
 (0)