Skip to content

Commit 782876d

Browse files
committed
actions: Move build step into separate action
Signed-off-by: Jorgen Kvalvaag <jorgen.kvalvaag@nordicsemi.no>
1 parent 6c2fb4d commit 782876d

File tree

2 files changed

+117
-82
lines changed

2 files changed

+117
-82
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: "Buildstep"
2+
description: "Build ATT firmware"
3+
inputs:
4+
memfault_project_key:
5+
type: string
6+
required: false
7+
default: "fookey"
8+
memfault_fw_type:
9+
type: string
10+
required: false
11+
default: "asset-tracker-template-dev"
12+
memfault_fw_version_prefix:
13+
type: string
14+
required: false
15+
default: "0.0.0-dev"
16+
board:
17+
type: string
18+
required: true
19+
short_board:
20+
type: string
21+
required: true
22+
version:
23+
type: string
24+
required: false
25+
default: "0.0.0-dev"
26+
path:
27+
type: string
28+
required: true
29+
default: "."
30+
debug:
31+
type: boolean
32+
required: false
33+
default: false
34+
35+
runs:
36+
using: "composite"
37+
steps:
38+
- name: Set up environment
39+
id: setup
40+
shell: bash
41+
run: |
42+
if [[ "${{ inputs.debug }}" == "true" ]]; then
43+
echo "VERSION=${{ inputs.version }}-debug" >> $GITHUB_OUTPUT
44+
echo "UPLOAD_ID=${{ inputs.short_board }}-debug" >> $GITHUB_OUTPUT
45+
else
46+
echo "VERSION=${{ inputs.version }}" >> $GITHUB_OUTPUT
47+
echo "UPLOAD_ID=${{ inputs.short_board }}" >> $GITHUB_OUTPUT
48+
fi
49+
cd ${{ inputs.path }}
50+
cp overlay-memfault.conf overlay-memfault-att.conf
51+
echo "CONFIG_MEMFAULT_NCS_PROJECT_KEY=\"${{ inputs.memfault_project_key }}\"" >> overlay-memfault-att.conf
52+
echo CONFIG_MEMFAULT_NCS_FW_TYPE=\"${{ inputs.memfault_fw_type }}\" >> overlay-memfault-att.conf
53+
echo CONFIG_MEMFAULT_NCS_FW_VERSION_AUTO=y >> overlay-memfault-att.conf
54+
echo CONFIG_MEMFAULT_NCS_FW_VERSION_PREFIX=\"${{ inputs.memfault_fw_version_prefix }}+\" >> overlay-memfault-att.conf
55+
56+
- name: Build firmware
57+
shell: bash
58+
run: |
59+
cd ${{ inputs.path }}
60+
west build -b ${{ inputs.board }} -d build -p --sysbuild -- -DEXTRA_CONF_FILE="overlay-memfault-att.conf" > /dev/null
61+
62+
- name: Copy artifacts
63+
shell: bash
64+
run: |
65+
mkdir -p artifacts
66+
cp ${{ inputs.path }}/build/merged.hex \
67+
artifacts/asset-tracker-template-${{ steps.setup.outputs.VERSION }}-${{ inputs.short_board }}-nrf91.hex
68+
cp ${{ inputs.path }}/build/app/zephyr/.config \
69+
artifacts/asset-tracker-template-${{ steps.setup.outputs.VERSION }}-${{ inputs.short_board }}-nrf91.config
70+
cp ${{ inputs.path }}/build/app/zephyr/zephyr.signed.bin \
71+
artifacts/asset-tracker-template-${{ steps.setup.outputs.VERSION }}-${{ inputs.short_board }}-nrf91-update-signed.bin
72+
cp ${{ inputs.path }}/build/app/zephyr/zephyr.signed.hex \
73+
artifacts/asset-tracker-template-${{ steps.setup.outputs.VERSION }}-${{ inputs.short_board }}-nrf91-update-signed.hex
74+
cp ${{ inputs.path }}/build/app/zephyr/zephyr.elf \
75+
artifacts/asset-tracker-template-${{ steps.setup.outputs.VERSION }}-${{ inputs.short_board }}-nrf91.elf
76+
cp ${{ inputs.path }}/build/dfu_application.zip \
77+
artifacts/asset-tracker-template-${{ steps.setup.outputs.VERSION }}-${{ inputs.short_board }}-nrf91-dfu.zip
78+
cd ${{ inputs.path }}/build
79+
ninja partition_manager_report > partition_manager_report.txt
80+
81+
- name: Generate Partition Manager Report
82+
shell: bash
83+
run: |
84+
sed '1d' ${{ inputs.path }}/build/partition_manager_report.txt > artifacts/pmr-${{ inputs.short_board }}-nrf91-default-${{ env.VERSION }}.txt

.github/workflows/build.yml

