Fix 95df7ea: Incorrect WindowClasses for deduplicated window descs. (#13412)
[openttd-github.git] / .github / workflows / release-windows.yml
blobd47b3645e5d07914728230fc888bd657531850d0
1 name: Release (Windows)
3 on:
4   workflow_call:
5     inputs:
6       survey_key:
7         required: false
8         type: string
9         default: ""
10       is_tag:
11         required: true
12         type: string
14 jobs:
15   windows:
16     strategy:
17       fail-fast: false
18       matrix:
19         include:
20         - arch: x86
21           host: x86
22         - arch: x64
23           host: x64
24         - arch: arm64
25           host: x64_arm64
27     name: Windows (${{ matrix.arch }})
29     runs-on: windows-latest
31     steps:
32     - name: Download source
33       uses: actions/download-artifact@v4
34       with:
35         name: internal-source
37     - name: Unpack source
38       shell: bash
39       run: |
40         tar -xf source.tar.gz --strip-components=1
42     - name: Install Rust toolchain
43       uses: dtolnay/rust-toolchain@stable
45     - name: Enable Rust cache
46       uses: Swatinem/rust-cache@v2
48     - name: Setup vcpkg caching
49       uses: actions/github-script@v7
50       with:
51         script: |
52           core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
53           core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
54           core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite')
56     - name: Install vcpkg
57       run: |
58         git clone https://github.com/microsoft/vcpkg ${{ runner.temp }}\vcpkg
59         ${{ runner.temp }}\vcpkg\bootstrap-vcpkg.bat -disableMetrics
61     - name: Install dependencies
62       shell: bash
63       run: |
64         echo "::group::Install choco dependencies"
65         choco install pandoc
66         echo "::endgroup::"
68         echo "::group::Install breakpad dependencies"
69         cargo install --locked dump_syms
70         echo "::endgroup::"
72     - name: Install MSVC problem matcher
73       uses: ammaraskar/msvc-problem-matcher@master
75     - name: Configure developer command prompt for tools
76       uses: ilammy/msvc-dev-cmd@v1
77       with:
78         arch: x64
80     - name: Build tools
81       shell: bash
82       run: |
83         mkdir build-host
84         cd build-host
86         echo "::group::CMake"
87         cmake ${GITHUB_WORKSPACE} \
88           -GNinja \
89           -DOPTION_TOOLS_ONLY=ON \
90           -DCMAKE_BUILD_TYPE=RelWithDebInfo \
91           # EOF
92         echo "::endgroup::"
94         echo "::group::Build"
95         cmake --build . --target tools
96         echo "::endgroup::"
98     - name: Configure developer command prompt for ${{ matrix.arch }}
99       uses: ilammy/msvc-dev-cmd@v1
100       with:
101         arch: ${{ matrix.host }}
103     - name: Build (with installer)
104       if: inputs.is_tag == 'true'
105       shell: bash
106       run: |
107         mkdir build
108         cd build
110         echo "::group::CMake"
111         cmake ${GITHUB_WORKSPACE} \
112           -GNinja \
113           -DVCPKG_TARGET_TRIPLET=${{ matrix.arch }}-windows-static \
114           -DCMAKE_TOOLCHAIN_FILE="${{ runner.temp }}\vcpkg\scripts\buildsystems\vcpkg.cmake" \
115           -DOPTION_USE_NSIS=ON \
116           -DHOST_BINARY_DIR=${GITHUB_WORKSPACE}/build-host \
117           -DCMAKE_BUILD_TYPE=RelWithDebInfo \
118           -DOPTION_SURVEY_KEY=${{ inputs.survey_key }} \
119           # EOF
120         echo "::endgroup::"
122         echo "::group::Build"
123         cmake --build . --target openttd
124         echo "::endgroup::"
125       env:
126         AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
127         AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
128         AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
129         AZURE_CODESIGN_ACCOUNT_NAME: ${{ secrets.AZURE_CODESIGN_ACCOUNT_NAME }}
130         AZURE_CODESIGN_ENDPOINT: ${{ secrets.AZURE_CODESIGN_ENDPOINT }}
131         AZURE_CODESIGN_PROFILE_NAME: ${{ secrets.AZURE_CODESIGN_PROFILE_NAME }}
133     - name: Build (without installer)
134       if: inputs.is_tag != 'true'
135       shell: bash
136       run: |
137         mkdir build
138         cd build
140         echo "::group::CMake"
141         cmake ${GITHUB_WORKSPACE} \
142           -GNinja \
143           -DVCPKG_TARGET_TRIPLET=${{ matrix.arch }}-windows-static \
144           -DCMAKE_TOOLCHAIN_FILE="${{ runner.temp }}\vcpkg\scripts\buildsystems\vcpkg.cmake" \
145           -DHOST_BINARY_DIR=${GITHUB_WORKSPACE}/build-host \
146           -DCMAKE_BUILD_TYPE=RelWithDebInfo \
147           -DOPTION_SURVEY_KEY=${{ inputs.survey_key }} \
148           # EOF
149         echo "::endgroup::"
151         echo "::group::Build"
152         cmake --build . --target openttd
153         echo "::endgroup::"
154       env:
155         AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
156         AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
157         AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
158         AZURE_CODESIGN_ACCOUNT_NAME: ${{ secrets.AZURE_CODESIGN_ACCOUNT_NAME }}
159         AZURE_CODESIGN_ENDPOINT: ${{ secrets.AZURE_CODESIGN_ENDPOINT }}
160         AZURE_CODESIGN_PROFILE_NAME: ${{ secrets.AZURE_CODESIGN_PROFILE_NAME }}
162     - name: Create breakpad symbols
163       shell: bash
164       run: |
165         cd build
166         dump_syms openttd.pdb --inlines --store symbols
168     - name: Create bundles
169       shell: bash
170       run: |
171         cd ${GITHUB_WORKSPACE}/build
172         echo "::group::Run CPack"
173         cpack
174         echo "::endgroup::"
176         echo "::group::Move PDB and exe to symbols"
177         PDB_FOLDER=$(find symbols -mindepth 2 -type d)
178         cp openttd.pdb ${PDB_FOLDER}/
180         EXE_FOLDER=symbols/openttd.exe/$(grep "INFO CODE_ID" symbols/*/*/openttd.sym | cut -d\  -f3)
181         mkdir -p ${EXE_FOLDER}
182         cp openttd.exe ${EXE_FOLDER}/
183         echo "::endgroup::"
185         echo "::group::Cleanup"
186         # Remove the sha256 files CPack generates; we will do this ourself at
187         # the end of this workflow.
188         rm -f bundles/*.sha256
189         echo "::endgroup::"
191     - name: Sign installer
192       if: inputs.is_tag == 'true'
193       shell: bash
194       run: |
195         ${GITHUB_WORKSPACE}/os/windows/sign.bat "${GITHUB_WORKSPACE}/build/bundles"
196       env:
197         AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
198         AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
199         AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
200         AZURE_CODESIGN_ACCOUNT_NAME: ${{ secrets.AZURE_CODESIGN_ACCOUNT_NAME }}
201         AZURE_CODESIGN_ENDPOINT: ${{ secrets.AZURE_CODESIGN_ENDPOINT }}
202         AZURE_CODESIGN_PROFILE_NAME: ${{ secrets.AZURE_CODESIGN_PROFILE_NAME }}
204     - name: Store bundles
205       uses: actions/upload-artifact@v4
206       with:
207         name: openttd-windows-${{ matrix.arch }}
208         path: build/bundles
209         retention-days: 5
211     - name: Store symbols
212       uses: actions/upload-artifact@v4
213       with:
214         name: symbols-windows-${{ matrix.arch }}
215         path: build/symbols
216         retention-days: 5