-
Notifications
You must be signed in to change notification settings - Fork 16
101 lines (96 loc) · 3.35 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
---
# Automatic building in CI
name: "Matrix Build"
on:
push:
pull_request:
branches: [main, develop]
merge_group:
permissions:
contents: read
packages: write
jobs:
build:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04, windows-2019, windows-2022]
fail-fast: false
runs-on: ${{matrix.os}}
env:
CMAKE_INSTALL_PREFIX: "${{ github.workspace }}/install"
steps:
- name: Checkout Sample-Server
uses: actions/checkout@v4
with:
path: Sample-Server
submodules: recursive
- name: Set Windows CMAKE_GENERATOR 2019
if: matrix.os == 'windows-2019'
run: |
#shellcheck disable=SC2154
echo "CMAKE_GENERATOR=Visual Studio 16 2019">> "$env:GITHUB_ENV"
echo "ARG_CTEST=-C Debug">> "$env:GITHUB_ENV"
- name: Set Windows CMAKE_GENERATOR 2022
if: matrix.os == 'windows-2022'
run: |
#shellcheck disable=SC2154
echo "CMAKE_GENERATOR=Visual Studio 17 2022">> "$env:GITHUB_ENV"
echo "ARG_CTEST=-C Debug">> "$env:GITHUB_ENV"
- name: Build server with dependencies
# yamllint disable rule:line-length
run: |
mkdir -p build
cd build
cmake ../Sample-Server/.github/ -DCMAKE_INSTALL_PREFIX:PATH=${{ env.CMAKE_INSTALL_PREFIX }}
cmake --build .
# yamllint enable rule:line-length
- name: Upload Artefacts
uses: actions/upload-artifact@v4
with:
name: Sample-Server-${{matrix.os}}
path: ${{ env.CMAKE_INSTALL_PREFIX }}/bin
- name: Test Sample-Server
run: |
cd build/SampleServer-build/
ctest --output-on-failure ${{ env.ARG_CTEST }}
docker:
runs-on: ubuntu-22.04
env:
# Check if this is not a pull request andGITHUB_TOKEN is set
# As all env variables are strings, you need to compare
# against "== 'true'" (not "== true")
IS_NOT_PR: "${{ !github.head_ref && true }}"
steps:
- name: Checkout Sample-Server
uses: actions/checkout@v4
with:
path: Sample-Server
submodules: recursive
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: PrepareReg Names
# yamllint disable rule:line-length
run: |
echo IMAGE_REPOSITORY="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
echo IMAGE_TAG="$(echo "${{ github.ref }}" | tr '[:upper:]' '[:lower:]' | awk '{sub(/([^\/]*\/){2}/,""); gsub(/\/|_/, "-")}1')" >> "$GITHUB_ENV"
echo IS_NOT_PR="${{ env.IS_NOT_PR }})"
# yamllint enable rule:line-length
- name: Login to GitHub Container Registry
uses: docker/[email protected]
if: env.IS_NOT_PR == 'true'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker Release
uses: "docker/[email protected]"
with:
provenance: false
file: "./Sample-Server/Dockerfile"
context: ./Sample-Server
platforms: linux/amd64
push: ${{env.IS_NOT_PR == 'true'}}
tags: |
ghcr.io/${{ env.IMAGE_REPOSITORY }}:${{ env.IMAGE_TAG }}