-
Notifications
You must be signed in to change notification settings - Fork 3
232 lines (201 loc) · 6.62 KB
/
build-on-push.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
# Builds when a release is published.
name: Build Workflow
on:
push:
branches:
- main
jobs:
create_release:
name: Create release
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]')"
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Get short SHA
id: vars
run: |
echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: r${{ github.run_number }}-${{ github.ref_name }}
release_name: Build ${{ env.GITHUB_SHA_SHORT }}
draft: false
prerelease: true
build:
name: Build for ${{ matrix.os_short }} using sm-${{ matrix.sm_branch }}
needs: create_release
runs-on: ${{ matrix.os }}
# skip build on '[ci skip]'
if: "!contains(github.event.head_commit.message, '[ci skip]')"
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
- windows-latest
target_arch:
- x86
- x86_64
include:
- meta_branch: "master"
sm_branch: "master"
spcomp_version: "1.11.x"
- os: ubuntu-20.04
target_arch: x86
os_short: linux
- os: ubuntu-20.04
target_arch: x86_64
os_short: linux64
- os: windows-latest
target_arch: x86
os_short: win
vs_dev_arch: x86
- os: windows-latest
target_arch: x86_64
os_short: win64
vs_dev_arch: x64
steps:
- name: Prepare env
shell: bash
run: |
echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Install (Linux)
if: runner.os == 'Linux'
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y clang g++-multilib
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
- name: Add msbuild to PATH (Windows)
if: runner.os == 'Windows'
uses: microsoft/[email protected]
- name: Install (Windows)
if: runner.os == 'Windows'
shell: cmd
run: |
:: See https://github.com/microsoft/vswhere/wiki/Find-VC
for /f "usebackq delims=*" %%i in (`vswhere -latest -property installationPath`) do (
call "%%i"\Common7\Tools\vsdevcmd.bat -arch=${{ matrix.vs_dev_arch }} -host_arch=x64
)
:: Loop over all environment variables and make them global.
for /f "delims== tokens=1,2" %%a in ('set') do (
echo>>"%GITHUB_ENV%" %%a=%%b
)
- name: Fetch Metamod:Source ${{ matrix.meta_branch }}
uses: actions/checkout@v2
with:
repository: alliedmodders/metamod-source
ref: ${{ matrix.meta_branch }}
path: mmsource
- name: Fetch SourceMod ${{ matrix.sm_branch }}
uses: actions/checkout@v2
with:
repository: alliedmodders/sourcemod
ref: ${{ matrix.sm_branch }}
path: sourcemod
submodules: recursive
- name: Fetch SDKs
shell: bash
run: |
git clone --mirror https://github.com/alliedmodders/hl2sdk hl2sdk-proxy-repo
sdks=(tf2)
for sdk in "${sdks[@]}"
do
git clone hl2sdk-proxy-repo -b $sdk hl2sdk-$sdk
done
- name: Fetch SDK Manifests
uses: actions/checkout@v2
with:
repository: alliedmodders/hl2sdk-manifests
path: hl2sdk-manifests
- name: Checkout AMBuild
uses: actions/checkout@v3
with:
repository: alliedmodders/ambuild
path: ambuild
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Set up spcomp
uses: rumblefrog/[email protected]
with:
version: ${{ matrix.spcomp_version }}
no-spcomp-proxy: true
- name: Checkout ambuild
run: |
python -m pip install wheel
pip install git+https://github.com/alliedmodders/ambuild
- name: Checkout project
uses: actions/checkout@v3
with:
path: src
- name: Build Files
working-directory: src
run: |
mkdir build
cd build
python3 ../configure.py --sdks=tf2 --sm-path="${{ github.workspace }}/sourcemod" --mms-path="${{ github.workspace }}/mmsource" --symbol-files --enable-optimize --hl2sdk-manifest-path="${{ github.workspace }}/hl2sdk-manifests" --targets ${{ matrix.target_arch }}
ambuild
- name: Upload Build Artifact
id: upload-build-artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os_short }}-${{ matrix.target_arch }}
path: src/build/package
combine_packages:
name: Upload assets for for ${{ matrix.os_short }}
needs: [build, create_release]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
- windows-latest
include:
- os: ubuntu-20.04
os_short: linux
package_ext: .tar.gz
- os: windows-latest
os_short: win
package_ext: zip
steps:
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
path: src/build/package
pattern: ${{ matrix.os_short }}*
merge-multiple: true
- name: Build Package (Windows)
if: runner.os == 'Windows'
working-directory: src/build
shell: cmd
run: |
pushd package
7z a -r "../package.${{ matrix.package_ext }}" addons
popd
- name: Build Package (Linux)
if: runner.os == 'Linux'
working-directory: src/build
shell: bash
run: |
pushd package
tar -czf "../package.${{ matrix.package_ext }}" --owner=0 --group=0 addons
popd
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: src/build/package.${{ matrix.package_ext }}
asset_name: package.${{ matrix.package_ext }}
asset_content_type: application/octet-stream