-
Notifications
You must be signed in to change notification settings - Fork 6
254 lines (236 loc) · 11 KB
/
windows.yml
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
#-----------------------------------------------------------------------------------------------------------------------
# .github/workflows/windows.yml is part of Brewken, and is copyright the following authors 2021-2024:
# • Artem Martynov <[email protected]>
# • Chris Speck <[email protected]>
# • Mattias Måhl <[email protected]>
# • Matt Young <[email protected]>
#
# Brewken is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# Brewken is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with this program. If not, see
# <http://www.gnu.org/licenses/>.
#-----------------------------------------------------------------------------------------------------------------------
name: Windows
on:
push:
branches:
- develop
- "stable/**"
pull_request:
branches:
- develop
schedule:
- cron: "0 2 * * *"
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build-win:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include: [
# In the past, we built only 32-bit packages (i686 architecture) on Windows because of problems getting 64-bit
# versions of NSIS plugins to work. However, we now invoke NSIS without plugins, so the 64-bit build seems to
# be working.
#
# As of January 2024, some of the 32-bit MSYS2 packages/groups we were previously relying on previously are no
# longer available. So now, we only build 64-bit packages (x86_64 architecture) on Windows.
{ msystem: MINGW64, arch: x86_64 },
#{ msystem: MINGW32, arch: i686 }
]
steps:
- uses: actions/checkout@v4
with:
path: temp
fetch-depth: 0
submodules: recursive
#
# Install MSYS2, then Python, then Pip
#
# We need Python 3.10 or later to run the bt script
#
# I tried using the separate actions/setup-python@v4 action, but it doesn't seem to result in the Python
# executable being visible in the MSYS2 environment. So, instead, we install from inside MSYS2. (According to
# https://packages.msys2.org/package/mingw-w64-x86_64-python, this is Python 3.10.9 as of 2022-12-10.)
#
# (In theory, an alternative approach would be to install Python, then run 'python -m ensurepip --upgrade' which,
# per https://docs.python.org/3/library/ensurepip.html, is the official Python way to bootstrap Pip. However,
# this did not seem to work properly in MSYS2 when I tried it.)
#
# Note that you _don't_ want to install the 'python' package here as it has some subtle differences from
# installing 'mingw-w64-i686-python'. (Same applies for 'python-pip' vs 'mingw-w64-i686-python-pip'.) Some of
# these differences are about where things are installed, but some are about how Python behaves, eg what
# platform.system() returns. See comments at https://github.com/conan-io/conan/issues/2638 for more.)
#
# We install the tree command here as, although it's not needed to do the build itself, it's useful for diagnosing
# certain build problems (eg to see what changes certain parts of the build have made to the build directory
# tree) when the build is running as a GitHub action. (If need be, you can also download the entire build
# directory within a day of a failed build running, but you need a decent internet connection for this as it's
# quite large.)
#
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
install: >-
mingw-w64-${{ matrix.arch }}-python
mingw-w64-${{ matrix.arch }}-python-pip
tree
update: true
release: true
path-type: strict
- name: Move Checkout
run: |
Copy-Item -Path "./temp" -Destination "C:/_" -Recurse
#
# On Windows, there are a couple of extra things we need to do before running the bt script:
#
# - For historical reasons, Linux and other platforms need to run both Python v2 (still used by some bits of
# system) and Python v3 (eg that you installed yourself) so there are usually two corresponding Python
# executables, python2 and python3. On Windows there is only whatever Python you installed and it's called
# python.exe. To keep the shebang in the bt script working, we just make a softlink to python called python3.
#
# - Getting Unicode input/output to work is fun. We should already have a Unicode locale, but it seems we also
# need to set PYTHONIOENCODING (see https://docs.python.org/3/using/cmdline.html#envvar-PYTHONIOENCODING, even
# though it seems to imply you don't need to set it on recent versions of Python).
#
# - The version of Pip we install above does not put it in the "right" place. Specifically it will not be in the
# PATH when we run bt. The following seems to be the least hacky way around this:
# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
# python get-pip.py
# python -m pip install -U --force-reinstall pip
# See https://stackoverflow.com/questions/48087004/installing-pip-on-msys for more discussion on this.
#
- name: Install Frameworks and Libraries, and set up Meson build environment
shell: msys2 {0}
run: |
cd /C/_/
echo "Working directory is:"
pwd
echo "Installed Python is:"
which python
python --version
echo "Installed pip is:"
which pip
pip --version
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
python -m pip install -U --force-reinstall pip
pip --version
echo "Locale:"
locale
export PYTHONIOENCODING=utf8
echo "Ensuring that python3 symlink / executable exists"
if [[ ! -f $(dirname $(which python))/python3 ]]; then ln -s $(which python) $(dirname $(which python))/python3; fi
echo "Running ./bt -v setup all"
./bt -v setup all
# In theory we don't need the next bit, as the bt script does it. In practice, for reasons I haven't yet bottomed
# out, the CMake/CPack invocation of NSIS complains it can't find Locate.nsh - but only on the Brewtarget build,
# not the Brewken one, even though all the build scripts etc are almost identical.
#
# Note that this is PowerShell, so absolute paths on the C drive begin C:/ rather than /C/ in MSYS2
- name: Download NSIS plugins
run: |
New-Item -ItemType Directory -Force -Path C:/_/build/nsis
Invoke-WebRequest -Uri https://nsis.sourceforge.io/mediawiki/images/a/af/Locate.zip -OutFile C:/_/build/nsis/Locate.zip
Expand-Archive -Path C:/_/build/nsis/Locate.zip -DestinationPath C:/_/build/nsis/Locate
Invoke-WebRequest -Uri https://nsis.sourceforge.io/mediawiki/images/7/76/Nsislog.zip -OutFile C:/_/build/nsis/Nsislog.zip
Expand-Archive -Path C:/_/build/nsis/Nsislog.zip -DestinationPath C:/_/build/nsis/Nsislog
Tree /f C:/_/build
# Somehow, running the configure script sets up CMake to use Ninja rather than Makefiles, which is then in
# conflict with our other assumptions about CMake. Error message says remove CMakeCache.txt before running CMake,
# so we do that as a short-term fix (on the assumption that, longer term, we'll be moving to Meson).
- name: CMake Config
shell: msys2 {0}
run: |
cd /C/_
./configure
cd build
rm CMakeCache.txt
cmake .. -DCMAKE_RC_COMPILER:FILEPATH=windres.exe -G "MinGW Makefiles"
# The pwd and find ../third-party commands below are just diagnostics, but it's generally useful to have too
# much rather than not enough diagnostic info on these GitHub action builds
- name: Build (with CMake)
shell: msys2 {0}
run: |
cd /C/_/build
pwd
tree -sh
cmake --build .
ls
- name: Build (with Meson)
shell: msys2 {0}
run: |
cd /C/_/mbuild
pwd
meson compile
# The 'export QT_DEBUG_PLUGINS=1' give us diagnostics in the event that there are problems initialising QT
# The 'export QT_QPA_PLATFORM=offscreen' stops Qt's xcb sub-module trying to connect to a non-existent display
# (which would cause the test runner to abort before running any tests).
- name: Test (via Meson)
shell: msys2 {0}
run: |
cd /C/_/mbuild
export QT_DEBUG_PLUGINS=1
export QT_QPA_PLATFORM=offscreen
meson test
- name: Test (via CMake)
shell: msys2 {0}
run: |
cd /C/_/build
cmake --build . --target test
#
# See above for explanation of the extra things we need to do on Windows before running the bt script. Most of
# that does not need doing again here, but PYTHONIOENCODING does need setting again.
#
# Note that, although we continue to support CMake for local builds and installs, we no longer support packaging
# with CPack/CMake. The bt build script packaging gives us better control over the packaging process.
#
- name: Package
shell: msys2 {0}
run: |
cd /C/_/
echo "Working directory is:"
pwd
echo "Installed Python is:"
which python
python --version
echo "Installed pip is:"
which pip
pip --version
export PYTHONIOENCODING=utf8
echo "Running ./bt -v package"
./bt -v package
cd mbuild/packages
pwd
tree -sh
- name: Upload Windows binaries (installers)
if: ${{ success()}}
uses: actions/upload-artifact@v4
with:
name: brewken-dev-${{ matrix.msystem }}
path: |
C:/_/mbuild/packages/windows/Brewken*Installer.exe
C:/_/mbuild/packages/windows/Brewken*Installer.exe.sha256sum
retention-days: 7
- name: Upload CMake error info from failed build
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.msystem }}-build-windows
path: C:/_/build/
retention-days: 1
- name: Upload Meson error info from failed build
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.msystem }}-mbuild-windows
path: C:/_/mbuild/
retention-days: 1