build - windows msvc #10
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build - windows msvc | |
on: | |
workflow_dispatch: | |
workflow_call: | |
jobs: | |
windows-msvc: | |
# inspired by https://github.com/lukka/CppCMakeVcpkgTemplate/blob/main/.github/workflows/hosted-pure-workflow.yml | |
strategy: | |
matrix: | |
config: [Debug, Release] | |
arch: [x64, x86] | |
name: Windows ${{ matrix.config }} ${{ matrix.arch }} Build (MSVC) | |
runs-on: windows-2022 | |
env: | |
VCPKG_ROOT: C:\vcpkg | |
VCPKG_TARGET_TRIPLET: ${{ matrix.arch }}-windows-static | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Get vcpkg_ref | |
# NOCOM: force use cache | |
# if: ${{ vars.VCPKG_REF == '' }} | |
# PRs from forked repos can't access repo variables (nor variables from the forked repo), | |
# but can restore caches from master | |
uses: actions/cache/restore@v4 | |
with: | |
path: vcpkg_ref | |
key: vcpkg_ref-invalid-to-use-latest | |
enableCrossOsArchive: true | |
fail-on-cache-miss: true | |
restore-keys: | | |
vcpkg_ref- | |
- name: Checkout vcpkg | |
id: prepare | |
run: | | |
# NOCOM: force use cache | |
REF='' | |
# REF=${{ vars.VCPKG_REF }} | |
if [ -z "$REF" -a -f vcpkg_ref ] ; then | |
REF="$(cat vcpkg_ref)" | |
fi | |
cd ${{ env.VCPKG_ROOT }} | |
# REF can be empty, a commit hash or a pull request | |
echo "Checking out '$REF'" | |
[ -n "$REF" ] && git fetch | |
git checkout $REF || git pull origin $REF | |
echo "vcpkg_key=${{ hashFiles( './install-dependencies.sh' ) }}-${REF}" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Restore vcpkg and its artifacts. | |
uses: actions/cache@v4 | |
with: | |
# Explicit path here because env is overridden by msvc-dev-cmd | |
path: C:\vcpkg\installed | |
key: | | |
${{ steps.prepare.outputs.vcpkg_key }}-${{ matrix.arch }} | |
- name: Installing dependencies | |
run: | | |
choco install innosetup | |
# Cache should have been populated by vcpkg-packages job | |
./install-dependencies.sh vcpkg --triplet=${{ env.VCPKG_TARGET_TRIPLET }} | |
shell: bash | |
- name: Configure MSVC development console | |
uses: ilammy/msvc-dev-cmd@v1 | |
with: | |
arch: ${{ matrix.arch }} | |
- name: Compiler | |
env: | |
VCPKG_ROOT: C:\vcpkg | |
run: | | |
mkdir $env:GITHUB_WORKSPACE\build | |
cd $env:GITHUB_WORKSPACE\build | |
cmake.exe -G "NMake Makefiles" .. -DVCPKG_TARGET_TRIPLET=${{ env.VCPKG_TARGET_TRIPLET }} -DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake" -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DOPTION_BUILD_WEBSITE_TOOLS=OFF -DOPTION_BUILD_TESTS=ON -DOPTION_ASAN=OFF -DOPTION_BUILD_CODECHECK=OFF -DOPTION_BUILD_WINSTATIC=ON -DOPTION_USE_GLBINDING=ON -DOPTION_FORCE_EMBEDDED_MINIZIP=ON | |
if ((Select-String -Quiet REVDETECT-BROKEN VERSION)) { exit 1 } | |
nmake | |
if ("${{ matrix.config }}" -Match "Release") { | |
strip -sv ./src/widelands.exe | |
} | |
- name: InnoSetup | |
run: | | |
cd $env:GITHUB_WORKSPACE | |
# Environment variables needed by our InnoSetup script | |
$env:PLATFORM = "${{ matrix.arch }}" | |
$env:CONFIGURATION = "${{ matrix.config }}" | |
$env:APPVEYOR_BUILD_FOLDER = $env:GITHUB_WORKSPACE | |
$env:APPVEYOR_BUILD_VERSION = "Widelands-${{ github.sha }}-${{ matrix.config }}-${{ matrix.arch }}" | |
ISCC.exe /o$env:GITHUB_WORKSPACE /fWidelands-${{ github.sha }}-msvc-${{ matrix.config }}-${{ matrix.arch }} $env:GITHUB_WORKSPACE\utils\windows\innosetup\Widelands.iss | |
- name: Uploading installer | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Widelands ${{ matrix.config }} ${{ matrix.arch }} Installer (MSVC) | |
path: ${{ github.workspace }}\Widelands-${{ github.sha }}-msvc-${{ matrix.config }}-${{ matrix.arch }}.exe |