forked from SalamLang/Salam
-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (57 loc) · 2.25 KB
/
Copy pathweb-assembly.yml
File metadata and controls
67 lines (57 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Build and Deploy WebAssembly
on:
push:
branches:
- next-generation-ts
- main
permissions:
contents: write
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Bun
run: |
curl -fsSL https://bun.sh/install | bash
echo "$HOME/.bun/bin" >> $GITHUB_PATH
export PATH="$HOME/.bun/bin:$PATH"
bun --version
- name: Setup GIT config
run: |
git clone https://github.com/SalamLang/Salam-Editor.git
git config --global user.name "Max Base (Salam)"
git config --global user.email "$EMAIL"
- name: Run WebAssembly build script
run: |
cd src
bunx esbuild main.ts --bundle --platform=browser --outfile=../salam-wa.js --external:fs --external:path
cd ..
bunx terser salam-wa.js --compress --mangle -o salam-wa.js
bunx javascript-obfuscator salam-wa.js --output salam-wa.js --compact true --control-flow-flattening true
- name: Calculate checksums of original files
id: original_checksums
run: |
ls -l salam-wa.js
sha256sum salam-wa.js > js-checksum.txt || echo "Error calculating checksum for salam-wa.js"
echo "JS_CHECKSUM=$(cat js-checksum.txt | awk '{ print $1 }')" >> $GITHUB_ENV
- name: Calculate checksums of new files in Salam-Editor
id: new_checksums
run: |
cd ..
cd Salam-Editor
git checkout dev
cd src/scripts/
ls -l salam-wa.js
sha256sum salam-wa.js > js-checksum-editor.txt || echo "Error calculating checksum for salam-wa.js"
echo "JS_CHECKSUM_EDITOR=$(cat js-checksum-editor.txt | awk '{ print $1 }')" >> $GITHUB_ENV
- name: Commit and push changes if needed
if: ${{ env.JS_CHECKSUM != env.JS_CHECKSUM_EDITOR }}
run: |
cp ./salam-wa.js ./Salam-Editor/src/scripts/
cd Salam-Editor
sudo chown -R www-data:www-data *
git add src/scripts/salam-wa.js
git commit -m "Release: Update WebAssembly files"
git push https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/SalamLang/Salam-Editor.git