Skip to content

Commit 2422fa9

Browse files
committed
workflows: add GitHub actions for build and release
Signed-off-by: Mike Szczys <[email protected]>
1 parent 4d152cd commit 2422fa9

File tree

3 files changed

+167
-0
lines changed

3 files changed

+167
-0
lines changed

.github/workflows/build_zephyr.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Copyright (c) 2024 Golioth, Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Build Zephyr binaries
5+
6+
on:
7+
workflow_dispatch:
8+
inputs:
9+
ZEPHYR_SDK:
10+
required: true
11+
type: string
12+
default: 0.16.3
13+
BOARD:
14+
required: true
15+
type: string
16+
default: nrf9160dk/nr9160/ns
17+
ARTIFACT:
18+
required: true
19+
type: boolean
20+
default: false
21+
TAG:
22+
type: string
23+
24+
workflow_call:
25+
inputs:
26+
ZEPHYR_SDK:
27+
required: true
28+
type: string
29+
BOARD:
30+
required: true
31+
type: string
32+
ARTIFACT:
33+
required: true
34+
type: boolean
35+
TAG:
36+
type: string
37+
38+
jobs:
39+
build:
40+
runs-on: ubuntu-latest
41+
42+
container: golioth/golioth-zephyr-base:${{ inputs.ZEPHYR_SDK }}-SDK-v0
43+
44+
env:
45+
ZEPHYR_SDK_INSTALL_DIR: /opt/toolchains/zephyr-sdk-${{ inputs.ZEPHYR_SDK }}
46+
47+
steps:
48+
- name: Checkout
49+
uses: actions/checkout@v4
50+
with:
51+
path: app
52+
53+
- name: Process Board name
54+
id: nicename
55+
shell: bash
56+
run: |
57+
BOARD_NICENAME=${{ inputs.BOARD }}
58+
BOARD_NICENAME=$(echo $BOARD_NICENAME | cut -d)
59+
echo "BOARD_NICENAME=${BOARD_NICENAME}" >> $GITHUB_OUTPUT
60+
61+
- name: Setup West workspace
62+
run: |
63+
west init -l app
64+
west update --narrow -o=--depth=1
65+
west zephyr-export
66+
pip3 install -r deps/zephyr/scripts/requirements-base.txt
67+
# Needed for TF-M
68+
pip3 install cryptography pyasn1 pyyaml cbor>=1.0.0 imgtool>=1.9.0 jinja2 click
69+
70+
- name: Build with West
71+
run: |
72+
west build -p -b ${{ inputs.BOARD }} --sysbuild app
73+
74+
- name: Prepare artifacts
75+
shell: bash
76+
if: inputs.ARTIFACT == true && inputs.TAG != ''
77+
78+
run: |
79+
cd build
80+
mkdir -p artifacts
81+
mv zephyr/merged.hex ./artifacts/Golioth_${{ steps.nicename.outputs.BOARD_NICENAME }}_kitchen_sink_${{ inputs.TAG }}.hex
82+
83+
# Run IDs are unique per repo but are reused on re-runs
84+
- name: Save artifact
85+
if: inputs.ARTIFACT == true
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: build_artifacts_${{ github.run_id }}_${{ steps.nicename.outputs.BOARD_NICENAME }}
89+
path: |
90+
build/artifacts/*

.github/workflows/release.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Copyright (c) 2023 Golioth, Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Create Release
5+
6+
on:
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Release Version.'
11+
required: true
12+
default: 'v0.0.0'
13+
type: string
14+
15+
jobs:
16+
build-binaries:
17+
strategy:
18+
matrix:
19+
ZEPHYR_SDK: [0.16.3]
20+
BOARD: ["nrf9160dk/nrf9160/ns","nrf7002dk/nrf5340/cpuapp"]
21+
22+
uses: ./.github/workflows/build_zephyr.yml
23+
with:
24+
ZEPHYR_SDK: ${{ matrix.ZEPHYR_SDK }}
25+
BOARD: ${{ matrix.BOARD }}
26+
ARTIFACT: true
27+
TAG: ${{ inputs.version }}
28+
29+
upload-binaries:
30+
needs: build-binaries
31+
32+
runs-on: ubuntu-latest
33+
34+
steps:
35+
- name: Checkout repo
36+
uses: actions/checkout@v4
37+
38+
- name: Download artifact
39+
uses: actions/download-artifact@v4
40+
with:
41+
pattern: build_artifacts_*
42+
path: ~/artifacts
43+
merge-multiple: true
44+
45+
- name: Create Release manually with GH CLI
46+
run: gh release create --title ${{ inputs.version }} --draft ${{ inputs.version }}
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Upload artifacts to release
51+
run: gh release upload --clobber ${{ inputs.version }} ~/artifacts/*.*
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) 2023 Golioth, Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: Test firmware
5+
6+
on:
7+
pull_request:
8+
9+
push:
10+
#branches: [ main ]
11+
12+
jobs:
13+
test_build_nrf9160dk:
14+
uses: ./.github/workflows/build_zephyr.yml
15+
with:
16+
ZEPHYR_SDK: 0.16.3
17+
BOARD: nrf9160dk/nrf9160/ns
18+
ARTIFACT: false
19+
test_build_nrf7002:
20+
uses: ./.github/workflows/build_zephyr.yml
21+
with:
22+
ZEPHYR_SDK: 0.16.3
23+
BOARD: nrf7002dk/nrf5340/cpuapp
24+
ARTIFACT: false

0 commit comments

Comments
 (0)