Skip to content

Add release job on push #36

Add release job on push

Add release job on push #36

Workflow file for this run

name: Build NCS Firmware
on:
push:
branches: [ main ]
tags:
- '*'
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
container:
image: ghcr.io/memfault/memfault-ncs-quickstart-fw:2025-11-06
strategy:
matrix:
board:
- nrf52840dk/nrf52840
- nrf5340dk/nrf5340/cpuapp
- thingy53/nrf5340/cpuapp
- nrf54l15dk/nrf54l15/cpuapp
- nrf54lm20dk/nrf54lm20a/cpuapp
- nrf54h20dk/nrf54h20/cpuapp
fail-fast: false
steps:
- name: Create sanitized board name
id: board_name
run: |
BOARD_NAME="${{ matrix.board }}"
SANITIZED_NAME=$(echo "$BOARD_NAME" | sed 's/\//-/g')
echo "sanitized=$SANITIZED_NAME" >> $GITHUB_OUTPUT
- name: Apply patches
# Patch from here:
# https://github.com/nrfconnect/sdk-nrf/compare/v3.2.0-preview2-branch...memfault:noahp/memfault-project-key-runtime-v3.2.0-preview2
run: |
curl -fsSL https://github.com/nrfconnect/sdk-nrf/compare/v3.2.0-preview2-branch...e59bb1f4f85db5f9e4d66f6c66f90f4143f8ad5e.diff | git -C /opt/ncs/${MEMFAULT_NCS_VERSION}/nrf apply
- name: Build firmware for ${{ matrix.board }}
run: |
. /opt/toolchain-env.sh
cd /opt/ncs/${MEMFAULT_NCS_VERSION}
# build 0.0.1 version
west build --build-dir 0.0.1 --sysbuild --pristine=always --board ${{ matrix.board }} nrf/samples/bluetooth/peripheral_mds
# to build the 0.0.2 version, we need to modify the line like this in samples/bluetooth/peripheral_mds/VERSION:
# PATCHLEVEL = 1
# to
# PATCHLEVEL = 2
sed -i 's/PATCHLEVEL = 1/PATCHLEVEL = 2/' nrf/samples/bluetooth/peripheral_mds/VERSION
west build --build-dir 0.0.2 --sysbuild --pristine=always --board ${{ matrix.board }} nrf/samples/bluetooth/peripheral_mds
- name: Store build artifact archives
shell: bash
run: |
for ver in 0.0.1 0.0.2; do
mkdir -p ~/artifacts/${{ steps.board_name.outputs.sanitized }}/${ver}/
cd /opt/ncs/${MEMFAULT_NCS_VERSION}/${ver}/
# Copy common files for all boards
cp \
dfu_application.zip_manifest.json \
dfu_application.zip \
peripheral_mds/zephyr/zephyr.elf \
\
~/artifacts/${{ steps.board_name.outputs.sanitized }}/${ver}/
# Handle hex files - special case for nrf54h20dk board
if [[ "${{ matrix.board }}" == "nrf54h20dk/nrf54h20/cpuapp" ]]; then
# Copy the specific hex files for nrf54h20dk
cp mcuboot/zephyr/zephyr.hex \
~/artifacts/${{ steps.board_name.outputs.sanitized }}/${ver}/mcuboot.zephyr.hex
cp ipc_radio/zephyr/zephyr.signed.hex \
~/artifacts/${{ steps.board_name.outputs.sanitized }}/${ver}/ipc_radio.zephyr.signed.hex
cp uicr/zephyr/zephyr.hex \
~/artifacts/${{ steps.board_name.outputs.sanitized }}/${ver}/uicr.zephyr.hex
cp peripheral_mds/zephyr/zephyr.signed.hex \
~/artifacts/${{ steps.board_name.outputs.sanitized }}/${ver}/peripheral_mds.zephyr.signed.hex
else
# Copy merged.hex for all other boards
cp merged.hex ~/artifacts/${{ steps.board_name.outputs.sanitized }}/${ver}/
fi
done
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.board_name.outputs.sanitized }}
path: |
~/artifacts/${{ steps.board_name.outputs.sanitized }}
retention-days: 30
release:
needs: build
runs-on: ubuntu-latest
if: github.event_name == 'create' && github.event.ref_type == 'tag'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v6
with:
path: ./artifacts
- name: Create GitHub Release with auto-generated notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ github.ref_name }} \
--title "Release ${{ github.ref_name }}" \
--generate-notes \
./artifacts/*.zip