-
Notifications
You must be signed in to change notification settings - Fork 0
212 lines (180 loc) · 7.43 KB
/
build-and-release.yaml
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
name: Build and Release
on:
push:
paths:
- "**.c"
- "**.h"
- "**.feature"
- "Kconfig"
- ".github/workflows/build-and-release.yaml"
- "west.yml"
- "*.conf"
- "!package.json"
- "!package-lock.json"
repository_dispatch:
types:
- source-update
workflow_dispatch:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
STACK_NAME: ${{ secrets.STACK_NAME }}
CI: 1
FORCE_COLOR: 3
jobs:
# This generates a unique build id (which is also different for re-runs) to
# be used in the artifact names to be able to distinguish them when
# downloading the artifact files.
build-id:
name: Generate build ID
runs-on: ubuntu-22.04
outputs:
id: ${{ steps.id.outputs.id }}
steps:
- name: Generate build ID
id: id
run: |
ID=`uuidgen`
echo "id=${ID}" >> $GITHUB_OUTPUT
# This generates a string containing the current date which is used in
# in artifact names to simpify locating and distinguishing them once they have
# been downloaded
date-string:
name: Generate string containing the current date
runs-on: ubuntu-22.04
outputs:
dateAsString: ${{ steps.dateAsString.outputs.dateAsString }}
steps:
- name: Generate date string
id: dateAsString
run: echo "dateAsString=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
broker:
name: Determine broker hostname
runs-on: ubuntu-22.04
steps:
- name: Determine the AWS IoT broker hostname
id: broker-hostname
run: |
BROKER_HOSTNAME=`AWS_ACCESS_KEY_ID=${{ env.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY=${{ env.AWS_SECRET_ACCESS_KEY }} AWS_DEFAULT_REGION=${{ env.AWS_REGION }} aws iot describe-endpoint --endpoint-type iot:Data-ATS | jq '.endpointAddress' -r | tr -d '\n'`
echo ${BROKER_HOSTNAME}
if [ -z "$BROKER_HOSTNAME" ]; then echo "Failed to discover broker hostname."; exit 1; fi
echo ${BROKER_HOSTNAME} > broker.conf
- uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: broker
path: broker.conf
release-version:
name: Determine next release version
runs-on: ubuntu-22.04
outputs:
nextRelease: ${{ steps.version.outputs.nextRelease }}
steps:
- uses: actions/checkout@v4
- 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 }}
build:
runs-on: ubuntu-22.04
needs: [broker, release-version, date-string]
strategy:
matrix:
board: [thingy91_nrf9160_ns, nrf9160dk_nrf9160_ns]
loglevel: [debug, debugWithMemfault, nodebug]
steps:
- uses: actions/checkout@v4
with:
path: firmware
- name: Configure Version
working-directory: firmware
run: |
APP_VERSION=${{ needs.release-version.outputs.nextRelease }}-${{ matrix.board }}-${{ matrix.loglevel }}
echo "CONFIG_ASSET_TRACKER_V2_APP_VERSION=\"${APP_VERSION}\"" >> firmware.conf
echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV
- uses: actions/download-artifact@v3
with:
name: broker
- name: Configure the AWS IoT broker hostname
working-directory: firmware
run: |
BROKER_HOSTNAME=`cat ../broker.conf`
echo "CONFIG_AWS_IOT_BROKER_HOST_NAME=\"${BROKER_HOSTNAME}\"" >> firmware.conf
- run: cat firmware.conf
working-directory: firmware
- name: Build with debug enabled
working-directory: firmware
if: matrix.loglevel == 'debug'
run: |
docker run --rm -v ${PWD}:/workdir/project nordicplayground/nrfconnect-sdk:main west build -p always -b ${{ matrix.board }} --build-dir /workdir/project/build -- -DOVERLAY_CONFIG="overlay-aws.conf;overlay-pgps.conf;overlay-debug.conf;asset-tracker-cloud-firmware-aws.conf;firmware.conf" -DEXTRA_CFLAGS="-Werror"
- name: Build with debug and Memfault enabled
if: matrix.loglevel == 'debugWithMemfault'
working-directory: firmware
run: |
echo "CONFIG_NRF_MODEM_LIB_TRACE_ENABLED=y" >> firmware.conf
echo "CONFIG_DEBUG_MODULE_MEMFAULT_USE_EXTERNAL_TRANSPORT=y" >> firmware.conf
echo "CONFIG_DEBUG_MODULE_MEMFAULT_HEARTBEAT_INTERVAL_SEC=3600" >> firmware.conf
echo "CONFIG_MEMFAULT_NCS_FW_VERSION_STATIC=y" >> firmware.conf
echo "CONFIG_MEMFAULT_NCS_FW_VERSION=\"${{ env.APP_VERSION }}\"" >> firmware.conf
echo "CONFIG_MEMFAULT_NCS_FW_TYPE=\"asset_tracker_v2\"" >> firmware.conf
echo "CONFIG_MEMFAULT_NCS_PROJECT_KEY=\"${{ secrets.MEMFAULT_PROJECT_KEY }}\"" >> firmware.conf
docker run --rm -v ${PWD}:/workdir/project nordicplayground/nrfconnect-sdk:main west build -p always -b ${{ matrix.board }} --build-dir /workdir/project/build -- -DOVERLAY_CONFIG="overlay-aws.conf;overlay-pgps.conf;overlay-debug.conf;overlay-memfault.conf;asset-tracker-cloud-firmware-aws.conf;firmware.conf" -DEXTRA_CFLAGS="-Werror"
- name: Upload symbols file to Memfault
if: matrix.loglevel == 'debugWithMemfault'
working-directory: firmware
run: |
pip3 install memfault-cli
memfault \
--org-token ${{ secrets.MEMFAULT_ORGANIZATION_TOKEN }} \
--org ${{ secrets.MEMFAULT_ORGANIZATION_SLUG }} \
--project ${{ secrets.MEMFAULT_PROJECT_SLUG }} \
upload-mcu-symbols \
--software-type asset_tracker_v2 \
--software-version ${{ env.APP_VERSION }} \
build/zephyr/zephyr.elf
- name: Build with debug disabled
working-directory: firmware
if: matrix.loglevel == 'nodebug'
run: |
docker run --rm -v ${PWD}:/workdir/project nordicplayground/nrfconnect-sdk:main west build -p always -b ${{ matrix.board }} --build-dir /workdir/project/build -- -DOVERLAY_CONFIG="overlay-aws.conf;overlay-pgps.conf;asset-tracker-cloud-firmware-aws.conf;firmware.conf" -DEXTRA_CFLAGS="-Werror"
- name: Copy firmware
working-directory: firmware
run: |
cp build/zephyr/merged.hex ../
cp build/zephyr/app_signed.hex ../
cp build/zephyr/app_update.bin ../
cp build/zephyr/zephyr.elf ../
cp firmware.conf ../
- uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name:
${{ matrix.board }}-${{ matrix.loglevel }}-${{
needs.date-string.outputs.dateAsString }}-${{ github.sha }}
path: |
merged.hex
app_signed.hex
app_update.bin
firmware.conf
zephyr.elf
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]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
- uses: actions/setup-node@v3
with:
node-version: "18.x"
- run: npx semantic-release