Skip to content

Commit

Permalink
workflows: add GitHub actions for build and release
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Szczys <mike@golioth.io>
  • Loading branch information
szczys committed Oct 28, 2024
1 parent 4d152cd commit ed7239d
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 0 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/build_zephyr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Copyright (c) 2024 Golioth, Inc.
# SPDX-License-Identifier: Apache-2.0

name: Build Zephyr binaries

on:
workflow_dispatch:
inputs:
ZEPHYR_SDK:
required: true
type: string
default: 0.16.3
BOARD:
required: true
type: string
default: nrf9160dk/nr9160/ns
ARTIFACT:
required: true
type: boolean
default: false
TAG:
type: string

workflow_call:
inputs:
ZEPHYR_SDK:
required: true
type: string
BOARD:
required: true
type: string
ARTIFACT:
required: true
type: boolean
TAG:
type: string

jobs:
build:
runs-on: ubuntu-latest

container: golioth/golioth-zephyr-base:${{ inputs.ZEPHYR_SDK }}-SDK-v0

env:
ZEPHYR_SDK_INSTALL_DIR: /opt/toolchains/zephyr-sdk-${{ inputs.ZEPHYR_SDK }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: app

- name: Process Board name
id: nicename
shell: bash
run: |
BOARD_NICENAME=${{ inputs.BOARD }}
BOARD_NICENAME=$(echo $BOARD_NICENAME | cut -d)
echo "BOARD_NICENAME=${BOARD_NICENAME}" >> $GITHUB_OUTPUT
- name: Setup West workspace
run: |
west init -l app
west update --narrow -o=--depth=1
west zephyr-export
pip3 install -r deps/zephyr/scripts/requirements-base.txt
# Needed for TF-M
pip3 install cryptography pyasn1 pyyaml cbor>=1.0.0 imgtool>=1.9.0 jinja2 click
- name: Build with West
run: |
west build -p -b ${{ inputs.BOARD }} app/01_IOT
- name: Prepare artifacts
shell: bash
if: inputs.ARTIFACT == true && inputs.TAG != ''

run: |
cd build
mkdir -p artifacts
mv zephyr/merged.hex ./artifacts/Golioth_${{ steps.nicename.outputs.BOARD_NICENAME }}_kitchen_sink_${{ inputs.TAG }}.hex
# Run IDs are unique per repo but are reused on re-runs
- name: Save artifact
if: inputs.ARTIFACT == true
uses: actions/upload-artifact@v4
with:
name: build_artifacts_${{ github.run_id }}_${{ steps.nicename.outputs.BOARD_NICENAME }}
path: |
build/artifacts/*
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright (c) 2023 Golioth, Inc.
# SPDX-License-Identifier: Apache-2.0

name: Create Release

on:
workflow_dispatch:
inputs:
version:
description: 'Release Version.'
required: true
default: 'v0.0.0'
type: string

jobs:
build-binaries:
strategy:
matrix:
ZEPHYR_SDK: [0.16.3]
BOARD: ["nrf9160dk/nrf9160/ns","nrf7002dk/nrf5340/cpuapp"]

uses: ./.github/workflows/build_zephyr.yml
with:
ZEPHYR_SDK: ${{ matrix.ZEPHYR_SDK }}
BOARD: ${{ matrix.BOARD }}
ARTIFACT: true
TAG: ${{ inputs.version }}

upload-binaries:
needs: build-binaries

runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v4

- name: Download artifact
uses: actions/download-artifact@v4
with:
pattern: build_artifacts_*
path: ~/artifacts
merge-multiple: true

- name: Create Release manually with GH CLI
run: gh release create --title ${{ inputs.version }} --draft ${{ inputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload artifacts to release
run: gh release upload --clobber ${{ inputs.version }} ~/artifacts/*.*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2023 Golioth, Inc.
# SPDX-License-Identifier: Apache-2.0

name: Test firmware

on:
pull_request:

push:
#branches: [ main ]

jobs:
test_build_nrf9160dk:
uses: ./.github/workflows/build_zephyr.yml
with:
ZEPHYR_SDK: 0.16.3
BOARD: nrf9160dk/nrf9160/ns
ARTIFACT: false
test_build_nrf7002:
uses: ./.github/workflows/build_zephyr.yml
with:
ZEPHYR_SDK: 0.16.3
BOARD: nrf7002dk/nrf5340/cpuapp
ARTIFACT: false

0 comments on commit ed7239d

Please sign in to comment.