Skip to content

Commit f202f42

Browse files
authored
Update build.yml
1 parent fa08fa3 commit f202f42

File tree

1 file changed

+27
-55
lines changed

1 file changed

+27
-55
lines changed

.github/workflows/build.yml

Lines changed: 27 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
push:
55
branches:
66
- master
7-
- main
87
pull_request:
98
workflow_dispatch:
109

@@ -22,86 +21,59 @@ jobs:
2221
with:
2322
submodules: recursive
2423

25-
- name: Cache vcpkg binaries
26-
uses: actions/cache@v3
27-
with:
28-
path: ${{ runner.os == 'Windows' && 'C:\\Users\\runneradmin\\AppData\\Local\\vcpkg\\' || '~/.cache/vcpkg' }}
29-
key: vcpkg-binary-${{ matrix.os }}-${{ hashFiles('vcpkg.json') }}
30-
restore-keys: |
31-
vcpkg-binary-${{ matrix.os }}-
32-
- name: Cache vcpkg directory
33-
uses: actions/cache@v3
34-
with:
35-
path: vcpkg
36-
key: vcpkg-${{ matrix.os }}-${{ hashFiles('vcpkg.json') }}
37-
restore-keys: |
38-
vcpkg-${{ matrix.os }}-
39-
- name: Set up vcpkg for Windows
40-
if: runner.os == 'Windows'
41-
shell: pwsh
42-
run: |
43-
if (Test-Path -Path "vcpkg") {
44-
Remove-Item -Recurse -Force "vcpkg"
45-
}
46-
git clone https://github.com/microsoft/vcpkg.git
47-
cd vcpkg
48-
.\bootstrap-vcpkg.bat
49-
.\vcpkg integrate install
50-
- name: Set up vcpkg for macOS/Linux
51-
if: runner.os != 'Windows'
52-
run: |
53-
rm -rf vcpkg
54-
git clone https://github.com/microsoft/vcpkg.git
55-
cd vcpkg
56-
./bootstrap-vcpkg.sh
57-
./vcpkg integrate install
5824
- name: Set up dependencies for macOS and Linux
5925
if: runner.os != 'Windows'
6026
run: |
6127
if [ "${{ runner.os }}" == "macOS" ]; then
62-
brew install cmake gfortran curl zip unzip gnu-tar
28+
brew install cmake ninja
6329
elif [ "${{ runner.os }}" == "Linux" ]; then
6430
sudo apt-get update
65-
sudo apt-get install -y cmake gfortran pkg-config build-essential
31+
sudo apt-get install -y cmake build-essential
6632
fi
33+
6734
- name: Set up dependencies for Windows
6835
if: runner.os == 'Windows'
6936
run: |
70-
choco install cmake git
37+
choco install cmake
38+
39+
- name: Run vcpkg
40+
uses: lukka/run-vcpkg@v11
41+
with:
42+
vcpkgJsonGlob: 'vcpkg.json'
43+
runVcpkgInstall: true
44+
7145
- name: Cache build directory
7246
uses: actions/cache@v3
7347
with:
7448
path: build
7549
key: build-${{ matrix.os }}-${{ hashFiles('CMakeLists.txt') }}
7650
restore-keys: |
7751
build-${{ matrix.os }}-
52+
7853
- name: Configure and build for macOS/Linux
7954
if: runner.os != 'Windows'
80-
run: |
81-
mkdir -p build && cd build
82-
cmake .. -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install
83-
cmake --build . --config Release --parallel
55+
uses: lukka/run-cmake@v10
56+
with:
57+
cmakeListsTxtPath: CMakeLists.txt
58+
configurePreset: 'linux-release'
59+
buildPreset: 'linux-release'
60+
8461
- name: Configure and build for Windows
8562
if: runner.os == 'Windows'
86-
shell: pwsh
87-
run: |
88-
if (Test-Path -Path "build") {
89-
Remove-Item -Recurse -Force "build"
90-
}
91-
mkdir build
92-
cd build
93-
cmake .. -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install
94-
cmake --build . --config Release --parallel
95-
- name: Install (Windows only)
63+
uses: lukka/run-cmake@v10
64+
with:
65+
cmakeListsTxtPath: CMakeLists.txt
66+
configurePreset: 'windows-release'
67+
buildPreset: 'windows-release'
68+
69+
- name: Install and Update PATH (Windows only)
9670
if: runner.os == 'Windows'
9771
run: |
9872
cd build
9973
cmake --install .
100-
- name: Add install directory to PATH (Windows only)
101-
if: runner.os == 'Windows'
102-
run: echo "${{github.workspace}}/install/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
74+
echo "${{github.workspace}}/install/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
10375
10476
- name: Run tests
10577
run: |
10678
cd build
107-
ctest -C Release
79+
ctest -C Release

0 commit comments

Comments
 (0)