-
Notifications
You must be signed in to change notification settings - Fork 1
110 lines (93 loc) · 3.45 KB
/
ci.yml
File metadata and controls
110 lines (93 loc) · 3.45 KB
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
name: CI/CD Pipeline
on:
pull_request:
branches: [ "main" ]
push:
branches: [ "main" ]
jobs:
# JOB 1: Build and test matrix
# Runs on PRs and pushes to main across OS's
build-and-test:
name: Build & Test (${{ matrix.config.name }} - ${{ matrix.build-configuration }})
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- { name: "Windows gcc", os: windows-latest, cc: "gcc", cxx: "g++" }
- { name: "Ubuntu gcc", os: ubuntu-latest, cc: "gcc", cxx: "g++" }
- { name: "MacOS clang", os: macos-latest, cc: "clang", cxx: "clang++" }
build-configuration: [ Debug, Release ]
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
submodules: true
- name: Install Ninja (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y ninja-build
- name: Install Ninja (macOS)
if: runner.os == 'macOS'
run: |
if ! command -v ninja >/dev/null 2>&1; then
brew install ninja
fi
- name: Install Ninja (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: choco install ninja -y
- name: Configure CMake
run: |
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.build-configuration }} -DCMAKE_C_COMPILER=${{ matrix.config.cc }} -DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }}
- name: Build Project
run: cmake --build build --config ${{ matrix.build-configuration }}
- name: Run Catch2 Unit Tests
# Runs the unit tests you specified
run: ctest --test-dir build -C ${{ matrix.build-configuration }} --output-on-failure
# We only package and upload 'Release' builds to save storage and time
- name: Compress Release Build Directory
if: matrix.build-configuration == 'Release'
uses: thedoctor0/zip-release@0.7.5
with:
type: 'zip'
path: 'build'
filename: '${{ matrix.config.os }}-build.zip'
- name: Upload Artifacts for Release
if: matrix.build-configuration == 'Release'
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.config.os }}-build
path: ${{ matrix.config.os }}-build.zip
retention-days: 1
# JOB 2: Create Pre-Release
# Runs only on pushes to main, after tests pass
release:
name: Create Pre-Release
needs: build-and-test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Download all OS Artifacts
uses: actions/download-artifact@v8
with:
path: ./release-artifacts
merge-multiple: true # Puts the Mac, Win, and Linux zip files in the same folder
- name: Generate Tag & Publish Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Create naming convention
DATE=$(date +'%d_%m_%Y')
SHORT_SHA=${GITHUB_SHA::8}
TAG_NAME="dev-${SHORT_SHA}-${DATE}"
# Create Pre-Release and attach all downloaded .zip files using modern GitHub CLI
gh release create "$TAG_NAME" ./release-artifacts/*.zip \
--title "Development Build $TAG_NAME" \
--prerelease \
--generate-notes