Skip to content

Switch to Vcpkg manifest #64

Switch to Vcpkg manifest

Switch to Vcpkg manifest #64

Workflow file for this run

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: MSBuild
on:
push:
pull_request:
env:
# Path to the solution file relative to the root of the project.
SOLUTION_FILE_PATH: build\Incursion.sln
# Generated files to clean and check
GENERATED_FILES: src/tokens.cpp src/yygram.cpp inc/yygram.h
# Vcpkg root directory
VCPKG_ROOT: build/vcpkg
permissions:
contents: read
jobs:
build:
strategy:
matrix:
configuration: ["Release", "Debug"]
platform: ["Win32", "x64"]
runs-on: windows-2022
env:
triplet: ${{ matrix.platform == 'Win32' && 'x86-windows' || 'x64-windows'}}
steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
# Restore both vcpkg and its artifacts from the GitHub cache service.
- name: Restore vcpkg and its artifacts.
uses: actions/cache@v4
with:
# The first path is where vcpkg generates artifacts while consuming the vcpkg.json manifest file.
# The second path is the location of vcpkg (it contains the vcpkg executable and data files).
# The other paths starting with '!' are exclusions: they contain temporary files generated during the build of the installed packages.
path: |
build/vcpkg_installed/
${{ env.VCPKG_ROOT }}
!${{ env.VCPKG_ROOT }}/buildtrees
!${{ env.VCPKG_ROOT }}/packages
!${{ env.VCPKG_ROOT }}/downloads
# The key is composed in a way that it gets properly invalidated: this must happen whenever vcpkg's Git commit id changes, or the list of packages changes. In this case a cache miss must happen and a new entry with a new key with be pushed to GitHub the cache service.
# The key includes: hash of the vcpkg.json file, the hash of the vcpkg Git commit id, and the used vcpkg's triplet. The vcpkg's commit id would suffice, but computing an hash out it does not harm.
# Note: given a key, the cache content is immutable. If a cache entry has been created improperly, in order the recreate the right content the key must be changed as well, and it must be brand new (i.e. not existing already).
key: |
${{ hashFiles( 'build/vcpkg.json', '.git/modules/vcpkg/HEAD' )}}-${{ env.triplet }}-invalidate
- name: Setup Vcpkg
run: |
${{ env.VCPKG_ROOT }}/bootstrap-vcpkg.bat
${{ env.VCPKG_ROOT }}/vcpkg.exe integrate install
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Clean generated files
if: matrix.platform == 'Win32' && matrix.configuration == 'Debug'
shell: bash
run: rm -v ${{env.GENERATED_FILES}}
- name: Build
# Add additional options to the MSBuild command line here (like platform or verbosity level).
# See https://docs.microsoft.com/visualstudio/msbuild/msbuild-command-line-reference
run: msbuild /m /p:Configuration=${{matrix.configuration}} /p:Platform=${{matrix.platform}} ${{env.SOLUTION_FILE_PATH}}
- name: Verify generated files
run: git diff --exit-code ${{env.GENERATED_FILES}}
- name: Copy binaries to project root
shell: bash
run: cp -v build/*/*/exe_libtcod/Incursion.exe build/*/*/exe_libtcod/*.dll .
- name: Compile mod
if: matrix.configuration == 'Debug'
shell: bash
run: ./Incursion.exe -compile
- name: Upload mod
if: matrix.configuration == 'Debug'
uses: actions/upload-artifact@v4
with:
name: mod-${{ matrix.platform }}
path: mod
retention-days: 1
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: direct-binaries-${{matrix.configuration}}-${{matrix.platform}}
path: |
*.exe
*.dll
retention-days: 1
package:
needs: [build]
runs-on: ubuntu-latest
strategy:
matrix:
platform: ["Win32", "x64"]
steps:
- uses: actions/checkout@v4
- name: Fetch mod
uses: actions/download-artifact@v4
with:
name: mod-${{ matrix.platform }}
path: mod
- name: Fetch binaries
uses: actions/download-artifact@v4
with:
name: direct-binaries-Release-${{matrix.platform}}
path: .
- name: Package Incursion
uses: actions/upload-artifact@v4
with:
name: Incursion-${{matrix.platform}}
path: |
*.exe
*.dll
*.md
*.txt
fonts
docs
mod
retention-days: 30
compression-level: 9