-
Notifications
You must be signed in to change notification settings - Fork 8
237 lines (198 loc) · 7.61 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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
name: Build, Test, Release
on: [push, pull_request]
permissions:
contents: write
issues: write
actions: write
jobs:
# generate date string to be embedded in builds
date-string:
name: Generate date string
runs-on: ubuntu-22.04
outputs:
dateAsString: ${{ steps.dateAsString.outputs.dateAsString }}
steps:
- run: echo "$(date +'%Y%m%d%H%M%S')"
- name: Generate date string
id: dateAsString
run: echo "dateAsString=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
# generate version string to be embedded in builds
release-version:
name: Determine next release version
runs-on: ubuntu-22.04
outputs:
nextRelease: ${{ steps.version.outputs.nextRelease }}
steps:
- uses: actions/checkout@v3
- name: Determine next release version
uses: nordicsemiconductor/cloud-get-next-version-action@saga
id: version
with:
branch: saga
defaultVersion: "0.0.0-development-${{ github.sha }}"
- run: echo ${{ steps.version.outputs.nextRelease }}
test:
name: Run Twister tests
runs-on: ubuntu-22.04
container: zephyrprojectrtos/ci:v0.26.4
env:
CMAKE_PREFIX_PATH: /opt/toolchains
steps:
- name: Install Ruby
run: |
sudo apt-get update
sudo apt-get install -y ruby
- name: Checkout
uses: actions/checkout@v3
with:
path: project
- name: Initialize
working-directory: project
run: |
west init -l .
west update
- name: Twister Tests
working-directory: project/asset_tracker_v2
run: |
../../zephyr/scripts/twister -G --testsuite-root ./tests/
- name: Archive test result
if: failure()
uses: actions/upload-artifact@v3
with:
name: twister
path: project/asset_tracker_v2/twister-out
build:
name: Build
runs-on: ubuntu-22.04
container: zephyrprojectrtos/ci:v0.26.4
needs: [release-version, date-string]
env:
CMAKE_PREFIX_PATH: /opt/toolchains
AWS_BROKER_HOSTNAME: iot.thingy.rocks
environment: production
# list variants to build
strategy:
matrix:
configuration:
- thingy91
- thingy91.debug
- thingy91.low-power.memfault
- thingy91.solar
- thingy91.solar.debug
- thingy91.solar.low-power.memfault
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: project
- name: Initialize
working-directory: project
run: |
west init -l .
west update
# configure build {
- name: Build for Thingy:91
if: contains(matrix.configuration, 'thingy91')
run: echo 'BOARD=thingy91_nrf9160_ns' >> $GITHUB_ENV
- name: Build for nRF9160-DK
if: contains(matrix.configuration, 'nrf9160dk')
run: echo 'BOARD=nrf9160dk_nrf9160_ns' >> $GITHUB_ENV
- name: Add KConfig options unconditionally
working-directory: project/asset_tracker_v2
run: |
APP_VERSION=${{ needs.release-version.outputs.nextRelease }}+${{ matrix.configuration }}
echo "CONFIG_ASSET_TRACKER_V2_APP_VERSION=\"${APP_VERSION}\"" >> firmware.conf
echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV
echo "CONFIG_DATA_DEVICE_MODE_ACTIVE=y" >> firmware.conf
echo "CONFIG_LTE_PSM_REQ_RAT=\"00000000\"" >> firmware.conf
echo "CONFIG_CLOUD_CLIENT_ID_IMEI_PREFIX=\"oob-\"" >> firmware.conf
echo "CONFIG_NRF_CLOUD_SEC_TAG=42" >> firmware.conf
echo "CONFIG_DATA_DEVICE_MODE_ACTIVE=y" >> firmware.conf
echo "CONFIG_DATA_ACTIVE_TIMEOUT_SECONDS=60" >> firmware.conf
- name: Configure Memfault
if: contains(matrix.configuration, 'memfault')
working-directory: project/asset_tracker_v2
run: |
echo "CONFIG_DEBUG_MODULE_MEMFAULT_USE_EXTERNAL_TRANSPORT=y" >> overlay-memfault.conf
echo "CONFIG_DEBUG_MODULE_MEMFAULT_HEARTBEAT_INTERVAL_SEC=3600" >> overlay-memfault.conf
echo "CONFIG_MEMFAULT_NCS_FW_VERSION_STATIC=y" >> overlay-memfault.conf
echo "CONFIG_MEMFAULT_NCS_FW_VERSION=\"${{ env.APP_VERSION }}\"" >> overlay-memfault.conf
echo "CONFIG_MEMFAULT_NCS_FW_TYPE=\"atv2\"" >> overlay-memfault.conf
echo "CONFIG_MEMFAULT_NCS_PROJECT_KEY=\"${{ vars.MEMFAULT_PROJECT_KEY }}\"" >> overlay-memfault.conf
echo MEMFAULT_OVERLAY=overlay-memfault.conf >> $GITHUB_ENV
- name: Configure Low-Power
working-directory: project/asset_tracker_v2
if: contains(matrix.configuration, 'low-power')
run: echo CONFIG_OVERLAY=overlay-low-power.conf >> $GITHUB_ENV
- name: Configure Debug
working-directory: project/asset_tracker_v2
if: contains(matrix.configuration, 'debug')
run: |
echo CONFIG_OVERLAY=overlay-debug.conf >> $GITHUB_ENV
echo "CONFIG_NRF_MODEM_LIB_TRACE=y" >> firmware.conf
- name: Configure Solar Shield
working-directory: project/asset_tracker_v2
if: contains(matrix.configuration, 'solar')
run: |
echo EXTRA_ARGS="-DSHIELD=powerfoyle" >> $GITHUB_ENV
# }
- name: Build firmware
working-directory: project/asset_tracker_v2
run: |
west build -b ${{ env.BOARD }} \
-p always -- \
${{ env.EXTRA_ARGS }} \
-DOVERLAY_CONFIG="${{ env.CONFIG_OVERLAY }};${{ env.MEMFAULT_OVERLAY }};firmware.conf"
- name: Upload symbols file to Memfault
if:
contains(matrix.configuration, 'memfault') && github.ref ==
'refs/heads/saga' && (github.event_name == 'push' || github.event_name
== 'workflow_dispatch' || github.event_name == 'repository_dispatch')
working-directory: project/asset_tracker_v2
run: |
pip3 install memfault-cli
memfault \
--org-token ${{ secrets.MEMFAULT_ORGANIZATION_TOKEN }} \
--org ${{ vars.MEMFAULT_ORGANIZATION_SLUG }} \
--project ${{ vars.MEMFAULT_PROJECT_SLUG }} \
upload-mcu-symbols \
--software-type atv2 \
--software-version ${{ env.APP_VERSION }} \
build/zephyr/zephyr.elf
- name: Archive firmware
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name:
${{ matrix.configuration }}-${{
needs.date-string.outputs.dateAsString }}-${{ github.sha }}
path: |
project/asset_tracker_v2/build/zephyr/zephyr.elf
project/asset_tracker_v2/build/zephyr/merged.hex
project/asset_tracker_v2/build/zephyr/app_update.bin
project/asset_tracker_v2/build/zephyr/app_signed.hex
project/asset_tracker_v2/build/zephyr/zephyr.dts
project/asset_tracker_v2/build/zephyr/.config
release:
name: Release
runs-on: ubuntu-22.04
if:
github.ref == 'refs/heads/saga' && (github.event_name == 'push' ||
github.event_name == 'workflow_dispatch' || github.event_name ==
'repository_dispatch')
needs: [build, test]
env:
GITHUB_TOKEN: ${{ vars.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- uses: actions/setup-node@v3
with:
node-version: "18.x"
- run: npx semantic-release
id: semantic-release
- name: Trigger deployment workflow
if: steps.semantic-release.outcome == 'success'
env:
GITHUB_TOKEN: ${{ vars.GITHUB_TOKEN }}
run: gh workflow run publish-firmware-bundles.yml