Skip to content

Commit 63c7746

Browse files
committed
CI : add release automation + windows-msvc workflows [skip ci]
1 parent ce8e845 commit 63c7746

2 files changed

Lines changed: 330 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
name: release
2+
3+
# Triggered only by a "Bumped versions" commit on develop
4+
# (Mark Sibly's historical convention). The commit contains ONLY the
5+
# version constant changes in wx.wx (WAKE_VERSION),
6+
# wide.wx (WIDE_VERSION) and createrelease.wx (WONKEY_VERSION / WAKE_VERSION /
7+
# RELEASE_SUFFIX). The workflow reads these versions, rebuilds each platform,
8+
# recommits the bootstrap binaries, tags and publishes the release.
9+
on:
10+
push:
11+
branches: [ develop ]
12+
workflow_dispatch:
13+
inputs:
14+
force:
15+
description: "Force the release without a 'Bumped versions' commit"
16+
type: boolean
17+
default: false
18+
19+
permissions:
20+
contents: write
21+
22+
jobs:
23+
# ---------------------------------------------------------------------------
24+
# 1. Guard: only proceed on a bump commit, and extract the tag.
25+
# ---------------------------------------------------------------------------
26+
guard:
27+
runs-on: ubuntu-latest
28+
if: >-
29+
github.event_name == 'workflow_dispatch' ||
30+
startsWith(github.event.head_commit.message, 'Bumped versions')
31+
outputs:
32+
tag: ${{ steps.versions.outputs.tag }}
33+
wonkey: ${{ steps.versions.outputs.wonkey }}
34+
wake: ${{ steps.versions.outputs.wake }}
35+
wide: ${{ steps.versions.outputs.wide }}
36+
suffix: ${{ steps.versions.outputs.suffix }}
37+
steps:
38+
- name: checkout repository
39+
uses: actions/checkout@v4
40+
41+
- name: parse versions from createrelease.wx
42+
id: versions
43+
run: |
44+
# Tolerates spacing variations: `:="x"` (createrelease.wx) and `:= "x"` (wx.wx).
45+
get() { grep -oE "Const $2 *:?= *\"[^\"]*\"" "$1" | head -n1 | sed -E 's/.*"([^"]*)".*/\1/'; }
46+
cr=src/createrelease/createrelease.wx
47+
wonkey=$(get "$cr" WONKEY_VERSION)
48+
wake=$(get "$cr" WAKE_VERSION)
49+
suffix=$(get "$cr" RELEASE_SUFFIX)
50+
51+
# WAKE_VERSION must be identical in wx.wx and createrelease.wx (otherwise desynced).
52+
wake_wx=$(get src/wake/wx.wx WAKE_VERSION)
53+
if [ "$wake" != "$wake_wx" ]; then
54+
echo "::error::WAKE_VERSION desynced — createrelease.wx='$wake' vs wx.wx='$wake_wx'"
55+
exit 1
56+
fi
57+
58+
# WIDE_VERSION lives in wide.wx (used for Wide's title + release notes).
59+
wide=$(get src/wide/wide.wx WIDE_VERSION)
60+
61+
echo "wonkey=$wonkey" >> "$GITHUB_OUTPUT"
62+
echo "wake=$wake" >> "$GITHUB_OUTPUT"
63+
echo "wide=$wide" >> "$GITHUB_OUTPUT"
64+
echo "suffix=$suffix" >> "$GITHUB_OUTPUT"
65+
echo "tag=v${wonkey}${suffix}" >> "$GITHUB_OUTPUT"
66+
echo "Wonkey=$wonkey Wake=$wake Wide=$wide Suffix='$suffix' Tag=v${wonkey}${suffix}"
67+
68+
# ---------------------------------------------------------------------------
69+
# 2. Matrix build: full bootstrap + package generation per platform.
70+
# ---------------------------------------------------------------------------
71+
build:
72+
needs: guard
73+
strategy:
74+
fail-fast: false
75+
matrix:
76+
include:
77+
# id = unique artifact key ; host = platform folder (bin/, releases/).
78+
- id: linux
79+
host: linux
80+
runner: ubuntu-latest
81+
shell: bash
82+
commit_bins: true
83+
- id: macos
84+
host: macos
85+
runner: macos-latest
86+
shell: bash
87+
commit_bins: true
88+
- id: windows
89+
host: windows
90+
runner: windows-2022
91+
shell: cmd
92+
commit_bins: true
93+
# MSVC variant: same host=windows, but msvc toolchain and NO
94+
# commit-back of binaries (mingw stays canonical). Additionally produces
95+
# a wonkey_..._windows-msvc_x64 package.
96+
- id: windows-msvc
97+
host: windows
98+
runner: windows-2022
99+
shell: cmd
100+
msvc: true
101+
commit_bins: false
102+
runs-on: ${{ matrix.runner }}
103+
steps:
104+
- name: checkout repository
105+
uses: actions/checkout@v4
106+
107+
- name: install linux packages
108+
if: matrix.host == 'linux'
109+
run: |
110+
sudo apt-get update -y
111+
sudo apt-get install -y g++-multilib libopenal-dev libpulse-dev libsdl2-dev
112+
113+
# --- Windows: toolchain selection ---------------------------------------
114+
# MSVC: WX_USE_MSVC left empty => wake calls FindMSVC() which locates
115+
# Visual Studio + Windows Kits on its own (WX_MSVC_VERSIONS = years to scan).
116+
# gcc : WX_USE_MSVC=0 explicitly forces mingw (otherwise autodetection
117+
# would switch to msvc since VS is present on the runner).
118+
- name: configure windows toolchain
119+
if: matrix.host == 'windows'
120+
shell: pwsh
121+
env:
122+
MATRIX_MSVC: ${{ matrix.msvc }}
123+
run: |
124+
if ($env:MATRIX_MSVC -eq 'true') {
125+
"WX_MSVC_VERSIONS=2022" | Out-File $env:GITHUB_ENV -Append -Encoding utf8
126+
} else {
127+
"WX_USE_MSVC=0" | Out-File $env:GITHUB_ENV -Append -Encoding utf8
128+
}
129+
130+
# --- Bootstrap (same sequence as the per-platform workflows) ------------
131+
- name: bootstrap (unix)
132+
if: matrix.host != 'windows'
133+
run: |
134+
cd scripts
135+
./rebuildmods.sh
136+
./rebuildwake.sh
137+
./rebuildwide.sh
138+
./rebuildlauncher.sh
139+
./makedocs.sh
140+
141+
- name: bootstrap (windows)
142+
if: matrix.host == 'windows'
143+
shell: cmd
144+
run: |
145+
cd %CD%\scripts
146+
rebuildmods.bat && rebuildwake.bat && rebuildwide.bat && rebuildlauncher.bat && makedocs.bat
147+
148+
# --- createrelease: no dedicated script, build via `wake app` -----------
149+
- name: build createrelease (unix)
150+
if: matrix.host != 'windows'
151+
run: |
152+
bin/${{ matrix.host }}/wake app -clean -apptype=console -config=release \
153+
-product=src/createrelease/createrelease.products/${{ matrix.host }}/createrelease \
154+
src/createrelease/createrelease.wx
155+
156+
- name: build createrelease (windows)
157+
if: matrix.host == 'windows'
158+
shell: cmd
159+
run: |
160+
bin\windows\wake app -clean -apptype=console -config=release -product=src/createrelease/createrelease.products/windows/createrelease src/createrelease/createrelease.wx
161+
162+
# --- Package generation (createrelease writes into releases/<host>/) ----
163+
- name: run createrelease (unix)
164+
if: matrix.host != 'windows'
165+
run: src/createrelease/createrelease.products/${{ matrix.host }}/createrelease
166+
167+
- name: run createrelease (windows)
168+
if: matrix.host == 'windows'
169+
shell: cmd
170+
run: src\createrelease\createrelease.products\windows\createrelease.exe
171+
172+
# --- Windows: compile the Inno installer from the generated .iss --------
173+
- name: build inno installer (windows)
174+
if: matrix.host == 'windows'
175+
shell: cmd
176+
run: |
177+
for %%f in (releases\windows\*.iss) do iscc "%%f"
178+
179+
# --- Artifacts: bootstrap binaries (canonical) + packages --------------
180+
# Only canonical variants (commit_bins) upload their binaries:
181+
# the msvc variant must not overwrite the committed mingw.
182+
- name: upload bootstrap binaries
183+
if: matrix.commit_bins
184+
uses: actions/upload-artifact@v4
185+
with:
186+
name: bin-${{ matrix.host }}
187+
path: bin/${{ matrix.host }}/
188+
retention-days: 1
189+
190+
- name: upload release packages
191+
uses: actions/upload-artifact@v4
192+
with:
193+
name: pkg-${{ matrix.id }}
194+
path: releases/${{ matrix.host }}/
195+
retention-days: 7
196+
197+
# ---------------------------------------------------------------------------
198+
# 3. Recommit the bootstrap binaries (required: clones rebuild on top of them)
199+
# + tag. [skip ci] prevents the workflow from re-triggering.
200+
# ---------------------------------------------------------------------------
201+
commit-binaries:
202+
needs: [guard, build]
203+
runs-on: ubuntu-latest
204+
steps:
205+
- name: checkout repository
206+
uses: actions/checkout@v4
207+
with:
208+
ref: develop
209+
token: ${{ secrets.GITHUB_TOKEN }}
210+
211+
- name: download all bootstrap binaries
212+
uses: actions/download-artifact@v4
213+
with:
214+
pattern: bin-*
215+
path: .artifacts
216+
217+
- name: place binaries
218+
run: |
219+
for host in linux macos windows; do
220+
if [ -d ".artifacts/bin-$host" ]; then
221+
mkdir -p "bin/$host"
222+
cp -R ".artifacts/bin-$host/." "bin/$host/"
223+
fi
224+
done
225+
rm -rf .artifacts
226+
227+
- name: commit, tag & push
228+
run: |
229+
git config user.name "wonkey-ci"
230+
git config user.email "ci@wonkey-coders.invalid"
231+
git add bin/
232+
if git diff --cached --quiet; then
233+
echo "No binaries changed."
234+
else
235+
git commit -m "chore: bootstrap binaries ${{ needs.guard.outputs.tag }} [skip ci]"
236+
git push origin develop
237+
fi
238+
git tag -f "${{ needs.guard.outputs.tag }}"
239+
git push -f origin "${{ needs.guard.outputs.tag }}"
240+
241+
# ---------------------------------------------------------------------------
242+
# 4. GitHub release with all installation packages.
243+
# ---------------------------------------------------------------------------
244+
release:
245+
needs: [guard, commit-binaries]
246+
runs-on: ubuntu-latest
247+
steps:
248+
- name: download all packages
249+
uses: actions/download-artifact@v4
250+
with:
251+
pattern: pkg-*
252+
path: dist
253+
merge-multiple: true
254+
255+
- name: create github release
256+
uses: softprops/action-gh-release@v2
257+
with:
258+
tag_name: ${{ needs.guard.outputs.tag }}
259+
name: Wonkey ${{ needs.guard.outputs.wonkey }}${{ needs.guard.outputs.suffix }}
260+
body: |
261+
Wonkey ${{ needs.guard.outputs.wonkey }}${{ needs.guard.outputs.suffix }}
262+
wake ${{ needs.guard.outputs.wake }}
263+
wide ${{ needs.guard.outputs.wide }}
264+
files: dist/**/*
265+
fail_on_unmatched_files: false