Lines changed: 33 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ jobs:
8181
apt update
8282
apt install -y --no-install-recommends gh
8383
84+
rm -rf artifacts
85+
mkdir -p artifacts
86+
8487
- name: Set VERSION environment variable
8588
shell: bash
8689
run: |
@@ -114,98 +117,46 @@ jobs:
114117
115118
# Asset Tracker Template firmware build
116119
- name: Build thingy91x firmware
117-
working-directory: asset-tracker-template/app
118-
run: |
119-
mkdir -p artifacts
120-
cp overlay-memfault.conf overlay-memfault-att.conf
121-
echo "CONFIG_MEMFAULT_NCS_PROJECT_KEY=\"${{ secrets.MEMFAULT_PROJECT_KEY }}\"" >> overlay-memfault-att.conf
122-
echo CONFIG_MEMFAULT_NCS_FW_TYPE=\"${{ env.MEMFAULT_FW_TYPE }}\" >> overlay-memfault-att.conf
123-
echo CONFIG_MEMFAULT_NCS_FW_VERSION_AUTO=y >> overlay-memfault-att.conf
124-
echo CONFIG_MEMFAULT_NCS_FW_VERSION_PREFIX=\"${{ env.MEMFAULT_FW_VERSION_PREFIX }}+\" >> overlay-memfault-att.conf
125-
west build -b thingy91x/nrf9151/ns -d build -p --sysbuild -- -DEXTRA_CONF_FILE="overlay-memfault-att.conf" 2>&1 | tee artifacts/build_output_thingy91x.log
126-
cp build/merged.hex artifacts/asset-tracker-template-${{ env.VERSION }}-thingy91x-nrf91.hex
127-
cp build/app/zephyr/.config artifacts/asset-tracker-template-${{ env.VERSION }}-thingy91x-nrf91.config
128-
cp build/app/zephyr/zephyr.signed.bin artifacts/asset-tracker-template-${{ env.VERSION }}-thingy91x-nrf91-update-signed.bin
129-
cp build/app/zephyr/zephyr.signed.hex artifacts/asset-tracker-template-${{ env.VERSION }}-thingy91x-nrf91-update-signed.hex
130-
cp build/app/zephyr/zephyr.elf artifacts/asset-tracker-template-${{ env.VERSION }}-thingy91x-nrf91.elf
131-
cp build/dfu_application.zip artifacts/asset-tracker-template-${{ env.VERSION }}-thingy91x-nrf91-dfu.zip
132-
cd build
133-
ninja partition_manager_report
134-
ninja partition_manager_report > ../artifacts/pmr-thingy91x-nrf91-default-${{ env.VERSION }}.txt
135-
sed -i '1d' ../artifacts/pmr-thingy91x-nrf91-default-${{ env.VERSION }}.txt
120+
uses: ./asset-tracker-template/.github/actions/build-step
121+
with:
122+
memfault_project_key: ${{ secrets.MEMFAULT_PROJECT_KEY }}
123+
memfault_fw_type: ${{ inputs.memfault_fw_type }}
124+
memfault_fw_version_prefix: ${{ env.MEMFAULT_FW_VERSION_PREFIX }}
125+
board: thingy91x/nrf9151/ns
126+
short_board: thingy91x
127+
version: ${{ env.VERSION }}
128+
path: asset-tracker-template/app
136129

