Skip to content

Commit ad803af

Browse files
committed
[GITHUB] Add weekly pre-releases workflow for Generals and GeneralsMD
1 parent 1eceff5 commit ad803af

File tree

9 files changed

+451
-40
lines changed

9 files changed

+451
-40
lines changed

.github/workflows/build-toolchain.yml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ on:
2525
default: false
2626
type: boolean
2727
description: "Build extras"
28+
release-name:
29+
required: false
30+
type: string
31+
description: "Release name for the build, used in versioning"
32+
build_user:
33+
required: false
34+
type: string
35+
description: "Override VERSION_BUILDUSER"
36+
build_loc:
37+
required: false
38+
type: string
39+
description: "Override VERSION_BUILDLOC"
40+
build_num:
41+
required: false
42+
type: string
43+
description: "Override VERSION_BUILDNUM"
2844

2945
jobs:
3046
build:
@@ -41,10 +57,10 @@ jobs:
4157
uses: actions/cache@v4
4258
with:
4359
path: C:\VC6
44-
key: vc6-permanent-cache-v2
60+
key: vc6-permanent-cache-v3
4561

4662
- name: Cache CMake Dependencies
47-
id: cache-cmake-deps
63+
id: cache-cmake-deps-v2
4864
uses: actions/cache@v4
4965
with:
5066
path: build\${{ inputs.preset }}\_deps
@@ -110,6 +126,22 @@ jobs:
110126
"-DRTS_BUILD_GENERALS=${{ inputs.game == 'Generals' && 'ON' || 'OFF' }}"
111127
)
112128
129+
if ("${{ inputs.release-name }}") {
130+
$buildFlags += "-DRELEASE_NAME:STRING=${{ inputs.release-name }}"
131+
}
132+
133+
if ("${{ inputs.build_user }}") {
134+
$buildFlags += "-DVERSION_BUILDUSER:STRING=${{ inputs.build_user }}"
135+
}
136+
137+
if ("${{ inputs.build_loc }}") {
138+
$buildFlags += "-DVERSION_BUILDLOC:STRING=${{ inputs.build_loc }}"
139+
}
140+
141+
if ("${{ inputs.build_num }}") {
142+
$buildFlags += "-DVERSION_BUILDNUM:INT=${{ inputs.build_num }}"
143+
}
144+
113145
$gamePrefix = "${{ inputs.game == 'Generals' && 'GENERALS' || 'ZEROHOUR' }}"
114146
$buildFlags += "-DRTS_BUILD_CORE_TOOLS=${{ inputs.tools && 'ON' || 'OFF' }}"
115147
$buildFlags += "-DRTS_BUILD_${gamePrefix}_TOOLS=${{ inputs.tools && 'ON' || 'OFF' }}"

