-
Notifications
You must be signed in to change notification settings - Fork 5
224 lines (189 loc) · 7.45 KB
/
Build_Win64_DX12.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
name: "Build Win64 DX12"
on:
workflow_dispatch:
push:
paths:
- "src/version.h"
env:
SOLUTION_FILE_PATH: vgframework.sln
BUILD_PLATFORM: '"Win64 DX12"'
permissions:
contents: write
jobs:
build_editor:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- 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 }}
- name: Build Release
run: msbuild /m /p:Configuration=Release /p:Platform=${{ env.BUILD_PLATFORM }} ${{ env.SOLUTION_FILE_PATH }}
- name: Upload Release Artifacts
if: success()
uses: actions/upload-artifact@v3
with:
name: release-artifacts
path: |
src/commit.h
VGFramework_x64_Release_DX12.exe
build\bin\x64\Release\audio.dll
build\bin\x64\Release\editor.dll
build\bin\x64\Release\engine.dll
build\bin\x64\Release\game.dll
build\bin\x64\Release\physics.dll
build\bin\x64\Release_DX12\renderer.dll
build_game:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- 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 }}
- name: Build Final
run: msbuild /m /p:Configuration=Final /p:Platform=${{ env.BUILD_PLATFORM }} ${{ env.SOLUTION_FILE_PATH }}
- name: Upload Final Artifacts
if: success()
uses: actions/upload-artifact@v3
with:
name: final-artifacts
path: |
src/commit.h
VGFramework_x64_Final_DX12.exe
build\bin\x64\Final\audio.dll
build\bin\x64\Final\engine.dll
build\bin\x64\Final\game.dll
build\bin\x64\Final\physics.dll
build\bin\x64\Final_DX12\renderer.dll
submit_binaries:
runs-on: windows-latest
needs: [build_editor, build_game]
steps:
- uses: actions/checkout@v4
- name: Download Release Artifacts
uses: actions/download-artifact@v3
with:
name: release-artifacts
path: ${{ env.GITHUB_WORKSPACE }}
- name: Download Final Artifacts
uses: actions/download-artifact@v3
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 "[email protected]"
# Stage Editor files
git add -f "Editor.exe"
git add -f "bin\x64\Release\audio.dll"
git add -f "bin\x64\Release\editor.dll"
git add -f "bin\x64\Release\engine.dll"
git add -f "bin\x64\Release\game.dll"
git add -f "bin\x64\Release\physics.dll"
git add -f "bin\x64\Release_DX12\renderer.dll"
# Stage Game files
git add -f "Game.exe"
git add -f "bin\x64\Final\audio.dll"
git add -f "bin\x64\Final\engine.dll"
git add -f "bin\x64\Final\game.dll"
git add -f "bin\x64\Final\physics.dll"
git add -f "bin\x64\Final_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": "A new version of VGFramework is 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"