|
6 | 6 | - main |
7 | 7 |
|
8 | 8 | jobs: |
| 9 | + env: |
| 10 | + # Indicates the location of the vcpkg as a Git submodule of the project repository. |
| 11 | + # Not using "VCPKG_ROOT" because a variable with the same name is defined in the VS's |
| 12 | + # Developer Command Prompt environment in VS 2022 17.6, which would override this one |
| 13 | + # if it had the same name. |
| 14 | + _VCPKG_: ${{ github.workspace }}/vcpkg |
| 15 | + # Tells vcpkg where binary packages are stored. |
| 16 | + VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vcpkg/bincache |
| 17 | + # Let's use GitHub Action cache as storage for the vcpkg Binary Caching feature. |
| 18 | + VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite' |
9 | 19 | build: |
10 | 20 | name: Build and Upload Artifacts |
11 | 21 | runs-on: windows-latest |
12 | | - steps: |
13 | | - # Get dependencies |
14 | | - - name: Checkout code |
15 | | - uses: actions/checkout@v3 |
| 22 | + env: |
| 23 | + # Indicates the location of the vcpkg as a Git submodule of the project repository. |
| 24 | + # Not using "VCPKG_ROOT" because a variable with the same name is defined in the VS's |
| 25 | + # Developer Command Prompt environment in VS 2022 17.6, which would override this one |
| 26 | + # if it had the same name. |
| 27 | + _VCPKG_: ${{ github.workspace }}/vcpkg |
| 28 | + # Tells vcpkg where binary packages are stored. |
| 29 | + VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vcpkg/bincache |
| 30 | + # Let's use GitHub Action cache as storage for the vcpkg Binary Caching feature. |
| 31 | + VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite' |
16 | 32 |
|
17 | | - - name: Install dependencies via vcpkg |
18 | | - run: vcpkg.exe install --triplet x64-windows |
| 33 | + steps: |
| 34 | + # Set env vars needed for vcpkg to leverage the GitHub Action cache as a storage |
| 35 | + # for Binary Caching. |
| 36 | + - uses: actions/github-script@v7 |
| 37 | + with: |
| 38 | + script: | |
| 39 | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); |
| 40 | + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); |
19 | 41 |
|
20 | | - - name: Cache vcpkg |
21 | | - uses: actions/cache@v3 |
| 42 | + - uses: actions/checkout@v4 |
22 | 43 | with: |
23 | | - path: | |
24 | | - vcpkg |
25 | | - vcpkg_installed |
26 | | - key: ${{ runner.os }}-vcpkg-${{ hashFiles('vcpkg.json') }} |
| 44 | + submodules: true |
| 45 | + - name: "Create directory '${{ env.VCPKG_DEFAULT_BINARY_CACHE }}'" |
| 46 | + run: mkdir -p $VCPKG_DEFAULT_BINARY_CACHE |
| 47 | + shell: bash |
27 | 48 |
|
28 | | - - name: Get Ninja |
29 | | - uses: seanmiddleditch/gha-setup-ninja@master |
| 49 | + # Setup the build machine with the most recent versions of CMake and Ninja. Both are cached if not already: on subsequent runs both will be quickly restored from GitHub cache service. |
| 50 | + - uses: lukka/get-cmake@latest |
30 | 51 |
|
31 | | - - name: Set up CMake |
32 | | - uses: jwlawson/actions-setup-cmake@v1 |
| 52 | + # Restore vcpkg from the GitHub Action cache service. Note that packages are restored by vcpkg's binary caching |
| 53 | + # when it is being run afterwards by CMake. |
| 54 | + - name: Restore vcpkg |
| 55 | + uses: actions/cache@v4 |
33 | 56 | with: |
34 | | - cmake-version: '3.16' |
| 57 | + # The first path is the location of vcpkg: it contains the vcpkg executable and data files, as long as the |
| 58 | + # built package archives (aka binary cache) which are located by VCPKG_DEFAULT_BINARY_CACHE env var. |
| 59 | + # The other paths starting with '!' are exclusions: they contain termporary files generated during the build of the installed packages. |
| 60 | + path: | |
| 61 | + ${{ env._VCPKG_ }} |
| 62 | + !${{ env._VCPKG_ }}/buildtrees |
| 63 | + !${{ env._VCPKG_ }}/packages |
| 64 | + !${{ env._VCPKG_ }}/downloads |
| 65 | + !${{ env._VCPKG_ }}/installed |
| 66 | + # The key is composed in a way that it gets properly invalidated whenever a different version of vcpkg is being used. |
| 67 | + key: | |
| 68 | + ${{ hashFiles( '.git/modules/vcpkg/HEAD' )}} |
35 | 69 |
|
36 | | - - name: Set up MSVC environment |
37 | | - shell: cmd |
38 | | - run: | |
39 | | - call "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath > vs_install_dir.txt |
40 | | - set /p InstallDir=<vs_install_dir.txt |
41 | | - call "%InstallDir%\VC\Auxiliary\Build\vcvarsall.bat" x64 |
| 70 | + # On Windows runners, let's ensure to have the Developer Command Prompt environment setup correctly. |
| 71 | + # As used here the Developer Command Prompt created is targeting x64 and using the default the Windows SDK. |
| 72 | + - uses: ilammy/msvc-dev-cmd@v1 |
42 | 73 |
|
43 | 74 | # Configure CMake (Windows) |
44 | 75 | - name: Configure CMake (Windows) |
45 | 76 | shell: cmd |
46 | 77 | run: | |
47 | | - cmake -B build -S . -G Ninja -DCMAKE_BUILD_TYPE=Release |
| 78 | + cmake --preset ninja-multi-vcpkg -B build -S . -G Ninja -DCMAKE_BUILD_TYPE=Release |
48 | 79 |
|
49 | 80 | # 4. Build the project |
50 | 81 | - name: Build PlatypusGui |
51 | | - run: cmake --build build --config Release --target PlatypusGui |
| 82 | + run: cmake --preset ninja-vcpkg-release --build build --config Release --target PlatypusGui |
52 | 83 |
|
53 | 84 | - name: Deploy Qt Dependencies (Windows) |
54 | 85 | shell: cmd |
|
0 commit comments