Skip to content

Update web-assembly.yml #119

Update web-assembly.yml

Update web-assembly.yml #119

Workflow file for this run

name: Build and Deploy WebAssembly
on:
push:
branches:
- main
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache Emscripten SDK
uses: actions/cache@v4
with:
path: emsdk
key: ${{ runner.os }}-emsdk-${{ hashFiles('emsdk/.emscripten') }}
restore-keys: |
${{ runner.os }}-emsdk-
- name: Install Emscripten (if not cached)
run: |
if [ ! -d "emsdk" ]; then
git clone https://github.com/emscripten-core/emsdk.git
fi
cd emsdk
./emsdk install latest
./emsdk activate latest
- name: Source Emscripten environment
run: |
echo "EMSDK=/home/runner/work/Salam/Salam/emsdk" >> $GITHUB_ENV
echo "PATH=$PATH:/home/runner/work/Salam/Salam/emsdk:/home/runner/work/Salam/Salam/emsdk/upstream/emscripten" >> $GITHUB_ENV
source ./emsdk/emsdk_env.sh
- name: Run WebAssembly build script
run: |
source emsdk/emsdk_env.sh
cd src
bash build-webassembly.sh
- name: Clone Salam-Editor repository
run: |
FIRST_NAME="Max"
DOMAIN="gmail.com"
EMAIL="${FIRST_NAME}BaseCode@${DOMAIN}"
git clone https://github.com/SalamLang/Salam-Editor.git
cp ./src/salam-wa.js ./Salam-Editor/
cp ./src/salam-wa.wasm ./Salam-Editor/
cd Salam-Editor
sudo chown www-data:www-data *
git config user.name "Max Base"
git config user.email "$EMAIL"
git config user.name "Max Base"
git config user.email "${{ secrets.USER_EMAIL }}"
- name: Calculate checksums of original files
id: original_checksums
run: |
cd src
sha256sum salam-wa.js > js-checksum.txt
sha256sum salam-wa.wasm > wasm-checksum.txt
echo "JS_CHECKSUM=$(cat js-checksum.txt | awk '{ print $1 }')" >> $GITHUB_ENV
echo "WASM_CHECKSUM=$(cat wasm-checksum.txt | awk '{ print $1 }')" >> $GITHUB_ENV
- name: Calculate checksums of new files in Salam-Editor
id: new_checksums
run: |
cd Salam-Editor
sha256sum salam-wa.js > js-checksum-editor.txt || echo "0 salam-wa.js" > js-checksum-editor.txt
sha256sum salam-wa.wasm > wasm-checksum-editor.txt || echo "0 salam-wa.wasm" > wasm-checksum-editor.txt
echo "JS_CHECKSUM_EDITOR=$(cat js-checksum-editor.txt | awk '{ print $1 }')" >> $GITHUB_ENV
echo "WASM_CHECKSUM_EDITOR=$(cat wasm-checksum-editor.txt | awk '{ print $1 }')" >> $GITHUB_ENV
- name: Commit and push changes if needed
if: ${{ env.JS_CHECKSUM != env.JS_CHECKSUM_EDITOR || env.WASM_CHECKSUM != env.WASM_CHECKSUM_EDITOR }}
run: |
cd Salam-Editor
git add salam-wa.js salam-wa.wasm
git commit -m "Release: Update WebAssembly files"
git push https://x-access-token:${{ secrets.USER_TOKEN }}@github.com/SalamLang/Salam-Editor.git