-
Notifications
You must be signed in to change notification settings - Fork 4
147 lines (128 loc) · 4.8 KB
/
web_builds.yml
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: 🌐 Web Builds
on:
push:
branches: [ master, main ]
env:
PROJECT_FOLDER: gdextension_cpp_example
TARGET_PATH: demo/bin/
TARGET_NAME: libgdexample
SCONS_CACHE: ${{ github.workspace }}/.scons-cache/
EM_VERSION: 3.1.39
EM_CACHE_FOLDER: emsdk-cache
GODOT_VERSION: 4.3
EXPORT_NAME: gdextension_cpp_example/demo/
jobs:
web-compilation:
runs-on: "ubuntu-20.04"
name: ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
- name: Web (wasm32) - Debug
cache-name: web-wasm32
target: template_debug
artifact-extension: wasm
- name: Web (wasm32) - Release
cache-name: web-wasm32
target: template_release
artifact-extension: wasm
- name: Web (wasm32, No Threads) - Debug
cache-name: web-wasm32-nothreads
target: template_debug
artifact-extension: nothreads.wasm
flags: threads=no
- name: Web (wasm32, No Threads) - Release
cache-name: web-wasm32-nothreads
target: template_release
artifact-extension: nothreads.wasm
flags: threads=no
steps:
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
submodules: recursive
- name: Restore Godot build cache
uses: ./gdextension_cpp_example/godot-cpp/.github/actions/godot-cache-restore
with:
cache-name: ${{ matrix.cache-name }}-${{ matrix.target }}
continue-on-error: true
# Use python 3.x release (works cross platform)
- name: Set up Python 3.x
uses: actions/setup-python@v5
with:
# Semantic version range syntax or exact version of a Python version
python-version: '3.x'
# Optional - x64 or x86 architecture, defaults to x64
architecture: 'x64'
- name: Web dependencies
uses: mymindstorm/setup-emsdk@v14
with:
version: ${{ env.EM_VERSION }}
actions-cache-folder: ${{ env.EM_CACHE_FOLDER }}-${{ matrix.target }}
- name: Configuring Python packages
run: |
python -c "import sys; print(sys.version)"
python -m pip install scons
python --version
scons --version
- name: Compilation
run: |
mkdir -v -p ${{ env.PROJECT_FOLDER}}/${{ env.TARGET_PATH }}
cd ${{ env.PROJECT_FOLDER }}
scons platform=web target=${{ matrix.target }} target_path=${{ env.TARGET_PATH }} target_name=${{env.TARGET_NAME}} -j6 ${{ matrix.flags }}
- name: Save Godot build cache
uses: ./gdextension_cpp_example/godot-cpp/.github/actions/godot-cache-save
with:
cache-name: ${{ matrix.cache-name }}-${{ matrix.target }}
continue-on-error: true
- name: Upload Artifact
env:
ARTIFACT_FOLDER: ${{ env.PROJECT_FOLDER }}/${{ env.TARGET_PATH }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.cache-name }}-${{ matrix.target }}
path: ${{ env.ARTIFACT_FOLDER }}*.${{ matrix.artifact-extension }}
if-no-files-found: error
web-deploy:
name: Web Deploy
runs-on: ubuntu-latest
needs: [ web-compilation ]
container:
image: barichello/godot-ci:4.3 # Ideally this would be ${GODOT_VERSION}, but Github Actions doesn't allow this! :(
steps:
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
- name: Download Artifacts
uses: actions/download-artifact@v4
- name: Copy Libraries to Project Folder
run: |
mkdir -v -p ${{env.PROJECT_FOLDER}}/${{env.TARGET_PATH}}
cp --verbose web-wasm32-*/*.wasm ${{env.PROJECT_FOLDER}}/${{env.TARGET_PATH}}
- name: Setup
run: |
mkdir -v -p ~/.local/share/godot/export_templates
mv /root/.local/share/godot/export_templates/${GODOT_VERSION}.stable ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable
- name: Web Build
run: |
mkdir -v -p build/web
cd $EXPORT_NAME
godot --headless --verbose --export-release "Web" ../../build/web/index.html
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: web
path: build/web
# Installing rsync is needed in order to deploy to GitHub Pages. Without it, the build will fail.
- name: Install rsync 📚
run: |
apt-get update && apt-get install -y rsync
- name: Deploy to GitHub Pages 🚀
uses: JamesIves/github-pages-deploy-action@releases/v4
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: build/web # The folder the action should deploy.