Skip to content

Commit 04fce5a

Browse files
committed
[GITHUB] Add weekly pre-releases workflow for Generals and GeneralsMD builds
1 parent 61cbc6f commit 04fce5a

File tree

3 files changed

+310
-0
lines changed

3 files changed

+310
-0
lines changed

.github/workflows/base-version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.9.1

.github/workflows/build-toolchain.yml

Lines changed: 11 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:
29+
required: false
30+
type: string
31+
description: "Release build (true/false)"
2832

2933
jobs:
3034
build:
@@ -35,6 +39,13 @@ jobs:
3539
- name: Checkout Code
3640
uses: actions/checkout@v4
3741

42+
- uses: actions/checkout@v4
43+
- name: Download version file
44+
if: inputs.release == 'true'
45+
uses: actions/download-artifact@v4
46+
with:
47+
name: version_files
48+
3849
- name: Cache VC6 Installation
3950
if: startsWith(inputs.preset, 'vc6')
4051
id: cache-vc6

.github/workflows/weekly-release.yml

Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
1+
name: Weekly Release
2+
3+
permissions:
4+
contents: write
5+
pull-requests: write
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
force_changed:
11+
description: 'Force build'
12+
required: false
13+
default: 'false'
14+
type: choice
15+
options:
16+
- 'false'
17+
- 'true'
18+
pre-release:
19+
description: 'Mark release as pre-release'
20+
required: false
21+
default: 'false'
22+
type: choice
23+
options:
24+
- 'false'
25+
- 'true'
26+
27+
schedule:
28+
- cron: '0 8 * * 1'
29+
30+
concurrency:
31+
group: ${{ github.workflow }}-${{ github.ref }}
32+
cancel-in-progress: true
33+
34+
jobs:
35+
detect-scm-changes:
36+
runs-on: ubuntu-latest
37+
outputs:
38+
changed: ${{ steps.check.outputs.changed }}
39+
steps:
40+
- uses: actions/checkout@v4
41+
with:
42+
fetch-depth: 0
43+
fetch-tags: true
44+
- id: check
45+
run: |
46+
if [ "${{ github.event.inputs.force_changed }}" = "true" ]; then
47+
echo "changed=true" >> $GITHUB_OUTPUT
48+
exit 0
49+
fi
50+
51+
echo LAST TAG:
52+
git describe --tags --abbrev=0 2>/dev/null || echo ""
53+
54+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
55+
if [ -z "$LAST_TAG" ]; then
56+
echo "changed=true" >> $GITHUB_OUTPUT
57+
exit 0
58+
fi
59+
CHANGED=$(git diff --name-only $LAST_TAG..HEAD | grep -v '.github/workflows/' | wc -l)
60+
if [ "$CHANGED" -eq "0" ]; then
61+
echo "changed=false" >> $GITHUB_OUTPUT
62+
else
63+
echo "changed=true" >> $GITHUB_OUTPUT
64+
fi
65+
66+
calculate-version:
67+
name: Generate version files
68+
runs-on: ubuntu-latest
69+
steps:
70+
- name: Checkout repository
71+
uses: actions/checkout@v4
72+
with:
73+
fetch-depth: 0
74+
fetch-tags: true
75+
76+
- name: Create Version Files
77+
run: |
78+
BASE_TAG=$(cat .github/workflows/base-version.txt)
79+
IFS='.' read -r major minor patch <<<"$BASE_TAG"
80+
CURRENT_TAG=$(git tag --list "$major.$minor*" --sort=-v:refname | head -n1)
81+
CURRENT_COMMIT=$(git rev-parse HEAD)
82+
83+
if [ -z "$CURRENT_TAG" ]; then
84+
CURRENT_TAG="$BASE_TAG"
85+
NEXT_TAG="$BASE_TAG"
86+
else
87+
IFS='.' read -r major minor patch <<<"$CURRENT_TAG"
88+
NEXT_TAG="$major.$minor.$((patch+1))"
89+
fi
90+
91+
echo "CURRENT_TAG: $CURRENT_TAG"
92+
echo "NEXT_TAG: $NEXT_TAG"
93+
94+
echo "$CURRENT_TAG" > current_tag.txt
95+
echo "$NEXT_TAG" > next_tag.txt
96+
echo "$CURRENT_COMMIT" > git_commit.txt
97+
98+
- name: Upload version files
99+
uses: actions/upload-artifact@v4
100+
with:
101+
name: version_files
102+
path: |
103+
next_tag.txt
104+
current_tag.txt
105+
git_commit.txt
106+
107+
build-generals:
108+
needs: [detect-scm-changes, calculate-version]
109+
if: needs.detect-scm-changes.outputs.changed == 'true'
110+
name: Build Generals${{ matrix.preset && '' }}
111+
strategy:
112+
matrix:
113+
include:
114+
- preset: "vc6"
115+
tools: true
116+
extras: true
117+
release: true
118+
- preset: "win32-vcpkg"
119+
tools: true
120+
extras: true
121+
release: true
122+
fail-fast: false
123+
uses: ./.github/workflows/build-toolchain.yml
124+
with:
125+
game: "Generals"
126+
preset: ${{ matrix.preset }}
127+
tools: ${{ matrix.tools }}
128+
extras: ${{ matrix.extras }}
129+
release: ${{ matrix.release }}
130+
secrets: inherit
131+
132+
build-generalsmd:
133+
needs: [detect-scm-changes, calculate-version]
134+
if: needs.detect-scm-changes.outputs.changed == 'true'
135+
name: Build GeneralsMD${{ matrix.preset && '' }}
136+
strategy:
137+
matrix:
138+
include:
139+
- preset: "vc6"
140+
tools: true
141+
extras: true
142+
release: true
143+
- preset: "win32"
144+
tools: true
145+
extras: true
146+
release: true
147+
fail-fast: false
148+
uses: ./.github/workflows/build-toolchain.yml
149+
with:
150+
game: "GeneralsMD"
151+
preset: ${{ matrix.preset }}
152+
tools: ${{ matrix.tools }}
153+
extras: ${{ matrix.extras }}
154+
release: ${{ matrix.release }}
155+
secrets: inherit
156+
157+
create-release:
158+
name: Create Release
159+
needs: [ build-generals, build-generalsmd ]
160+
runs-on: ubuntu-latest
161+
steps:
162+
- name: Checkout repository
163+
uses: actions/checkout@v4
164+
with:
165+
fetch-depth: 0
166+
fetch-tags: true
167+
168+
- name: Download version file
169+
uses: actions/download-artifact@v4
170+
with:
171+
name: version_files
172+
173+
- name: Read base version
174+
id: base_version
175+
run: echo "base_version=$(cat .github/workflows/base-version.txt)" >> $GITHUB_OUTPUT
176+
177+
- name: Get latest semver tag
178+
id: get_tag
179+
run: echo "current_tag=$(cat current_tag.txt)" >> $GITHUB_OUTPUT
180+
181+
- name: Calculate next version
182+
id: next_version
183+
run: echo "next_tag=$(cat next_tag.txt)" >> $GITHUB_OUTPUT
184+
185+
- name: Collect commits since last release
186+
id: changelog
187+
run: |
188+
TAG=${{ steps.get_tag.outputs.current_tag }}
189+
NEXT=${{ steps.next_version.outputs.next_tag }}
190+
if [ "$TAG" == "$NEXT" ]; then
191+
{
192+
echo "commits<<EOF"
193+
git log --pretty=format:"- %s" | head -n10 | grep -v "Sync Generals repos"
194+
echo "EOF"
195+
} >> $GITHUB_OUTPUT
196+
else
197+
{
198+
echo "commits<<EOF"
199+
git log "$TAG"..HEAD --pretty=format:"- %s" | grep -v "Sync Generals repos"
200+
echo "EOF"
201+
} >> $GITHUB_OUTPUT
202+
fi
203+
204+
# Generals vc6
205+
- name: Download Generals VC6 Artifacts
206+
uses: actions/download-artifact@v4
207+
with:
208+
name: Generals-vc6+t+e
209+
path: generals-vc6-artifacts
210+
211+
- name: Prepare and Zip Generals VC6
212+
run: |
213+
mkdir generals-vc6-release
214+
cp generals-vc6-artifacts/generalsv.exe generals-vc6-release/GeneralsV.exe
215+
cp generals-vc6-artifacts/W3DViewV.exe generals-vc6-release/W3DViewV.exe
216+
cp generals-vc6-artifacts/WorldBuilderV.exe generals-vc6-release/WorldBuilderV.exe
217+
zip -j generals-vc6-${{ steps.next_version.outputs.next_tag }}.zip generals-vc6-release/*
218+
219+
# Generals win32
220+
- name: Download Generals Win32 Artifacts
221+
uses: actions/download-artifact@v4
222+
with:
223+
name: Generals-win32-vcpkg+t+e
224+
path: generals-win32-artifacts
225+
226+
- name: Prepare and Zip Generals Win32
227+
run: |
228+
mkdir generals-win32-release
229+
cp generals-win32-artifacts/generalsv.exe generals-win32-release/GeneralsV.exe
230+
cp generals-win32-artifacts/W3DViewV.exe generals-win32-release/W3DViewV.exe
231+
cp generals-win32-artifacts/WorldBuilderV.exe generals-win32-release/WorldBuilderV.exe
232+
zip -j generals-win32-${{ steps.next_version.outputs.next_tag }}.zip generals-win32-release/*
233+
234+
# GeneralsMD vc6
235+
- name: Download GeneralsMD VC6 Artifacts
236+
uses: actions/download-artifact@v4
237+
with:
238+
name: GeneralsMD-vc6+t+e
239+
path: generalsmd-vc6-artifacts
240+
241+
- name: Prepare and Zip GeneralsMD VC6
242+
run: |
243+
mkdir generalsmd-vc6-release
244+
cp generalsmd-vc6-artifacts/generalszh.exe generalsmd-vc6-release/GeneralsZHv.exe
245+
cp generalsmd-vc6-artifacts/W3DViewZH.exe generalsmd-vc6-release/W3DViewZHv.exe
246+
cp generalsmd-vc6-artifacts/WorldBuilderZH.exe generalsmd-vc6-release/WorldBuilderZHv.exe
247+
zip -j generalszh-vc6-${{ steps.next_version.outputs.next_tag }}.zip generalsmd-vc6-release/*
248+
249+
# GeneralsMD win32
250+
- name: Download GeneralsMD Win32 Artifacts
251+
uses: actions/download-artifact@v4
252+
with:
253+
name: GeneralsMD-win32+t+e
254+
path: generalsmd-win32-artifacts
255+
256+
- name: Prepare and Zip GeneralsMD Win32
257+
run: |
258+
mkdir generalsmd-win32-release
259+
cp generalsmd-win32-artifacts/generalszh.exe generalsmd-win32-release/GeneralsZHv.exe
260+
cp generalsmd-win32-artifacts/W3DViewZH.exe generalsmd-win32-release/W3DViewZHv.exe
261+
cp generalsmd-win32-artifacts/WorldBuilderZH.exe generalsmd-win32-release/WorldBuilderZHv.exe
262+
zip -j generalszh-win32-${{ steps.next_version.outputs.next_tag }}.zip generalsmd-win32-release/*
263+
264+
- name: Create GitHub Release
265+
uses: softprops/action-gh-release@v2
266+
with:
267+
tag_name: ${{ steps.next_version.outputs.next_tag }}
268+
name: ${{ steps.next_version.outputs.next_tag }}
269+
prerelease: ${{ github.event.inputs.pre-release == 'true' }}
270+
body: |
271+
## Build notes
272+
273+
- **VC6 builds**: May be less compatible with modern systems, but guarantee compatibility with the original binary for multiplayer.
274+
- **Win32 builds**: Offer better compatibility with modern systems, but multiplayer will only work with other win32 builds.
275+
276+
### Known issues
277+
278+
- Fullscreen execution can freeze the game. For that case, you should add the `-win` parameter to run the game in windowed mode.
279+
280+
### Changelog
281+
${{ steps.changelog.outputs.commits }}
282+
files: |
283+
generals-vc6-${{ steps.next_version.outputs.next_tag }}.zip
284+
generals-win32-${{ steps.next_version.outputs.next_tag }}.zip
285+
generalszh-vc6-${{ steps.next_version.outputs.next_tag }}.zip
286+
generalszh-win32-${{ steps.next_version.outputs.next_tag }}.zip
287+
env:
288+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
289+
290+
- name: Clean up release folders
291+
if: always()
292+
run: |
293+
rm -rf generals-vc6-release generals-win32-release generalsmd-vc6-release generalsmd-win32-release
294+
rm -rf generals-vc6-artifacts generals-win32-artifacts generalsmd-vc6-artifacts generalsmd-win32-artifacts
295+
rm -f generals-vc6-${{ steps.next_version.outputs.next_tag }}.zip
296+
rm -f generals-win32-${{ steps.next_version.outputs.next_tag }}.zip
297+
rm -f generalszh-vc6-${{ steps.next_version.outputs.next_tag }}.zip
298+
rm -f generalszh-win32-${{ steps.next_version.outputs.next_tag }}.zip

0 commit comments

Comments
 (0)