Skip to content

Commit 01b53c5

Browse files
committed
[.github/workflows/github-actions.yml] Restructure to matrix to reuse steps
1 parent 642f486 commit 01b53c5

File tree

1 file changed

+62
-72
lines changed

1 file changed

+62
-72
lines changed

.github/workflows/github-actions.yml

Lines changed: 62 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -6,88 +6,78 @@ on:
66
- master
77

88
jobs:
9-
build_ubuntu:
10-
runs-on: ubuntu-latest
11-
steps:
12-
- uses: actions/checkout@v2
13-
- name: deps
14-
run: sudo apt-get install -y libssl-dev libcurl4-openssl-dev libarchive-dev
15-
- name: build
16-
run: |
17-
mkdir cmake-build-"$RUNNER_OS"-debug && pushd "$_"
18-
cmake -DCMAKE_BUILD_TYPE="Debug" ..
19-
cmake --build .
20-
- name: test
21-
run: cd cmake-build-"$RUNNER_OS"-debug && ctest .
22-
- name: release
23-
run: |
24-
cd "$GITHUB_WORKSPACE"
25-
echo "${{ secrets.GITHUB_TOKEN }}" > .token
26-
gh auth login --with-token < .token
27-
rm .token
28-
gh release delete -y amalgamation
29-
gh release create amalgamation --target master cmake-build-"$RUNNER_OS"-debug/src/acquire.h
30-
build_macos:
31-
runs-on: macos-latest
32-
steps:
33-
- uses: actions/checkout@v2
34-
- name: deps
35-
run: brew install pkg-config libarchive # openssl
36-
- name: build
37-
run: |
38-
prefix="$(brew --prefix libarchive)"
39-
export LDFLAGS="-L${prefix}/lib"
40-
export CPPFLAGS="-I${prefix}/include"
41-
export PKG_CONFIG_PATH="${prefix}/lib/pkgconfig"
42-
mkdir cmake-build-"$RUNNER_OS"-debug && cd "$_"
43-
cmake -DCMAKE_BUILD_TYPE="Debug" ..
44-
cmake --build .
45-
- name: test
46-
run: cd cmake-build-"$RUNNER_OS"-debug && ctest .
47-
build_windows:
48-
runs-on: windows-latest
9+
build:
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-latest, windows-latest, macos-latest]
15+
16+
name: ${{ matrix.os }}
17+
4918
steps:
5019
- uses: actions/checkout@v2
51-
# - uses: ilammy/msvc-dev-cmd@v1
52-
- name: Cache vcpkg
53-
uses: actions/cache@v2
54-
env:
55-
cache-name: cache-vcpkg
56-
with:
57-
path: ${{ github.workspace }}/vcpkg
58-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/vcpkg.json') }}
59-
restore-keys: |
60-
${{ runner.os }}-build-${{ env.cache-name }}-
61-
${{ runner.os }}-build-
62-
${{ runner.os }}-
20+
21+
- name: mkdir
22+
run: mkdir build
23+
24+
- name: Install dependencies for macOS
25+
run: brew install pkg-config libarchive
26+
if: matrix.os == 'macos-latest'
27+
28+
- name: Install dependencies for Ubuntu
29+
run: sudo apt-get install -y libcurl4-openssl-dev
30+
if: matrix.os == 'ubuntu-latest'
31+
6332
- name: checkout vcpkg
6433
uses: actions/checkout@v2
6534
with:
6635
repository: "microsoft/vcpkg"
67-
ref: 6ba505cf2c1752d8ea5abb21427e23ff89dc486f
36+
ref: d8d61c941c333a147edffdcbdc9964dc0c0962f5
6837
path: vcpkg
69-
- name: "Setup vcpkg"
38+
if: matrix.os == 'windows-latest'
39+
40+
- name: Setup vcpkg (Windows)
7041
run: ./vcpkg/bootstrap-vcpkg.bat
71-
- name: Install dependencies with vcpkg
42+
if: matrix.os == 'windows-latest'
43+
44+
- name: configure (with vcpkg on Windows)
45+
working-directory: ./build
7246
run: |
73-
cd "%GITHUB_WORKSPACE%\vcpkg"
74-
dir /S /AD
75-
IF NOT EXIST "buildtrees\libarchive" (
76-
.\vcpkg --version
77-
.\vcpkg install --triplet "%RUNNER_ARCH%-%RUNNER_OS%"
78-
)
47+
cmake -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_TOOLCHAIN_FILE="..\vcpkg\scripts\buildsystems\vcpkg.cmake" .
7948
shell: cmd
80-
- name: build
49+
if: matrix.os == 'windows-latest'
50+
51+
- name: configure (macOS)
52+
working-directory: ./build
8153
run: |
82-
cd "%GITHUB_WORKSPACE%"
83-
set vcpkg="%cd%\vcpkg"
84-
md "cmake-build-debug"
85-
cd "cmake-build-debug"
86-
cmake -DCMAKE_TOOLCHAIN_FILE="%vcpkg%\scripts\buildsystems\vcpkg.cmake" ..
87-
cmake --build .
88-
shell: cmd
54+
prefix="$(brew --prefix libarchive)"
55+
export LDFLAGS="-L${prefix}/lib"
56+
export CPPFLAGS="-I${prefix}/include"
57+
export PKG_CONFIG_PATH="${prefix}/lib/pkgconfig"
58+
cmake -DCMAKE_BUILD_TYPE="Debug" ..
59+
if: matrix.os == 'macos-latest'
60+
61+
- name: configure (Ubuntu)
62+
working-directory: ./build
63+
run: |
64+
cmake -DCMAKE_BUILD_TYPE="Debug" ..
65+
if: matrix.os == 'ubuntu-latest'
66+
67+
- name: build
68+
working-directory: ./build
69+
run: cmake --build .
70+
8971
- name: test
72+
working-directory: ./build
73+
run: ctest --output-on-failure -C Debug .
74+
75+
- name: release
76+
working-directory: ./build
9077
run: |
91-
cd "%GITHUB_WORKSPACE%\libacquire\cmake-build-debug"
92-
ctest -C "Debug" .
93-
shell: cmd
78+
echo "${{ secrets.GITHUB_TOKEN }}" > .token
79+
gh auth login --with-token < .token
80+
rm .token
81+
gh release delete -y amalgamation
82+
gh release create amalgamation --target master "src/acquire.h"
83+
if: matrix.os == 'ubuntu-latest'

0 commit comments

Comments
 (0)