137130
- name: Build nrf9151dk firmware
138131
if: ${{ github.event_name != 'pull_request' }}
139-
working-directory: asset-tracker-template/app
140-
run: |
141-
mkdir -p artifacts
142-
cp overlay-memfault.conf overlay-memfault-att.conf
143-
echo "CONFIG_MEMFAULT_NCS_PROJECT_KEY=\"${{ secrets.MEMFAULT_PROJECT_KEY }}\"" >> overlay-memfault-att.conf
144-
echo CONFIG_MEMFAULT_NCS_FW_TYPE=\"${{ env.MEMFAULT_FW_TYPE }}\" >> overlay-memfault-att.conf
145-
echo CONFIG_MEMFAULT_NCS_FW_VERSION_AUTO=y >> overlay-memfault-att.conf
146-
echo CONFIG_MEMFAULT_NCS_FW_VERSION_PREFIX=\"${{ env.MEMFAULT_FW_VERSION_PREFIX }}+\" >> overlay-memfault-att.conf
147-
west build -b nrf9151dk/nrf9151/ns -d build -p --sysbuild -- -DEXTRA_CONF_FILE="overlay-memfault-att.conf"
148-
cp build/merged.hex artifacts/asset-tracker-template-${{ env.VERSION }}-nrf9151dk-nrf91.hex
149-
cp build/app/zephyr/.config artifacts/asset-tracker-template-${{ env.VERSION }}-nrf9151dk-nrf91.config
150-
cp build/app/zephyr/zephyr.signed.bin artifacts/asset-tracker-template-${{ env.VERSION }}-nrf9151dk-nrf91-update-signed.bin
151-
cp build/app/zephyr/zephyr.signed.hex artifacts/asset-tracker-template-${{ env.VERSION }}-nrf9151dk-nrf91-update-signed.hex
152-
cp build/app/zephyr/zephyr.elf artifacts/asset-tracker-template-${{ env.VERSION }}-nrf9151dk-nrf91.elf
153-
cp build/dfu_application.zip artifacts/asset-tracker-template-${{ env.VERSION }}-nrf9151dk-nrf91-dfu.zip
154-
cd build
155-
ninja partition_manager_report
156-
ninja partition_manager_report > ../artifacts/pmr-nrf9151dk-nrf91-default-${{ env.VERSION }}.txt
157-
sed -i '1d' ../artifacts/pmr-nrf9151dk-nrf91-default-${{ env.VERSION }}.txt
158-
159-
- name: Upload artifact
160-
uses: actions/upload-artifact@v4
161-
id: artifact-upload-att
132+
uses: ./asset-tracker-template/.github/actions/build-step
162133
with:
163-
name: firmware-att
164-
if-no-files-found: error
165-
path: |
166-
asset-tracker-template/app/artifacts/*
134+
memfault_project_key: ${{ secrets.MEMFAULT_PROJECT_KEY }}
135+
memfault_fw_type: ${{ inputs.memfault_fw_type }}
136+
memfault_fw_version_prefix: ${{ env.MEMFAULT_FW_VERSION_PREFIX }}
137+
board: nrf9151dk/nrf9151/ns
138+
short_board: nrf9151dk
139+
version: ${{ env.VERSION }}
140+
path: asset-tracker-template/app
167141

168142
# Asset Tracker Template debug firmware build
169143
- name: Build thingy91x debug firmware
170144
if: ${{ inputs.build_debug }}
171-
working-directory: asset-tracker-template/app
172-
run: |
173-
cp overlay-memfault.conf overlay-memfault-debug.conf
174-
echo "CONFIG_MEMFAULT_NCS_PROJECT_KEY=\"${{ secrets.MEMFAULT_PROJECT_KEY }}\"" >> overlay-memfault-debug.conf
175-
echo CONFIG_MEMFAULT_NCS_FW_TYPE=\"${{ env.MEMFAULT_FW_TYPE }}\" >> overlay-memfault-debug.conf
176-
echo CONFIG_MEMFAULT_NCS_FW_VERSION_AUTO=y >> overlay-memfault-debug.conf
177-
echo CONFIG_MEMFAULT_NCS_FW_VERSION_PREFIX=\"${{ env.MEMFAULT_FW_VERSION_PREFIX }}-debug+\" >> overlay-memfault-debug.conf
178-
west build -p -b thingy91x/nrf9151/ns -p --sysbuild -- -DEXTRA_CONF_FILE="overlay-memfault-debug.conf;overlay-etb.conf"
179-
180-
- name: Rename debug artifacts
181-
if: ${{ inputs.build_debug }}
182-
working-directory: asset-tracker-template/app/build
183-
run: |
184-
cp merged.hex asset-tracker-template-${{ env.VERSION }}-debug-thingy91x-nrf91.hex
185-
cp app/zephyr/.config asset-tracker-template-${{ env.VERSION }}-debug-thingy91x-nrf91.config
186-
cp app/zephyr/zephyr.signed.bin asset-tracker-template-${{ env.VERSION }}-debug-thingy91x-nrf91-update-signed.bin
187-
cp app/zephyr/zephyr.signed.hex asset-tracker-template-${{ env.VERSION }}-debug-thingy91x-nrf91-update-signed.hex
188-
cp app/zephyr/zephyr.elf asset-tracker-template-${{ env.VERSION }}-debug-thingy91x-nrf91.elf
189-
cp dfu_application.zip asset-tracker-template-${{ env.VERSION }}-debug-thingy91x-nrf91-dfu.zip
190-
191-
- name: Create partition manager report for nRF91 debug firmware
192-
if: ${{ inputs.build_debug }}
193-
working-directory: asset-tracker-template/app/build
194-
run: |
195-
ninja partition_manager_report
196-
ninja partition_manager_report > pmr-nrf91-debug-${{ env.VERSION }}.txt
197-
sed -i '1d' pmr-nrf91-debug-${{ env.VERSION }}.txt
198-
199-
- name: Upload debug artifact
200-
if: ${{ inputs.build_debug }}
145+
uses: ./asset-tracker-template/.github/actions/build-step
146+
with:
147+
memfault_project_key: ${{ secrets.MEMFAULT_PROJECT_KEY }}
148+
memfault_fw_type: ${{ inputs.memfault_fw_type }}
149+
memfault_fw_version_prefix: ${{ env.MEMFAULT_FW_VERSION_PREFIX }}
150+
board: nrf9151dk/nrf9151/ns
151+
short_board: nrf9151dk
152+
version: ${{ env.VERSION }}
153+
path: asset-tracker-template/app
154+
155+
- name: Upload artifacts
201156
uses: actions/upload-artifact@v4
202-
id: artifact-upload-att-debug
203157
with:
204-
name: firmware-att-debug
205-
if-no-files-found: error
206-
path: |
207-
asset-tracker-template/app/build/asset-tracker-template-*.*
208-
asset-tracker-template/app/build/pmr-nrf91-*.txt
158+
name: firmware-artifacts-att
159+
path: artifacts/*
209160

210161
- name: Print run-id and fw version
211162
run: |

0 commit comments

Comments
 (0)