-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (141 loc) · 6.47 KB
/
build.yml
File metadata and controls
167 lines (141 loc) · 6.47 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
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
name: Build & Latest Release (Linux + Windows)
on:
pull_request:
branches: [ master ]
push:
branches: [ master ]
workflow_dispatch:
permissions:
contents: write
jobs:
# ───────────────────────────────────────────────────────── build ──
build:
env: # ←─ use block style, no braces
SHORT_SHA: ${{ github.sha }}
strategy:
matrix:
include:
- os: ubuntu-22.04
cfg: linux-release
build: linux-build
isLinux: true
- os: windows-2022
cfg: windows-release
build: windows-build
isLinux: false
runs-on: ${{ matrix.os }}
steps:
# 1) checkout & deps ─────────────────────────────────────────────
- uses: actions/checkout@v4
- name: Install packages (apt)
if: matrix.isLinux
run: |
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends \
clang ninja-build cmake build-essential \
libxmu-dev libxi-dev libxinerama-dev libxrandr-dev \
libxcursor-dev libudev-dev libopenal-dev unixodbc-dev \
libgl1-mesa-dev libxxf86vm-dev zlib1g-dev
- name: Set up MSVC env
if: matrix.os == 'windows-2022'
uses: ilammy/msvc-dev-cmd@v1
with: { arch: x64 }
- name: Verify Ninja on PATH
run: ninja --version
# 2) unzip engine files ──────────────────────────────────────────
- name: Unzip Engine files (Linux)
if: matrix.isLinux
run: |
unzip -q assets/Engine.zip -d assets
unzip -q third_party/EE/Engine.zip -d third_party/EE
- name: Unzip Engine files (Windows)
if: matrix.os == 'windows-2022'
shell: pwsh
run: |
Expand-Archive assets/Engine.zip -DestinationPath assets -Force
Get-ChildItem third_party/EE -Filter '*.zip' |
ForEach-Object { Expand-Archive $_.FullName -DestinationPath third_party/EE -Force }
# 3) configure → build → test ───────────────────────────────────
- name: Configure
run: cmake --preset ${{ matrix.cfg }}
- name: Build
run: cmake --build --preset ${{ matrix.build }}
- name: Run unit tests
run: ctest --test-dir out/build/${{ matrix.cfg }} --output-on-failure
# 4) package + archive ──────────────────────────────────────────
- name: Package & archive (Linux)
if: matrix.isLinux
run: |
set -euo pipefail
STAGE=out/dist
mkdir -p "$STAGE/Bin"
cp "out/build/${{ matrix.cfg }}/apps/client/client" "$STAGE/client"
cp "out/build/${{ matrix.cfg }}/apps/server/server" "$STAGE/server"
cp assets/Engine.pak "$STAGE/Bin/Engine.pak"
cp assets/Project.pak "$STAGE/Bin/Project.pak"
ARCHIVE=linux_binaries_${SHORT_SHA:0:8}.tar.gz
tar -czf "$ARCHIVE" -C "$STAGE" .
echo "ARCHIVE_PATH=$ARCHIVE" >> $GITHUB_ENV
- name: Package & archive (Windows)
if: matrix.os == 'windows-2022'
shell: pwsh
run: |
$Stage = "out/dist"
New-Item "$Stage/Bin" -ItemType Directory -Force | Out-Null
Copy-Item "out/build/${{ matrix.cfg }}/apps/client/client.exe" "$Stage/client.exe"
Copy-Item "out/build/${{ matrix.cfg }}/apps/server/server.exe" "$Stage/server.exe"
Copy-Item "assets/Engine.pak" "$Stage/Bin/Engine.pak"
Copy-Item "assets/Project.pak" "$Stage/Bin/Project.pak"
$sha = $env:SHORT_SHA.Substring(0,8)
$archive = "windows_binaries_${sha}.zip"
Compress-Archive -Path "$Stage/*" -DestinationPath $archive
echo "ARCHIVE_PATH=$archive" >> $env:GITHUB_ENV
# 5) upload exactly that one file ────────────────────────────────
- name: Upload platform archive
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.os }}
path: ${{ env.ARCHIVE_PATH }}
retention-days: 2
# ───────────────────────────────────────────────────── release ──
release:
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# 1) Clean slate: delete old “latest” release + tag (if present)
- name: Delete previous Latest release
env:
GITHUB_TOKEN: ${{ github.token }} # <- use the name gh expects
run: |
# The CLI exits 1 if the release/tag doesn't exist; ignore that.
gh release delete latest --cleanup-tag --yes --repo "$GITHUB_REPOSITORY" 2>&1 | \
grep -v "release.*not found" || true
# 2) Download fresh archives built by the matrix
- name: Download platform archives
uses: actions/download-artifact@v4
with:
pattern: binaries-*
merge-multiple: true
path: release # → release/*.zip / *.tar.gz
# 3) Metadata for title & body
- name: Build release metadata
id: vars
run: |
echo "timestamp=$(date -u +'%Y-%m-%d %H:%M UTC')" >> $GITHUB_OUTPUT
echo "short_sha=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
# 4) Publish brand-new Latest release with ONLY the two archives
- name: Publish Latest release
uses: softprops/action-gh-release@v2
with:
tag_name: latest
make_latest: true
name: Latest build – ${{ steps.vars.outputs.timestamp }}
body: |
Automatic build from commit \
[`${{ steps.vars.outputs.short_sha }}`]\
(${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}).
files: |
release/*.zip
release/*.tar.gz