.github/workflows/windows-msvc.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: windows-msvc
2+
3+
# Full bootstrap of Wonkey on Windows with the MSVC toolchain (instead of the
4+
# mingw/gcc used by windows.yml). Acts as a test CI on push/PR; the MSVC
5+
# release is produced by release.yml (windows-msvc matrix entry).
6+
on:
7+
push:
8+
branches: [ develop ]
9+
pull_request:
10+
branches: [ develop ]
11+
workflow_dispatch:
12+
13+
jobs:
14+
build-windows-msvc:
15+
runs-on: windows-2022 # VS 2022 Enterprise preinstalled
16+
17+
steps:
18+
- name: checkout repository
19+
uses: actions/checkout@v4
20+
21+
# WX_USE_MSVC left empty => wake calls FindMSVC(), which locates
22+
# Visual Studio + Windows Kits on its own. WX_MSVC_VERSIONS = VS years to scan.
23+
- name: configure wake for MSVC
24+
shell: pwsh
25+
run: |
26+
"WX_MSVC_VERSIONS=2022" | Out-File $env:GITHUB_ENV -Append -Encoding utf8
27+
28+
- name: print host infos
29+
shell: cmd
30+
run: echo %CD%
31+
32+
- name: print wake help
33+
shell: cmd
34+
run: |
35+
%CD%\bin\windows\wake
36+
37+
- name: rebuild modules
38+
shell: cmd
39+
run: |
40+
cd %CD%\scripts
41+
rebuildmods.bat
42+
43+
- name: rebuild wake
44+
shell: cmd
45+
run: |
46+
cd %CD%\scripts
47+
rebuildwake.bat
48+
49+
- name: rebuild wide
50+
shell: cmd
51+
run: |
52+
cd %CD%\scripts
53+
rebuildwide.bat
54+
55+
- name: rebuild launcher
56+
shell: cmd
57+
run: |
58+
cd %CD%\scripts
59+
rebuildlauncher.bat
60+
61+
- name: make docs
62+
shell: cmd
63+
run: |
64+
cd %CD%\scripts
65+
makedocs.bat

0 commit comments

Comments
 (0)