-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (113 loc) · 3.35 KB
/
cpp_cicd.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
name: C++ CI/CD
permissions:
contents: write
issues: write
pull-requests: write
on:
push:
branches: [ "main" ]
tags:
- 'v*'
pull_request:
branches: [ "main" ]
jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- os: windows-latest
exe_name: minidb.exe
artifact_name: minidb-windows
- os: ubuntu-latest
exe_name: minidb
artifact_name: minidb-linux
- os: macos-latest
exe_name: minidb
artifact_name: minidb-macos
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake
- name: Install dependencies (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install cmake
- name: Configure CMake
run: |
mkdir build
cd build
cmake ..
- name: Build
working-directory: ./build
run: |
cmake --build . --config Release
- name: Run tests
working-directory: ./build
run: |
ctest -C Release --output-on-failure
- name: Prepare Release Asset
shell: bash
run: |
mkdir -p release-asset
if [ "${{ matrix.os }}" = "windows-latest" ]; then
cp build/Release/${{ matrix.exe_name }} release-asset/
else
cp build/${{ matrix.exe_name }} release-asset/
fi
cd release-asset
if [ "${{ matrix.os }}" = "windows-latest" ]; then
7z a -tzip minidb-windows.zip ${{ matrix.exe_name }}
else
tar czf ${{ matrix.artifact_name }}.tar.gz ${{ matrix.exe_name }}
fi
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact_name }}
path: |
release-asset/*.zip
release-asset/*.tar.gz
release:
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
path: artifacts
- name: Display structure of downloaded files
run: ls -R artifacts/
- name: Rename and prepare assets
run: |
mkdir release_files
cp artifacts/minidb-windows/minidb-windows.zip release_files/
cp artifacts/minidb-linux/minidb-linux.tar.gz release_files/
cp artifacts/minidb-macos/minidb-macos.tar.gz release_files/
- name: Create Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
release_files/minidb-windows.zip
release_files/minidb-linux.tar.gz
release_files/minidb-macos.tar.gz
draft: false
prerelease: false
generate_release_notes: true
name: Release ${{ github.ref_name }}
body: |
## MinidDB Release ${{ github.ref_name }}
### Downloads
- Windows: `minidb-windows.zip`
- Linux: `minidb-linux.tar.gz`
- macOS: `minidb-macos.tar.gz`