generated from BenniWi/learn2code_template
-
Notifications
You must be signed in to change notification settings - Fork 2
152 lines (115 loc) · 4.91 KB
/
build_and_test_code.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: build and test code
on:
push:
branches: [ "main"]
pull_request:
branches: [ "main" ]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build_linux:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Install gtest manually
run: sudo apt-get install libgtest-dev
- name: Create a temporary artifact downloads folder
working-directory: ${{github.workspace}}/
run: mkdir linux_binary_dir
## Do all the Build stuff for Linux
- name: Configure CMake 4 Linux
run: cmake -B ${{github.workspace}}/code/build -S${{github.workspace}}/code -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build 4 Linux
run: cmake --build ${{github.workspace}}/code/build --config ${{env.BUILD_TYPE}}
- name: Install 4 Linux
run: cmake --install ${{github.workspace}}/code/build --config ${{env.BUILD_TYPE}} --prefix ${{github.workspace}}/linux_binary_dir
- name: Test
working-directory: ${{github.workspace}}/code/build
run: ctest -C ${{env.BUILD_TYPE}}
- uses: actions/upload-artifact@master
with:
name: linux_binaries
path: linux_binary_dir
build_windows:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install windows compiler
run: sudo apt-get install mingw-w64
- name: Create a temporary artifact downloads folder
working-directory: ${{github.workspace}}/
run: mkdir windows_binary_dir
## Do all the Build stuff for Windows
- name: Configure CMake 4 Windows
run: cmake -B ${{github.workspace}}/code/build -S${{github.workspace}}/code -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} --toolchain ${{github.workspace}}/code/mingw-w64-x86_64.cmake
- name: Build 4 Windows
run: cmake --build ${{github.workspace}}/code/build --config ${{env.BUILD_TYPE}}
- name: Install 4 Windows
run: cmake --install ${{github.workspace}}/code/build --config ${{env.BUILD_TYPE}} --prefix ${{github.workspace}}/windows_binary_dir
- uses: actions/upload-artifact@master
with:
name: windows_binaries
path: windows_binary_dir
build_macos:
runs-on: macos-11
steps:
- uses: actions/checkout@v3
- name: Install gtest manually
run: brew install googletest
- name: Create a temporary artifact downloads folder
working-directory: ${{github.workspace}}/
run: mkdir macos_binary_dir
## Do all the Build stuff for Mac
- name: Configure CMake 4 MacOS
run: cmake -B ${{github.workspace}}/code/build -S${{github.workspace}}/code -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build 4 Mac
run: cmake --build ${{github.workspace}}/code/build --config ${{env.BUILD_TYPE}}
- name: Install 4 MAC
run: cmake --install ${{github.workspace}}/code/build --config ${{env.BUILD_TYPE}} --prefix ${{github.workspace}}/macos_binary_dir
- name: Test
working-directory: ${{github.workspace}}/code/build
run: ctest -C ${{env.BUILD_TYPE}}
- uses: actions/upload-artifact@master
with:
name: macos_binaries
path: macos_binary_dir
create_release:
needs: [build_linux, build_windows, build_macos]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@master
with:
name: linux_binaries
path: linux_binary_dir
- uses: actions/download-artifact@master
with:
name: windows_binaries
path: windows_binary_dir
- uses: actions/download-artifact@master
with:
name: macos_binaries
path: macos_binary_dir
- name: rename binaries
if: ${{ github.ref == 'refs/heads/main' }} # pre release only on main
run: |
mv linux_binary_dir/demo_1_main linux_binary_dir/demo_1_main_linux \
&& mv macos_binary_dir/demo_1_main macos_binary_dir/demo_1_main_macos \
&& mv windows_binary_dir/demo_1_main.exe windows_binary_dir/demo_1_main_windows.exe
# create pre-release
- name: create a pre-release
if: ${{ github.ref == 'refs/heads/main' }} # pre release only on main
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Exam 1 Package"
files: |
linux_binary_dir/*
windows_binary_dir/*
macos_binary_dir/*