-
Notifications
You must be signed in to change notification settings - Fork 8
85 lines (75 loc) · 3.2 KB
/
build.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
# Copyright (c) 2020-2021-2022 Luca Cappa
# Released under the term specified in file LICENSE.txt
# SPDX short identifier: MIT
#
# The peculiarity of this workflow is that assumes vcpkg is NOT stored as a submodule of this repository.
# This workflow does the following:
# - Restores vcpkg artifacts from cache.
# - Using the provided Git commit id, sets up vcpkg if needed, then run CMake with CMakePreset.json using a configuration
# that leverages the vcpkg's toolchain file. This will automatically run vcpkg to install dependencies
# described by the vcpkg.json manifest file. It will be a no-op if those are restored from cache.
# - Finally builds the sources with Ninja.
name: hosted-ninja-vcpkg-autocache
on: [push, workflow_dispatch]
jobs:
job:
name: ${{ matrix.os }}-${{ github.workflow }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: windows-latest
vcpkgCommitId: 'cfa560b585b4b17eaa26c74845924fc1f76ef74e'
- os: ubuntu-latest
vcpkgCommitId: 'cfa560b585b4b17eaa26c74845924fc1f76ef74e'
- os: macos-latest
vcpkgCommitId: 'cfa560b585b4b17eaa26c74845924fc1f76ef74e'
steps:
- uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
path: repo
- name: Create git archive to build
run: |
cd repo
git archive --format=tar --prefix= HEAD -o archive.tar
cd ..
tar xf repo/archive.tar
- uses: lukka/get-cmake@latest
- name: Dump the content of $RUNNER_TEMP
run: find $RUNNER_TEMP
shell: bash
- name: Dump the content of $RUNNER_WORKSPACE
run: find $RUNNER_WORKSPACE
shell: bash
- name: Restore artifacts, or setup vcpkg (do not install any package)
uses: lukka/run-vcpkg@v11
id: runvcpkg
with:
# This specifies the location of vcpkg, where it is going to be restored from cache, or create from scratch.
vcpkgDirectory: '${{ runner.workspace }}/b/vcpkg'
# The Git commit id of vcpkg to be checked out. This is only needed because we are not using a submodule.
vcpkgGitCommitId: '${{ matrix.vcpkgCommitId}}'
# The vcpkg.json file, which will be part of cache key computation.
vcpkgJsonGlob: '**/vcpkg.json'
- name: Prints output of run-vcpkg's action
run: echo "root='${{ steps.runvcpkg.outputs.RUNVCPKG_VCPKG_ROOT_OUT }}', triplet='${{ steps.runvcpkg.outputs.RUNVCPKG_VCPKG_DEFAULT_TRIPLET_OUT }}'"
- name: Install gfortran
if: runner.os == 'macOS'
run: |
brew install gfortran
ln -s /usr/local/bin/gfortran-12 /usr/local/bin/gfortran
ln -s /usr/local/bin/gcc-12 /usr/local/bin/gcc
which gfortran
- name: Run CMake with Ninja
uses: lukka/run-cmake@v10
with:
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
configurePreset: 'ninja-multi-vcpkg'
buildPreset: 'ninja-multi-vcpkg'
- name: List $RUNNER_WORKSPACE after build
run: find $RUNNER_WORKSPACE
shell: bash