-
Notifications
You must be signed in to change notification settings - Fork 4
285 lines (246 loc) · 9.54 KB
/
Build_Version.yml
File metadata and controls
285 lines (246 loc) · 9.54 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
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
name: "Build Version"
on:
workflow_dispatch:
push:
paths:
- "src/version.h"
env:
SOLUTION_FILE_PATH_WIN64: vgframework_vs2022.sln
BUILD_PLATFORM_WIN64: '"Win64 MSVC DX12"'
permissions:
contents: write
jobs:
build_editor:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Generate Projects
working-directory: ./sharpmake
shell: cmd
run: generate_projects_Windows.bat
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2
with:
vs-version: '[17.11.2, 18.0.0)'
- name: Restore NuGet packages
run: nuget restore ${{ env.SOLUTION_FILE_PATH_WIN64 }}
- name: Build Editor Release
run: msbuild /m /p:Configuration=Release /p:Platform=${{ env.BUILD_PLATFORM_WIN64 }} ${{ env.SOLUTION_FILE_PATH_WIN64 }}
- name: Upload Release Artifacts
if: success()
uses: actions/upload-artifact@v4
with:
name: release-artifacts
path: |
src/commit.h
editor.exe
build/bin/win64/release msvc/audio.dll
build/bin/win64/release msvc/editor.dll
build/bin/win64/release msvc/engine.dll
build/bin/win64/release msvc/game.dll
build/bin/win64/release msvc/physics.dll
build/bin/win64/release msvc DX12\renderer.dll
- name: Verify Uploaded Release Artifacts
shell: pwsh
run: |
$expectedFiles = @(
"src/commit.h",
"editor.exe",
"build/bin/win64/release msvc/audio.dll",
"build/bin/win64/release msvc/editor.dll",
"build/bin/win64/release msvc/engine.dll",
"build/bin/win64/release msvc/game.dll",
"build/bin/win64/release msvc/physics.dll",
"build/bin/win64/release msvc DX12/renderer.dll"
)
$missing = @()
foreach ($file in $expectedFiles) {
if (-not (Test-Path $file)) {
$missing += $file
}
}
if ($missing.Count -gt 0) {
Write-Host "Missing files:" $missing
exit 1
} else {
Write-Host "All expected release files found and uploaded."
}
build_game:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Generate Projects
working-directory: ./sharpmake
shell: cmd
run: generate_projects_Windows.bat
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2
with:
vs-version: '[17.11.2, 18.0.0)'
- name: Restore NuGet packages
run: nuget restore ${{ env.SOLUTION_FILE_PATH_WIN64 }}
- name: Build Game Final
run: msbuild /m /p:Configuration=Final /p:Platform=${{ env.BUILD_PLATFORM_WIN64 }} ${{ env.SOLUTION_FILE_PATH_WIN64 }}
- name: Upload Final Artifacts
if: success()
uses: actions/upload-artifact@v4
with:
name: final-artifacts
path: |
src/commit.h
game.exe
build/bin/win64/final msvc/audio.dll
build/bin/win64/final msvc/engine.dll
build/bin/win64/final msvc/game.dll
build/bin/win64/final msvc/physics.dll
build/bin/win64/final msvc DX12\renderer.dll
- name: Verify Uploaded Final Artifacts
shell: pwsh
run: |
$expectedFiles = @(
"src/commit.h",
"game.exe",
"build/bin/win64/final msvc/audio.dll",
"build/bin/win64/final msvc/engine.dll",
"build/bin/win64/final msvc/game.dll",
"build/bin/win64/final msvc/physics.dll",
"build/bin/win64/final msvc DX12/renderer.dll"
)
$missing = @()
foreach ($file in $expectedFiles) {
if (-not (Test-Path $file)) {
$missing += $file
}
}
if ($missing.Count -gt 0) {
Write-Host "Missing files:" $missing
exit 1
} else {
Write-Host "All expected final files found and uploaded."
}
submit_binaries:
runs-on: windows-latest
needs: [build_editor, build_game]
steps:
- uses: actions/checkout@v4
- name: Download Release Artifacts
uses: actions/download-artifact@v4
with:
name: release-artifacts
path: ${{ env.GITHUB_WORKSPACE }}
- name: Download Final Artifacts
uses: actions/download-artifact@v4
with:
name: final-artifacts
path: ${{ env.GITHUB_WORKSPACE }}
- name: Read version, copy client files, and push binaries
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: |
# Read GIT_REVISION from commit.h
$versionContent = Get-Content "src/commit.h"
$gitRevision = ""
foreach ($line in $versionContent) {
if ($line -like '*#define GIT_REVISION*') {
$parts = $line -split '"'
$gitRevision = $parts[1]
break
}
}
# Read version from version.h
$versionContent = Get-Content "src/version.h"
$major, $minor, $patch = "", "", ""
foreach ($line in $versionContent) {
if ($line -match '#define VG_FRAMEWORK_VERSION_MAJOR (\d+)') {
$major = $matches[1]
} elseif ($line -match '#define VG_FRAMEWORK_VERSION_MINOR (\d+)') {
$minor = $matches[1]
} elseif ($line -match '#define VG_FRAMEWORK_VERSION_PATCH (\d+)') {
$patch = $matches[1]
}
}
$fullVersion = "$major.$minor.$patch"
$commitMessage = "Editor and Game $fullVersion ($gitRevision)"
Write-Host "Commit message: $commitMessage"
# Run the batch file to create client file copies
cmd /c script\copy_client_files.bat
# Configure Git and push changes
git config user.name "VGF_Boy"
git config user.email "VGF_Boy@users.noreply.github.com"
# Stage Editor files
git add -f "editor.exe"
git add -f "bin\win64\release msvc\audio.dll"
git add -f "bin\win64\release msvc\editor.dll"
git add -f "bin\win64\release msvc\engine.dll"
git add -f "bin\win64\release msvc\game.dll"
git add -f "bin\win64\release msvc\physics.dll"
git add -f "bin\win64\release msvc DX12\renderer.dll"
# Stage Game files
git add -f "game.exe"
git add -f "bin\win64\final msvc\audio.dll"
git add -f "bin\win64\final msvc\engine.dll"
git add -f "bin\win64\final msvc\game.dll"
git add -f "bin\win64\final msvc\physics.dll"
git add -f "bin\win64\final msvc DX12\renderer.dll"
git commit -m "$commitMessage"
git push
- name: Send Discord Notification
shell: pwsh
run: |
$DISCORD_RELEASE_WEBHOOK_URL = "${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}"
$jobName = "${{ github.job }}"
$runId = "${{ github.run_id }}"
$repo = "${{ github.repository }}"
$serverUrl = "${{ github.server_url }}"
$jobsApiUrl = "https://api.github.com/repos/$repo/actions/runs/$runId/jobs"
$jobId = (curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" $jobsApiUrl | ConvertFrom-Json).jobs | Where-Object { $_.name -eq $jobName } | Select-Object -ExpandProperty id
$jobUrl = "$serverUrl/$repo/actions/runs/$runId/job/$jobId"
$commitSha = "${{ github.sha }}"
$shortCommitSha = $commitSha.Substring(0, 7)
$versionContent = Get-Content "src/version.h"
$major, $minor, $patch = "", "", ""
foreach ($line in $versionContent) {
if ($line -match '#define VG_FRAMEWORK_VERSION_MAJOR (\d+)') {
$major = $matches[1]
} elseif ($line -match '#define VG_FRAMEWORK_VERSION_MINOR (\d+)') {
$minor = $matches[1]
} elseif ($line -match '#define VG_FRAMEWORK_VERSION_PATCH (\d+)') {
$patch = $matches[1]
}
}
$fullVersion = "$major.$minor.$patch"
$commitContent = Get-Content "src/commit.h"
$gitRevision = ""
foreach ($line in $commitContent) {
if ($line -like '*#define GIT_REVISION*') {
$parts = $line -split '"'
$gitRevision = $parts[1]
break
}
}
$jsonPayload = @"
{
"username": "VGF_Boy",
"content": "",
"embeds": [
{
"type": "rich",
"title": "VGFramework $fullVersion ``$gitRevision``",
"description": "New vgframework version available",
"color": 15579707,
"thumbnail": {
"url": "https://github.com/vimontgames/vgframework/blob/master/doc/img/version.png?raw=true"
},
"author": {
"name": "$($env:GITHUB_ACTOR)",
"url": "https://github.com/$($env:GITHUB_ACTOR)",
"icon_url": "https://avatars.githubusercontent.com/u/$($env:GITHUB_ACTOR_ID)?v=4"
},
"url": "$jobUrl"
}
]
}
"@
# Send the notification using curl
$RESPONSE = curl -H "Content-Type: application/json" -X POST -d $jsonPayload $DISCORD_RELEASE_WEBHOOK_URL
# Output the response from the server
Write-Output "Webhook server response: $RESPONSE"