forked from TheSuperHackers/GeneralsGameCode
-
Notifications
You must be signed in to change notification settings - Fork 0
278 lines (236 loc) · 9.86 KB
/
build-historical.yml
File metadata and controls
278 lines (236 loc) · 9.86 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
name: Build Historical
permissions:
contents: write
on:
workflow_dispatch:
inputs:
commit:
description: 'Commit SHA to build'
required: true
type: string
pull_requests:
description: 'PR numbers to cherry-pick (comma-separated, e.g., "545,876")'
required: false
default: ''
type: string
game:
description: 'Game to build'
required: true
default: 'GeneralsMD'
type: choice
options:
- 'Generals'
- 'GeneralsMD'
- 'Both'
create_release:
description: 'Create a GitHub release'
required: false
default: 'true'
type: choice
options:
- 'true'
- 'false'
concurrency:
group: ${{ github.workflow }}-${{ github.event.inputs.commit }}
cancel-in-progress: false
jobs:
prepare:
name: Prepare Build Info
runs-on: ubuntu-latest
outputs:
short_sha: ${{ steps.info.outputs.short_sha }}
commit_date: ${{ steps.info.outputs.commit_date }}
commit_subject: ${{ steps.info.outputs.commit_subject }}
release_tag: ${{ steps.info.outputs.release_tag }}
steps:
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
fetch-tags: true
- name: Gather Commit Info
id: info
run: |
COMMIT="${{ github.event.inputs.commit }}"
if ! git cat-file -e "$COMMIT^{commit}" 2>/dev/null; then
echo "::error::Commit $COMMIT not found in repository"
exit 1
fi
SHORT_SHA=$(git rev-parse --short=7 "$COMMIT")
COMMIT_DATE=$(git show -s --format=%cs "$COMMIT")
COMMIT_SUBJECT=$(git show -s --format=%s "$COMMIT" | head -c 80)
PR_SUFFIX=""
if [ -n "${{ github.event.inputs.pull_requests }}" ]; then
PR_SUFFIX="+pr${{ github.event.inputs.pull_requests }}"
fi
RELEASE_TAG="historical-${COMMIT_DATE}-${SHORT_SHA}${PR_SUFFIX}"
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
echo "commit_date=$COMMIT_DATE" >> $GITHUB_OUTPUT
echo "commit_subject=$COMMIT_SUBJECT" >> $GITHUB_OUTPUT
echo "release_tag=$RELEASE_TAG" >> $GITHUB_OUTPUT
echo "### Build Info" >> $GITHUB_STEP_SUMMARY
echo "- Commit: \`$COMMIT\` ($SHORT_SHA)" >> $GITHUB_STEP_SUMMARY
echo "- Date: $COMMIT_DATE" >> $GITHUB_STEP_SUMMARY
echo "- Subject: $COMMIT_SUBJECT" >> $GITHUB_STEP_SUMMARY
echo "- PRs to apply: ${{ github.event.inputs.pull_requests || 'none' }}" >> $GITHUB_STEP_SUMMARY
echo "- Release tag: $RELEASE_TAG" >> $GITHUB_STEP_SUMMARY
build:
name: Build ${{ matrix.game }} vc6
needs: prepare
runs-on: windows-2022
timeout-minutes: 30
strategy:
matrix:
game: ${{ github.event.inputs.game == 'Both' && fromJson('["Generals", "GeneralsMD"]') || fromJson(format('["{0}"]', github.event.inputs.game)) }}
fail-fast: false
steps:
- name: Checkout Target Commit
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.inputs.commit }}
fetch-depth: 0
- name: Apply Pull Requests
if: ${{ github.event.inputs.pull_requests != '' }}
shell: bash
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
PR_LIST="${{ github.event.inputs.pull_requests }}"
IFS=',' read -ra PRS <<< "$PR_LIST"
for PR in "${PRS[@]}"; do
PR=$(echo "$PR" | xargs)
echo "::group::Applying PR #$PR"
git fetch origin "pull/$PR/head:pr-$PR"
PR_BASE=$(git merge-base pr-$PR HEAD)
PR_COMMITS=$(git rev-list --reverse "$PR_BASE..pr-$PR")
for COMMIT in $PR_COMMITS; do
echo "Cherry-picking $COMMIT"
if ! git cherry-pick --no-commit "$COMMIT"; then
echo "::error::Failed to cherry-pick commit $COMMIT from PR #$PR"
git cherry-pick --abort || true
exit 1
fi
done
git commit -m "Apply PR #$PR" || echo "No changes to commit for PR #$PR"
echo "::endgroup::"
done
- name: Cache VC6 Installation
id: cache-vc6
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: C:\VC6
key: vc6-permanent-cache-v2
- name: Download VC6 Portable
if: ${{ steps.cache-vc6.outputs.cache-hit != 'true' }}
env:
EXPECTED_HASH: "D0EE1F6DCEF7DB3AD703120D9FB4FAD49EBCA28F44372E40550348B1C00CA583"
VC6_COMMIT: "001c4bafdcf2ef4b474d693acccd35a91e848f40"
shell: pwsh
run: |
Invoke-WebRequest -Uri https://github.com/itsmattkc/MSVC600/archive/$env:VC6_COMMIT.zip -OutFile VS6_VisualStudio6.zip
$fileHash = (Get-FileHash -Path VS6_VisualStudio6.zip -Algorithm SHA256).Hash
if ($fileHash -ne $env:EXPECTED_HASH) {
Write-Error "Hash verification failed!"
exit 1
}
Expand-Archive -Path VS6_VisualStudio6.zip -DestinationPath C:\VC6
Move-Item -Path C:\VC6\MSVC600-$env:VC6_COMMIT -Destination C:\VC6\VC6SP6
Remove-Item VS6_VisualStudio6.zip
- name: Set Up VC6 Environment
shell: pwsh
run: |
$VSCommonDir = "C:\VC6\VC6SP6\Common"
$MSDevDir = "C:\VC6\VC6SP6\Common\msdev98"
$MSVCDir = "C:\VC6\VC6SP6\VC98"
$VcOsDir = "WINNT"
"VSCommonDir=$VSCommonDir" >> $env:GITHUB_ENV
"MSDevDir=$MSDevDir" >> $env:GITHUB_ENV
"MSVCDir=$MSVCDir" >> $env:GITHUB_ENV
"VcOsDir=$VcOsDir" >> $env:GITHUB_ENV
"PATH=$MSDevDir\BIN;$MSVCDir\BIN;$VSCommonDir\TOOLS\$VcOsDir;$VSCommonDir\TOOLS;$env:PATH" >> $env:GITHUB_ENV
"INCLUDE=$MSVCDir\ATL\INCLUDE;$MSVCDir\INCLUDE;$MSVCDir\MFC\INCLUDE;$env:INCLUDE" >> $env:GITHUB_ENV
"LIB=$MSVCDir\LIB;$MSVCDir\MFC\LIB;$env:LIB" >> $env:GITHUB_ENV
- name: Configure with CMake
shell: pwsh
run: |
$buildFlags = @(
"-DRTS_BUILD_ZEROHOUR=${{ matrix.game == 'GeneralsMD' && 'ON' || 'OFF' }}",
"-DRTS_BUILD_GENERALS=${{ matrix.game == 'Generals' && 'ON' || 'OFF' }}",
"-DRTS_BUILD_CORE_TOOLS=ON",
"-DRTS_BUILD_${{ matrix.game == 'Generals' && 'GENERALS' || 'ZEROHOUR' }}_TOOLS=ON"
)
cmake --preset vc6 $buildFlags
- name: Build with CMake
shell: pwsh
run: |
cmake --build --preset vc6
- name: Collect Artifacts
shell: pwsh
run: |
$buildDir = "build\vc6"
$artifactsDir = New-Item -ItemType Directory -Force -Path "$buildDir\${{ matrix.game }}\artifacts"
$files = Get-ChildItem -Path "$buildDir\Core","$buildDir\${{ matrix.game }}" -File |
Where-Object { $_.Extension -in @(".exe", ".dll", ".pdb") }
$files | Move-Item -Destination $artifactsDir -Force
- name: Upload Artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: ${{ matrix.game }}-vc6-${{ needs.prepare.outputs.short_sha }}
path: build\vc6\${{ matrix.game }}\artifacts
retention-days: 90
create-release:
name: Create Release
needs: [prepare, build]
if: ${{ github.event.inputs.create_release == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Download Generals Artifact
if: ${{ github.event.inputs.game == 'Generals' || github.event.inputs.game == 'Both' }}
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
name: Generals-vc6-${{ needs.prepare.outputs.short_sha }}
path: generals-artifacts
- name: Download GeneralsMD Artifact
if: ${{ github.event.inputs.game == 'GeneralsMD' || github.event.inputs.game == 'Both' }}
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
name: GeneralsMD-vc6-${{ needs.prepare.outputs.short_sha }}
path: generalsmd-artifacts
- name: Prepare Release Archives
run: |
if [ -d "generals-artifacts" ]; then
zip -jr generals-${{ needs.prepare.outputs.release_tag }}.zip generals-artifacts/*
fi
if [ -d "generalsmd-artifacts" ]; then
zip -jr generalszh-${{ needs.prepare.outputs.release_tag }}.zip generalsmd-artifacts/*
fi
- name: Generate Release Notes
id: notes
run: |
BODY="## Historical Build
**Commit:** \`${{ github.event.inputs.commit }}\`
**Date:** ${{ needs.prepare.outputs.commit_date }}
**Subject:** ${{ needs.prepare.outputs.commit_subject }}"
if [ -n "${{ github.event.inputs.pull_requests }}" ]; then
BODY="${BODY}
**Applied PRs:** ${{ github.event.inputs.pull_requests }}"
fi
BODY="${BODY}
---
*Built for replay compatibility testing.*"
echo "body<<EOF" >> $GITHUB_OUTPUT
echo "$BODY" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
with:
tag_name: ${{ needs.prepare.outputs.release_tag }}
name: ${{ needs.prepare.outputs.release_tag }}
prerelease: true
body: ${{ steps.notes.outputs.body }}
files: |
generals-${{ needs.prepare.outputs.release_tag }}.zip
generalszh-${{ needs.prepare.outputs.release_tag }}.zip
fail_on_unmatched_files: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}