forked from zephyrproject-rtos/example-application
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add github workflow with semver and release
- Loading branch information
1 parent
36602d0
commit 8a04ca3
Showing
44 changed files
with
833 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: SemVer Release & Build | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, closed] | ||
branches: main | ||
|
||
jobs: | ||
version: | ||
outputs: | ||
next: ${{steps.semver.outputs.next}} | ||
nextStrict: ${{steps.semver.outputs.nextStrict}} | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get Next Version | ||
id: semver | ||
uses: ietf-tools/semver-action@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: main | ||
|
||
build: | ||
runs-on: ubuntu-22.04 | ||
container: ghcr.io/zephyrproject-rtos/ci:v0.26.2 | ||
env: | ||
CMAKE_PREFIX_PATH: /opt/toolchains | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
path: example-application | ||
|
||
- name: Initialize | ||
working-directory: example-application | ||
run: | | ||
west init -l . | ||
west update | ||
- name: Build firmware | ||
working-directory: example-application | ||
run: | | ||
west twister -T app -v --inline-logs --integration | ||
- name: Twister Tests | ||
working-directory: example-application | ||
run: | | ||
west twister -T tests --integration | ||
release: | ||
runs-on: ubuntu-latest | ||
needs: [version,build] | ||
steps: | ||
- name: Create Release | ||
uses: ncipollo/[email protected] | ||
with: | ||
allowUpdates: true | ||
draft: false | ||
makeLatest: true | ||
generateReleaseNotes: true | ||
name: ${{ needs.version.outputs.next }} | ||
body: Changelog Contents | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
artifacts: "README.md,LICENSE,app/build/zephyr/${{ github.repository }}-${{ needs.version.outputs.nextStrict }}.uf2" | ||
commit: ${{ github.sha }} | ||
tag: ${{ needs.version.outputs.next }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# editors | ||
.vscode | ||
*.swp | ||
*~ | ||
|
||
# python | ||
.venv | ||
|
||
# build | ||
/build* | ||
/twister-out* | ||
|
||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright (c) 2021 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# This CMake file is picked by the Zephyr build system because it is defined | ||
# as the module CMake entry point (see zephyr/module.yml). | ||
|
||
zephyr_include_directories(include) | ||
|
||
add_subdirectory(drivers) | ||
add_subdirectory(lib) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) 2021 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# This Kconfig file is picked by the Zephyr build system because it is defined | ||
# as the module Kconfig entry point (see zephyr/module.yml). You can browse | ||
# module options by going to Zephyr -> Modules in Kconfig. | ||
|
||
rsource "drivers/Kconfig" | ||
rsource "lib/Kconfig" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,80 @@ | ||
# example-application | ||
Example out-of-tree application that is also a module | ||
# Zephyr Example Application | ||
|
||
This repository contains a Zephyr example application. The main purpose of this | ||
repository is to serve as a reference on how to structure Zephyr-based | ||
applications. Some of the features demonstrated in this example are: | ||
|
||
- Basic [Zephyr application][app_dev] skeleton | ||
- [Zephyr workspace applications][workspace_app] | ||
- [Zephyr modules][modules] | ||
- [West T2 topology][west_t2] | ||
- [Custom boards][board_porting] | ||
- Custom [devicetree bindings][bindings] | ||
- Out-of-tree [drivers][drivers] | ||
- Out-of-tree libraries | ||
- Example CI configuration (using Github Actions) | ||
- Custom [west extension][west_ext] | ||
|
||
This repository is versioned together with the [Zephyr main tree][zephyr]. This | ||
means that every time that Zephyr is tagged, this repository is tagged as well | ||
with the same version number, and the [manifest](west.yml) entry for `zephyr` | ||
will point to the corresponding Zephyr tag. For example, the `example-application` | ||
v2.6.0 will point to Zephyr v2.6.0. Note that the `main` branch always | ||
points to the development branch of Zephyr, also `main`. | ||
|
||
[app_dev]: https://docs.zephyrproject.org/latest/develop/application/index.html | ||
[workspace_app]: https://docs.zephyrproject.org/latest/develop/application/index.html#zephyr-workspace-app | ||
[modules]: https://docs.zephyrproject.org/latest/develop/modules.html | ||
[west_t2]: https://docs.zephyrproject.org/latest/develop/west/workspaces.html#west-t2 | ||
[board_porting]: https://docs.zephyrproject.org/latest/guides/porting/board_porting.html | ||
[bindings]: https://docs.zephyrproject.org/latest/guides/dts/bindings.html | ||
[drivers]: https://docs.zephyrproject.org/latest/reference/drivers/index.html | ||
[zephyr]: https://github.com/zephyrproject-rtos/zephyr | ||
[west_ext]: https://docs.zephyrproject.org/latest/develop/west/extensions.html | ||
|
||
## Getting Started | ||
|
||
Before getting started, make sure you have a proper Zephyr development | ||
environment. Follow the official | ||
[Zephyr Getting Started Guide](https://docs.zephyrproject.org/latest/getting_started/index.html). | ||
|
||
### Initialization | ||
|
||
The first step is to initialize the workspace folder (``my-workspace``) where | ||
the ``example-application`` and all Zephyr modules will be cloned. Run the following | ||
command: | ||
|
||
```shell | ||
# initialize my-workspace for the example-application (main branch) | ||
west init -m https://github.com/zephyrproject-rtos/example-application --mr main my-workspace | ||
# update Zephyr modules | ||
cd my-workspace | ||
west update | ||
``` | ||
|
||
### Building and running | ||
|
||
To build the application, run the following command: | ||
|
||
```shell | ||
west build -b $BOARD app | ||
``` | ||
|
||
where `$BOARD` is the target board. | ||
|
||
You can use the `custom_plank` board found in this | ||
repository. Note that Zephyr sample boards may be used if an | ||
appropriate overlay is provided (see `app/boards`). | ||
|
||
A sample debug configuration is also provided. To apply it, run the following | ||
command: | ||
|
||
```shell | ||
west build -b $BOARD app -- -DOVERLAY_CONFIG=debug.conf | ||
``` | ||
|
||
Once you have built the application, run the following command to flash it: | ||
|
||
```shell | ||
west flash | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#------------------------------------------------------------------------------- | ||
# Zephyr Example Application | ||
# | ||
# Copyright (c) 2021 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.13.1) | ||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
|
||
project(app LANGUAGES C) | ||
|
||
target_sources(app PRIVATE src/main.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright (c) 2021 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# This file is the application Kconfig entry point. All application Kconfig | ||
# options can be defined here or included via other application Kconfig files. | ||
# You can browse these options using the west targets menuconfig (terminal) or | ||
# guiconfig (GUI). | ||
|
||
menu "Zephyr" | ||
source "Kconfig.zephyr" | ||
endmenu | ||
|
||
module = APP | ||
module-str = APP | ||
source "subsys/logging/Kconfig.template.log_config" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
VERSION_MAJOR = 1 | ||
VERSION_MINOR = 0 | ||
PATCHLEVEL = 0 | ||
VERSION_TWEAK = 0 | ||
EXTRAVERSION = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (c) 2021 Nordic Semiconductor ASA | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/* This devicetree overlay file will be automatically picked by the Zephyr | ||
* build system when building the sample for the nucleo_f302r8 board. It shows | ||
* how the example-application can be built on sample boards already provided | ||
* by Zephyr. | ||
*/ | ||
|
||
/ { | ||
examplesensor0: examplesensor_0 { | ||
compatible = "zephyr,examplesensor"; | ||
input-gpios = <&gpioc 13 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; | ||
}; | ||
}; | ||
|
||
&gpioc { | ||
status = "okay"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Copyright (c) 2021 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# This is a Kconfig fragment which can be used to enable debug-related options | ||
# in the application. See the README for more details. | ||
|
||
# compiler | ||
CONFIG_DEBUG_OPTIMIZATIONS=y | ||
|
||
# console | ||
CONFIG_CONSOLE=y | ||
|
||
# UART console | ||
CONFIG_SERIAL=y | ||
CONFIG_UART_CONSOLE=y | ||
|
||
# logging | ||
CONFIG_LOG=y | ||
CONFIG_APP_LOG_LEVEL_DBG=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Copyright (c) 2021 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# This file contains selected Kconfig options for the application. | ||
|
||
CONFIG_SENSOR=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# This file is provided so that the application can be compiled using Twister, | ||
# the Zephyr testing tool. In this file, multiple combinations can be specified, | ||
# so that you can easily test all of them locally or in CI. | ||
sample: | ||
description: Example application | ||
name: example-application | ||
common: | ||
build_only: true | ||
integration_platforms: | ||
- custom_plank | ||
- nucleo_f302r8 | ||
tests: | ||
app.default: {} | ||
app.debug: | ||
extra_overlay_confs: | ||
- debug.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) 2021 Nordic Semiconductor ASA | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/drivers/sensor.h> | ||
#include <app_version.h> | ||
|
||
#include <zephyr/logging/log.h> | ||
LOG_MODULE_REGISTER(main, CONFIG_APP_LOG_LEVEL); | ||
|
||
int main(void) | ||
{ | ||
int ret; | ||
const struct device *sensor; | ||
|
||
printk("Zephyr Example Application %s\n", APP_VERSION_STRING); | ||
|
||
sensor = DEVICE_DT_GET(DT_NODELABEL(examplesensor0)); | ||
if (!device_is_ready(sensor)) { | ||
LOG_ERR("Sensor not ready"); | ||
return 0; | ||
} | ||
|
||
while (1) { | ||
struct sensor_value val; | ||
|
||
ret = sensor_sample_fetch(sensor); | ||
if (ret < 0) { | ||
LOG_ERR("Could not fetch sample (%d)", ret); | ||
return 0; | ||
} | ||
|
||
ret = sensor_channel_get(sensor, SENSOR_CHAN_PROX, &val); | ||
if (ret < 0) { | ||
LOG_ERR("Could not get sample (%d)", ret); | ||
return 0; | ||
} | ||
|
||
printk("Sensor value: %d\n", val.val1); | ||
|
||
k_sleep(K_MSEC(1000)); | ||
} | ||
|
||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright (c) 2021 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config BOARD_ENABLE_DCDC | ||
bool "Enable DCDC mode" | ||
select SOC_DCDC_NRF52X | ||
default y | ||
depends on BOARD_CUSTOM_PLANK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Copyright (c) 2021 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
config BOARD_CUSTOM_PLANK | ||
bool "Custom Plank Board" | ||
depends on SOC_NRF52840_QIAA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) 2021 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
if BOARD_CUSTOM_PLANK | ||
|
||
config BOARD | ||
default "custom_plank" | ||
|
||
endif # BOARD_CUSTOM_PLANK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Custom Plank Board | ||
|
||
`custom_plank` board is used to demonstrate how to create custom boards. It is | ||
in fact a simplified version of the nRF52840-DK board, so the | ||
`example-application` can be run on that development kit when using | ||
`custom_plank`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright (c) 2021 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
board_runner_args(jlink "--device=nrf52" "--speed=4000") | ||
board_runner_args(pyocd "--target=nrf52840" "--frequency=4000000") | ||
|
||
set(OPENOCD_NRF5_SUBFAMILY "nrf52") | ||
|
||
include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake) | ||
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) | ||
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake) | ||
include(${ZEPHYR_BASE}/boards/common/openocd-nrf5.board.cmake) |
Oops, something went wrong.