.github/workflows/weekly-release.yml

Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
name: Weekly Release
2+
3+
permissions:
4+
contents: write
5+
pull-requests: write
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
build_notes:
11+
description: 'Build notes (optional)'
12+
required: false
13+
default: ''
14+
type: string
15+
known_issues:
16+
description: 'Known issues (optional)'
17+
required: false
18+
default: ''
19+
type: string
20+
force_changed:
21+
description: 'Force build'
22+
required: false
23+
default: 'false'
24+
type: choice
25+
options:
26+
- 'false'
27+
- 'true'
28+
pre-release:
29+
description: 'Mark release as pre-release'
30+
required: false
31+
default: 'false'
32+
type: choice
33+
options:
34+
- 'false'
35+
- 'true'
36+
build_user:
37+
description: 'Override BUILDUSER (optional)'
38+
required: false
39+
type: string
40+
build_loc:
41+
description: 'override BUILDLOC (optional)'
42+
required: false
43+
type: string
44+
45+
schedule:
46+
- cron: '0 8 * * 5'
47+
48+
concurrency:
49+
group: ${{ github.workflow }}-${{ github.ref }}
50+
cancel-in-progress: true
51+
52+
jobs:
53+
get-date:
54+
runs-on: ubuntu-latest
55+
outputs:
56+
date: ${{ steps.date.outputs.date }}
57+
steps:
58+
- name: Get current date
59+
id: date
60+
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
61+
62+
detect-scm-changes:
63+
needs: [get-date]
64+
runs-on: ubuntu-latest
65+
outputs:
66+
changed: ${{ steps.check.outputs.changed }}
67+
steps:
68+
- uses: actions/checkout@v4
69+
with:
70+
fetch-depth: 0
71+
fetch-tags: true
72+
- id: check
73+
run: |
74+
if [ "${{ github.event.inputs.force_changed }}" = "true" ]; then
75+
echo "changed=true" >> $GITHUB_OUTPUT
76+
exit 0
77+
fi
78+
79+
echo LAST TAG:
80+
git describe --tags --abbrev=0 2>/dev/null || echo ""
81+
82+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
83+
if [ -z "$LAST_TAG" ]; then
84+
echo "changed=true" >> $GITHUB_OUTPUT
85+
exit 0
86+
fi
87+
CHANGED=$(git diff --name-only $LAST_TAG..HEAD | grep -v '.github/workflows/' | wc -l)
88+
if [ "$CHANGED" -eq "0" ]; then
89+
echo "changed=false" >> $GITHUB_OUTPUT
90+
else
91+
echo "changed=true" >> $GITHUB_OUTPUT
92+
fi
93+
94+
build-generals:
95+
needs: [detect-scm-changes, get-date]
96+
if: needs.detect-scm-changes.outputs.changed == 'true'
97+
name: Build Generals${{ matrix.preset && '' }}
98+
strategy:
99+
matrix:
100+
include:
101+
- preset: "vc6"
102+
tools: true
103+
extras: false
104+
release: true
105+
fail-fast: false
106+
uses: ./.github/workflows/build-toolchain.yml
107+
with:
108+
game: "Generals"
109+
preset: ${{ matrix.preset }}
110+
tools: ${{ matrix.tools }}
111+
extras: ${{ matrix.extras }}
112+
release-name: ${{ needs.get-date.outputs.date }}
113+
build_user: ${{ github.event.inputs.build_user || 'TheSuperHackers' }}
114+
build_loc: ${{ github.event.inputs.build_loc || 'https://github.com/TheSuperHackers/GeneralsGameCode/' }}
115+
build_num: ${{ needs.calculate-version.outputs.tag_count }}
116+
secrets: inherit
117+
118+
build-generalsmd:
119+
needs: [detect-scm-changes, get-date]
120+
if: needs.detect-scm-changes.outputs.changed == 'true'
121+
name: Build GeneralsMD${{ matrix.preset && '' }}
122+
strategy:
123+
matrix:
124+
include:
125+
- preset: "vc6"
126+
tools: true
127+
extras: false
128+
release: true
129+
fail-fast: false
130+
uses: ./.github/workflows/build-toolchain.yml
131+
with:
132+
game: "GeneralsMD"
133+
preset: ${{ matrix.preset }}
134+
tools: ${{ matrix.tools }}
135+
extras: ${{ matrix.extras }}
136+
release-name: ${{ needs.get-date.outputs.date }}
137+
build_user: ${{ github.event.inputs.build_user || 'TheSuperHackers' }}
138+
build_loc: ${{ github.event.inputs.build_loc || 'https://github.com/TheSuperHackers/GeneralsGameCode/' }}
139+
build_num: ${{ needs.calculate-version.outputs.tag_count }}
140+
secrets: inherit
141+
142+
create-release:
143+
name: Create Release
144+
needs: [build-generals, build-generalsmd, get-date]
145+
runs-on: ubuntu-latest
146+
steps:
147+
- name: Checkout repository
148+
uses: actions/checkout@v4
149+
with:
150+
fetch-depth: 0
151+
fetch-tags: true
152+
153+
- name: Collect commits since last release
154+
id: changelog
155+
run: |
156+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
157+
if [ -z "$LAST_TAG" ]; then
158+
CHANGELOG_COMMITS=$(git log --pretty="format:- %s" --no-merges HEAD | head -n 10 || true)
159+
else
160+
CHANGELOG_COMMITS=$(git log --pretty="format:- %s" --no-merges "$LAST_TAG"..HEAD || true)
161+
fi
162+
if [ -z "$CHANGELOG_COMMITS" ]; then
163+
CHANGELOG_COMMITS="- No relevant changes detected since the last release."
164+
fi
165+
{
166+
echo 'commits<<CHANGELOG_EOF'
167+
echo "$CHANGELOG_COMMITS"
168+
echo 'CHANGELOG_EOF'
169+
} >> "$GITHUB_OUTPUT"
170+
171+
# Generals vc6
172+
- name: Download Generals VC6 Artifacts
173+
uses: actions/download-artifact@v4
174+
with:
175+
name: Generals-vc6+t
176+
path: generals-vc6-artifacts
177+
178+
- name: Prepare and Zip Generals VC6
179+
run: |
180+
mkdir generals-vc6-release
181+
cp generals-vc6-artifacts/generalsv.exe generals-vc6-release/GeneralsV.exe
182+
cp generals-vc6-artifacts/W3DViewV.exe generals-vc6-release/W3DViewV.exe
183+
cp generals-vc6-artifacts/WorldBuilderV.exe generals-vc6-release/WorldBuilderV.exe
184+
zip -j generals-preview-${{ needs.get-date.outputs.date }}.zip generals-vc6-release/*
185+
186+
# GeneralsMD vc6
187+
- name: Download GeneralsMD VC6 Artifacts
188+
uses: actions/download-artifact@v4
189+
with:
190+
name: GeneralsMD-vc6+t
191+
path: generalsmd-vc6-artifacts
192+
193+
- name: Prepare and Zip GeneralsMD VC6
194+
run: |
195+
mkdir generalsmd-vc6-release
196+
cp generalsmd-vc6-artifacts/generalszh.exe generalsmd-vc6-release/GeneralsZHv.exe
197+
cp generalsmd-vc6-artifacts/W3DViewZH.exe generalsmd-vc6-release/W3DViewZHv.exe
198+
cp generalsmd-vc6-artifacts/WorldBuilderZH.exe generalsmd-vc6-release/WorldBuilderZHv.exe
199+
zip -j generalszh-preview-${{ needs.get-date.outputs.date }}.zip generalsmd-vc6-release/*
200+
201+
- name: Generate release notes
202+
id: release_body
203+
run: |
204+
BODY=""
205+
if [ "${{ github.event.inputs.build_notes }}" != "" ]; then
206+
BODY="${BODY}### Build notes\n${{ github.event.inputs.build_notes }}\n"
207+
fi
208+
if [ "${{ github.event.inputs.known_issues }}" != "" ]; then
209+
BODY="${BODY}### Known issues\n${{ github.event.inputs.known_issues }}\n"
210+
fi
211+
BODY="${BODY}### Changelog\n${{ steps.changelog.outputs.commits }}"
212+
echo "body<<EOF" >> $GITHUB_OUTPUT
213+
echo -e "$BODY" >> $GITHUB_OUTPUT
214+
echo "EOF" >> $GITHUB_OUTPUT
215+
216+
- name: Create GitHub Release
217+
uses: softprops/action-gh-release@v2
218+
with:
219+
tag_name: preview-${{ needs.get-date.outputs.date }}
220+
name: preview-${{ needs.get-date.outputs.date }}
221+
prerelease: ${{ github.event.inputs.pre-release == 'true' }}
222+
body: ${{ steps.release_body.outputs.body }}
223+
files: |
224+
generals-preview-${{ needs.get-date.outputs.date }}.zip
225+
generalszh-preview-${{ needs.get-date.outputs.date }}.zip
226+
env:
227+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
228+
229+
- name: Clean up release folders
230+
if: always()
231+
run: |
232+
rm -rf generals-vc6-release generalsmd-vc6-release
233+
rm -rf generals-vc6-artifacts generalsmd-vc6-artifacts
234+
rm -f generals-preview-${{ needs.get-date.outputs.date }}.zip
235+
rm -f generalszh-preview-${{ needs.get-date.outputs.date }}.zip

Generals/Code/GameEngine/Source/Common/version.cpp

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -329,22 +329,32 @@ UnicodeString Version::getUnicodeProductString() const
329329

330330
if (!productTitle.isEmpty())
331331
{
332-
UnicodeString productVersion = TheGameText->FETCH_OR_SUBSTITUTE("Version:ProductVersion", getUnicodeProductVersion().str());
333-
UnicodeString productAuthor = TheGameText->FETCH_OR_SUBSTITUTE("Version:ProductAuthor", getUnicodeProductAuthor().str());
334-
335-
str.concat(productTitle);
336-
337-
if (!productVersion.isEmpty())
332+
// Get build user or author name
333+
AsciiString asciiUser = getAsciiBuildUserOrGitCommitAuthorName();
334+
UnicodeString user;
335+
if (!asciiUser.isEmpty())
338336
{
339-
str.concat(L" ");
340-
str.concat(productVersion);
337+
user.translate(asciiUser);
338+
}
339+
else
340+
{
341+
user = L"Unknown";
341342
}
342343

343-
if (!productAuthor.isEmpty())
344+
// Get release name from gitinfo
345+
UnicodeString releaseName;
346+
if (ReleaseName[0] != '\0')
347+
{
348+
releaseName.translate(ReleaseName);
349+
}
350+
else
344351
{
345-
str.concat(L" ");
346-
str.concat(productAuthor);
352+
releaseName = getUnicodeGitTagOrHash();
347353
}
354+
355+
str.concat(productTitle);
356+
str.concat(L" by ");
357+
str.concat(user);
348358
}
349359

350360
return str;
@@ -356,15 +366,26 @@ UnicodeString Version::getUnicodeProductVersionHashString() const
356366
UnicodeString productString = getUnicodeProductString();
357367
UnicodeString gameVersion = getUnicodeVersion();
358368
UnicodeString gameHash;
359-
gameHash.format(L"exe:%08X ini:%08X", TheGlobalData->m_exeCRC, TheGlobalData->m_iniCRC);
369+
370+
if (ReleaseName[0])
371+
{
372+
AsciiString asciiRel;
373+
asciiRel.concat(ReleaseName);
374+
UnicodeString uRel;
375+
uRel.translate(asciiRel);
376+
gameHash.format(L" release %s", uRel.str());
377+
}
378+
else
379+
{
380+
gameHash.format(L" | exe:%08X ini:%08X", TheGlobalData->m_exeCRC, TheGlobalData->m_iniCRC);
381+
}
360382

361383
if (!productString.isEmpty())
362384
{
363385
str.concat(productString);
364-
str.concat(L" | ");
365386
}
366387
str.concat(gameHash);
367-
str.concat(L" ");
388+
str.concat(L" - ");
368389
str.concat(gameVersion);
369390

370391
return str;

0 commit comments

Comments
 (0)