-
Notifications
You must be signed in to change notification settings - Fork 1
137 lines (118 loc) · 4.74 KB
/
msbuild.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
# 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