Skip to content

Commit 9746f58

Browse files
committed
[GITHUB] Add weekly pre-releases workflow for Generals and GeneralsMD
1 parent 0d850ca commit 9746f58

File tree

5 files changed

+296
-6
lines changed

5 files changed

+296
-6
lines changed

.github/workflows/build-toolchain.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ 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"
2832

2933
jobs:
3034
build:
@@ -110,6 +114,10 @@ jobs:
110114
"-DRTS_BUILD_ZEROHOUR=${{ inputs.game == 'GeneralsMD' && 'ON' || 'OFF' }}",
111115
"-DRTS_BUILD_GENERALS=${{ inputs.game == 'Generals' && 'ON' || 'OFF' }}"
112116
)
117+
118+
if ("${{ inputs.release-name }}") {
119+
$buildFlags += "-DRELEASE_NAME='${{ inputs.release-name }}'"
120+
}
113121
114122
$gamePrefix = "${{ inputs.game == 'Generals' && 'GENERALS' || 'ZEROHOUR' }}"
115123
$buildFlags += "-DRTS_BUILD_CORE_TOOLS=${{ inputs.tools && 'ON' || 'OFF' }}"

.github/workflows/weekly-release.yml

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

Generals/Code/Main/CMakeLists.txt

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,42 @@ target_link_libraries(g_generals PRIVATE
2424
winmm
2525
)
2626

27-
# TODO Originally referred to build host and user, replace with git info perhaps?
27+
# Set build information variables with default values that can be overridden
28+
if(NOT DEFINED VERSION_BUILDUSER)
29+
set(VERSION_BUILDUSER "\"The Super Hackers\"")
30+
endif()
31+
32+
if(NOT DEFINED VERSION_BUILDLOC)
33+
set(VERSION_BUILDLOC "\"https://github.com/TheSuperHackers/GeneralsGameCode\"")
34+
endif()
35+
36+
# Use git revision count as build number if available, otherwise use default or override
37+
if(NOT DEFINED VERSION_BUILDNUM)
38+
if(DEFINED GIT_REV_LIST_COUNT)
39+
set(VERSION_BUILDNUM ${GIT_REV_LIST_COUNT})
40+
else()
41+
set(VERSION_BUILDNUM 601)
42+
endif()
43+
endif()
44+
2845
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/GeneratedVersion.h
2946
"#pragma once
3047
48+
#ifndef VERSION_BUILDNUM
49+
#define VERSION_BUILDNUM ${VERSION_BUILDNUM}
50+
#endif
51+
52+
#ifndef VERSION_LOCALBUILDNUM
3153
#define VERSION_LOCALBUILDNUM 0
32-
#define VERSION_BUILDUSER \"\"
33-
#define VERSION_BUILDLOC \"\"
54+
#endif
55+
56+
#ifndef VERSION_BUILDUSER
57+
#define VERSION_BUILDUSER ${VERSION_BUILDUSER}
58+
#endif
59+
60+
#ifndef VERSION_BUILDLOC
61+
#define VERSION_BUILDLOC ${VERSION_BUILDLOC}
62+
#endif
3463
"
3564
)
3665

GeneralsMD/Code/Main/CMakeLists.txt

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,42 @@ target_link_libraries(z_generals PRIVATE
2626
zi_always
2727
)
2828

29-
# TODO Originally referred to build host and user, replace with git info perhaps?
29+
# Set build information variables with default values that can be overridden
30+
if(NOT DEFINED VERSION_BUILDUSER)
31+
set(VERSION_BUILDUSER "\"The Super Hackers\"")
32+
endif()
33+
34+
if(NOT DEFINED VERSION_BUILDLOC)
35+
set(VERSION_BUILDLOC "\"https://github.com/TheSuperHackers/GeneralsGameCode\"")
36+
endif()
37+
38+
# Use git revision count as build number if available, otherwise use default or override
39+
if(NOT DEFINED VERSION_BUILDNUM)
40+
if(DEFINED GIT_REV_LIST_COUNT)
41+
set(VERSION_BUILDNUM ${GIT_REV_LIST_COUNT})
42+
else()
43+
set(VERSION_BUILDNUM 601)
44+
endif()
45+
endif()
46+
3047
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/GeneratedVersion.h
3148
"#pragma once
3249
50+
#ifndef VERSION_BUILDNUM
51+
#define VERSION_BUILDNUM ${VERSION_BUILDNUM}
52+
#endif
53+
54+
#ifndef VERSION_LOCALBUILDNUM
3355
#define VERSION_LOCALBUILDNUM 0
34-
#define VERSION_BUILDUSER \"\"
35-
#define VERSION_BUILDLOC \"\"
56+
#endif
57+
58+
#ifndef VERSION_BUILDUSER
59+
#define VERSION_BUILDUSER ${VERSION_BUILDUSER}
60+
#endif
61+
62+
#ifndef VERSION_BUILDLOC
63+
#define VERSION_BUILDLOC ${VERSION_BUILDLOC}
64+
#endif
3665
"
3766
)
3867

resources/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
set(GIT_PRE_CONFIGURE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/gitinfo/gitinfo.cpp.in")
33
set(GIT_POST_CONFIGURE_FILE "${CMAKE_CURRENT_BINARY_DIR}/gitinfo.cpp")
44

5+
if(DEFINED RELEASE_NAME)
6+
set(GIT_HEAD_SHA1 "${RELEASE_NAME}")
7+
set(GIT_HEAD_SHORT_SHA1 "${RELEASE_NAME}")
8+
set(GIT_TAG "${RELEASE_NAME}")
9+
endif()
10+
511
include(gitinfo/git_watcher.cmake)
612

713
# Create resources library

0 commit comments

Comments
 (0)