-
-
Notifications
You must be signed in to change notification settings - Fork 531
243 lines (226 loc) · 9.96 KB
/
CI_emscripten.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
name: Emscripten
on:
push:
branches-ignore:
- 'l10n_**' # Push events to translation service branches (that begin with "l10n_")
pull_request:
# Match all pull requests...
paths-ignore:
# Except some text-only files / documentation
- 'ChangeLog'
# Except those that only include changes to stats
- 'data/base/stats/**'
- 'data/mp/stats/**'
- 'data/mp/multiplay/script/functions/camTechEnabler.js'
# Linux-specific example scripts
- 'doc/hosting/linux_scripts/**'
# Support running after "Draft Tag Release" workflow completes, as part of automated release process
workflow_run:
workflows: ["Draft Tag Release"]
push:
tags:
- '*'
types:
- completed
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
EMSDK_VERSION: 3.1.61
CMAKE_BUILD_PARALLEL_LEVEL: 4 # See: https://github.blog/2024-01-17-github-hosted-runners-double-the-power-for-open-source/
jobs:
web-build:
strategy:
matrix:
include:
- arch: "wasm32"
upload_artifact: true
fail-fast: false
name: '${{ matrix.arch }}'
permissions:
contents: read
# needed to generate artifact attestations, see: https://docs.github.com/en/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds
id-token: write
attestations: write
runs-on: ubuntu-latest
env:
WZ_WASM_ARCH: '${{ matrix.arch }}'
if: "!contains(github.event.head_commit.message, '[ci skip]')"
outputs:
# Needed by the release + other later jobs - despite this being a matrix job, this should be the same for all, so we can allow whatever is last to persist it
WZ_GITHUB_REF: ${{ steps.checkout-config.outputs.WZ_GITHUB_REF }}
WZ_GITHUB_SHA: ${{ steps.checkout-config.outputs.WZ_GITHUB_SHA }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
path: 'src'
- name: Configure Repo Checkout
id: checkout-config
working-directory: ./src
env:
WORKFLOW_RUN_CONCLUSION: ${{ github.event.workflow_run.conclusion }}
WORKFLOW_RUN_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
run: |
. .ci/githubactions/checkout_config.sh
- name: Prepare Git Repo for autorevision
working-directory: '${{ github.workspace }}/src'
run: cmake -P .ci/githubactions/prepare_git_repo.cmake
- name: Init Git Submodules
working-directory: '${{ github.workspace }}/src'
run: git submodule update --init --recursive
- name: Prep Directories
run: |
mkdir -p "${{ github.workspace }}/build"
mkdir -p "${{ github.workspace }}/installed"
mkdir -p "${{ github.workspace }}/output"
- name: Compute build variables
run: |
WZ_DISTRIBUTOR="UNKNOWN"
if [ "${GITHUB_REPOSITORY}" == "Warzone2100/warzone2100" ]; then
WZ_DISTRIBUTOR="wz2100.net"
fi
echo "WZ_DISTRIBUTOR=${WZ_DISTRIBUTOR}"
echo "WZ_DISTRIBUTOR=${WZ_DISTRIBUTOR}" >> $GITHUB_ENV
WZ_BUILD_DESC="web_${WZ_WASM_ARCH}"
echo "WZ_BUILD_DESC=${WZ_BUILD_DESC}"
echo "WZ_BUILD_DESC=${WZ_BUILD_DESC}" >> $GITHUB_ENV
- name: Prep Build Environment
run: |
# Install additional host tools
sudo apt-get -u update
DEBIAN_FRONTEND=noninteractive sudo apt-get -y install cmake git zip unzip gettext asciidoctor
- uses: actions/setup-node@v4
- name: Install workbox-cli
run: npm install workbox-cli --global
- name: Install EMSDK
id: emsdk
run: |
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
# Download and install the latest SDK tools
./emsdk install ${EMSDK_VERSION}
# Make the "latest" SDK "active" for the current user. (writes .emscripten file)
./emsdk activate ${EMSDK_VERSION}
# Output full path to activation script
echo "CI_EMSDK_ENV_SCRIPT_PATH=$(pwd)/emsdk_env.sh" >> $GITHUB_OUTPUT
echo "CI_EMSDK_ENV_SCRIPT_PATH=$(pwd)/emsdk_env.sh" >> $GITHUB_ENV
- name: CMake Configure
working-directory: '${{ github.workspace }}/build'
env:
WZ_INSTALL_DIR: '${{ github.workspace }}/installed'
run: |
# Setup vcpkg in build dir
git clone https://github.com/microsoft/vcpkg.git vcpkg
# CMake Configure
source "${CI_EMSDK_ENV_SCRIPT_PATH}"
echo "::add-matcher::${GITHUB_WORKSPACE}/src/.ci/githubactions/pattern_matchers/cmake.json"
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DWZ_ENABLE_WARNINGS:BOOL=ON -DWZ_DISTRIBUTOR:STRING="${WZ_DISTRIBUTOR}" "-DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake" "-DVCPKG_TARGET_TRIPLET=${WZ_WASM_ARCH}-emscripten" "-DCMAKE_INSTALL_PREFIX:PATH=${WZ_INSTALL_DIR}" "${{ github.workspace }}/src"
echo "::remove-matcher owner=cmake::"
- name: CMake Build
working-directory: '${{ github.workspace }}/build'
run: |
source "${CI_EMSDK_ENV_SCRIPT_PATH}"
echo "::add-matcher::${GITHUB_WORKSPACE}/src/.ci/githubactions/pattern_matchers/clang.json"
cmake --build . --config ${BUILD_TYPE} --target install
echo "::remove-matcher owner=clang::"
- name: Debug Output
working-directory: ${{github.workspace}}/installed
run: ls -al
- name: Package Archive
working-directory: '${{ github.workspace }}/build'
env:
OUTPUT_DIR: "${{ github.workspace }}/output"
run: |
cpack --config "./CPackConfig.cmake" -G ZIP -D CPACK_PACKAGE_FILE_NAME="warzone2100_archive" -D CPACK_INCLUDE_TOPLEVEL_DIRECTORY=OFF -D CPACK_ARCHIVE_COMPONENT_INSTALL=ON -D CPACK_COMPONENTS_GROUPING=ALL_COMPONENTS_IN_ONE
OUTPUT_FILE_NAME="warzone2100_${WZ_BUILD_DESC}_archive.zip"
mv "./warzone2100_archive.zip" "${OUTPUT_DIR}/${OUTPUT_FILE_NAME}"
echo "Generated .zip: \"${OUTPUT_FILE_NAME}\""
echo " -> SHA512: $(sha512sum "${OUTPUT_DIR}/${OUTPUT_FILE_NAME}")"
echo " -> Size (bytes): $(stat -c %s "${OUTPUT_DIR}/${OUTPUT_FILE_NAME}")"
echo "WZ_FULL_OUTPUT_ZIP_PATH=${OUTPUT_DIR}/${OUTPUT_FILE_NAME}" >> $GITHUB_ENV
- name: 'Upload Artifact - (Archive)'
uses: actions/upload-artifact@v4
if: success() && (matrix.upload_artifact == true) && (github.repository == 'Warzone2100/warzone2100')
with:
name: warzone2100_${{ env.WZ_BUILD_DESC }}_archive
path: '${{ env.WZ_FULL_OUTPUT_ZIP_PATH }}'
if-no-files-found: 'error'
- name: Generate artifact attestation
# Run on push to master branch (development build), or tag release automation build
if: success() && ((github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event_name == 'workflow_run' && github.event.workflow_run.name == 'Draft Tag Release'))
uses: actions/attest-build-provenance@v1
continue-on-error: true
with:
subject-path: '${{ env.WZ_FULL_OUTPUT_ZIP_PATH }}'
upload_to_release:
strategy:
matrix:
architecture: ["wasm32"]
fail-fast: false
name: 'Upload to Release'
permissions:
contents: write # Needed to upload to releases
runs-on: ubuntu-latest
if: (github.repository == 'Warzone2100/warzone2100') && (github.event_name == 'workflow_run' && github.event.workflow_run.name == 'Draft Tag Release')
needs: web-build
env:
WZ_WASM_ARCH: '${{ matrix.architecture }}'
WZ_BUILD_DESC: 'web_${{ matrix.architecture }}'
steps:
- name: Prep Environment
run: mkdir dl-archive
- name: Download Archive Artifact
uses: actions/download-artifact@v4
with:
name: 'warzone2100_${{ env.WZ_BUILD_DESC }}_archive'
path: ./dl-archive
- name: Upload Release Asset
run: |
SOURCE_TAG="${WZ_GITHUB_REF#refs/tags/}"
gh release upload "${SOURCE_TAG}" "${{ env.WZ_FULL_OUTPUT_ZIP_PATH }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
WZ_GITHUB_REF: ${{ needs.web-build.outputs.WZ_GITHUB_REF }}
WZ_FULL_OUTPUT_ZIP_PATH: ./dl-archive/warzone2100_${{ env.WZ_BUILD_DESC }}_archive.zip
publish_dev_build:
strategy:
matrix:
architecture: ["wasm32"]
fail-fast: false
name: 'Publish Dev Build (${{ matrix.architecture }})'
# Run on push to master branch (development build)
if: (github.repository == 'Warzone2100/warzone2100') && (github.event_name == 'push' && github.ref == 'refs/heads/master')
needs: web-build
uses: ./.github/workflows/publish_web_build.yml
with:
env: webedition_deploy_dev
architecture: ${{ matrix.architecture }}
artifact: 'warzone2100_web_${{ matrix.architecture }}_archive'
built-ref: ${{ needs.web-build.outputs.WZ_GITHUB_REF }}
built-commit-sha: ${{ needs.web-build.outputs.WZ_GITHUB_SHA }}
release: false
ssh-dest-host: ${{ vars.WZ_WEB_BUILD_UPLOAD_SSH_HOST }}
cdn-purge-base-url: 'play.wz2100.net/dev'
secrets: inherit
publish_release_build:
strategy:
matrix:
architecture: ["wasm32"]
fail-fast: false
name: 'Publish Release Build (${{ matrix.architecture }})'
# Run on tag release automation build
# Note: the build will be uploaded to a /release/<tag>/ folder, but will not be set as the "latest" release until the GitHub Release is published
if: (github.repository == 'Warzone2100/warzone2100') && (github.event_name == 'workflow_run' && github.event.workflow_run.name == 'Draft Tag Release')
needs: web-build
uses: ./.github/workflows/publish_web_build.yml
with:
env: webedition_deploy_release
architecture: ${{ matrix.architecture }}
artifact: 'warzone2100_web_${{ matrix.architecture }}_archive'
built-ref: ${{ needs.web-build.outputs.WZ_GITHUB_REF }}
built-commit-sha: ${{ needs.web-build.outputs.WZ_GITHUB_SHA }}
release: true
ssh-dest-host: ${{ vars.WZ_WEB_BUILD_UPLOAD_SSH_HOST }}
cdn-purge-base-url: 'play.wz2100.net/release'
secrets: inherit