-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (125 loc) · 4.23 KB
/
cmake.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
153
154
155
156
name: Build for Host and Target
on:
push:
pull_request:
release:
types: [created]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up CMake
uses: lukka/get-cmake@latest
with:
cmakeVersion: latestrc
ninjaVersion: latest
- name: Set up dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential
- name: Create build directory
run: mkdir -p build
- name: Configure CMake
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DON_TARGET=OFF
- name: Build with CMake
run: cmake --build build --config Release
- name: Run tests
working-directory: ${{github.workspace}}/build/test
shell: bash
run: |
ctest --output-on-failure --output-junit ${GITHUB_WORKSPACE}/test-results.xml
- name: Archive Test Results
uses: actions/upload-artifact@v4
with:
name: test-results
path: test-results.xml
build_target:
name: ${{matrix.name}}
strategy:
matrix:
include:
- os: ubuntu-20.04
name: Linux
cache-key: linux
cmake-args: '-DPIMORONI_PICO_PATH=$GITHUB_WORKSPACE/pimoroni-pico -DPICO_SDK_PATH=$GITHUB_WORKSPACE/pico-sdk -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/install'
apt-packages: clang-tidy gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
runs-on: ${{matrix.os}}
permissions:
contents: write
pull-requests: write
repository-projects: write
env:
PICO_SDK_PATH: $GITHUB_WORKSPACE/pico-sdk
PIMORONI_PICO_LIBS: $GITHUB_WORKSPACE/pimoroni-pico
RELEASE_FILE: ${{github.event.repository.name}}-${{github.event.release.tag_name}}
COMMIT_FILE: ${{github.event.repository.name}}-${{github.sha}}
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
path: project
submodules: recursive
# Checkout the Pimoroni Pico Libraries
- name: Checkout Pimoroni Pico Libraries
uses: actions/checkout@v4
with:
repository: pimoroni/pimoroni-pico
path: pimoroni-pico
# Checkout the Pico SDK
- name: Checkout Pico SDK
uses: actions/checkout@v4
with:
repository: raspberrypi/pico-sdk
path: pico-sdk
submodules: true
# Linux deps
- name: Install deps
if: runner.os == 'Linux'
run: |
sudo apt update && sudo apt install ${{matrix.apt-packages}}
- name: Create Build Environment
run: cmake -E make_directory ${{github.workspace}}/build
- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}/build
run: cmake $GITHUB_WORKSPACE/project -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DON_TARGET=ON -DCPACK_PACKAGE_FILE_NAME=${{env.RELEASE_FILE}} ${{matrix.cmake-args}}
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
run: |
cmake --build . --config $BUILD_TYPE -j 2
- name: Debug Archive
working-directory: ${{github.workspace}}/build/src
shell: bash
run: |
ls -la
- name: Archive Build
uses: actions/upload-artifact@v4
with:
name: ${{env.COMMIT_FILE}}
path: build/src/*.uf2
- name: Build Release Packages
if: github.event_name == 'release'
working-directory: ${{github.workspace}}/build
shell: bash
run: |
cmake --build . --config $BUILD_TYPE --target package -j 2
- name: Upload .zip
if: github.event_name == 'release'
uses: softprops/action-gh-release@v2
with:
files: ${{github.workspace}}/build/${{env.RELEASE_FILE}}.zip
name: ${{env.RELEASE_FILE}}.zip
- name: Upload .tar.gz
if: github.event_name == 'release'
uses: softprops/action-gh-release@v2
with:
files: ${{github.workspace}}/build/${{env.RELEASE_FILE}}.tar.gz
name: ${{env.RELEASE_FILE}}.tar.gz