Skip to content
Snippets Groups Projects
Commit b97eabc4 authored by Cyril Danilevski's avatar Cyril Danilevski
Browse files

Add Git commit sha and time to CI build

parent bfd3e709
No related branches found
No related tags found
1 merge request!2Initial MPOD feature
...@@ -30,7 +30,7 @@ build: ...@@ -30,7 +30,7 @@ build:
- arduino-cli lib install --git-url https://github.com/patricklaf/SNMP.git --config-file arduino-cli.yaml - arduino-cli lib install --git-url https://github.com/patricklaf/SNMP.git --config-file arduino-cli.yaml
# Compile artifact # Compile artifact
- arduino-cli compile --fqbn esp32:esp32:esp32wroverkit icbm.ino --output-dir firmware - arduino-cli compile --fqbn esp32:esp32:esp32wroverkit icbm.ino --output-dir firmware --build-property build.extra_flags="-DICBM_GIT_VERSION=$CI_COMMIT_SHORT_SHA -DICBM_GIT_TIMESTAMP=$CI_COMMIT_TIMESTAMP"
- zip -r firmware.zip firmware - zip -r firmware.zip firmware
artifacts: artifacts:
when: always when: always
......
...@@ -35,7 +35,7 @@ board_manager: ...@@ -35,7 +35,7 @@ board_manager:
- http://arduino.esp8266.com/stable/package_esp8266com_index.json - http://arduino.esp8266.com/stable/package_esp8266com_index.json
``` ```
Update the arduino index with: Update the Arduino index with:
```bash ```bash
arduino-cli core update-index arduino-cli core update-index
...@@ -55,6 +55,13 @@ And uploaded so: ...@@ -55,6 +55,13 @@ And uploaded so:
arduino-cli upload -p /dev/ttyUSB1 --fqbn esp32:esp32:esp32wroverkit arduino-cli upload -p /dev/ttyUSB1 --fqbn esp32:esp32:esp32wroverkit
### Versioning
The firmware version is provided as part of the `/idn` route.
This is the git tag or commit, if `-DICBM_GIT_VERSION` is set.
The git date can be set via `-DICBM_GIT_TIMESTAMP`.
### CI Artefacts ### CI Artefacts
CI artefacts can be uploaded so: CI artefacts can be uploaded so:
......
#include "rest.hpp" #include "rest.hpp"
#include <ETH.h> #include <ETH.h>
#ifndef ICBM_GIT_VERSION
#define ICBM_GIT_VERSION "DEVEL" // set via -DICBM_GIT_VERSION
#endif
#ifndef ICBM_GIT_TIMESTAMP
#define ICBM_GIT_TIMESTAMP "UNKNOWN"
#endif
WebServer restServer(80); WebServer restServer(80);
void initializeRoutes() { void initializeRoutes() {
...@@ -26,7 +34,11 @@ void identify() { ...@@ -26,7 +34,11 @@ void identify() {
message += "\",\n"; message += "\",\n";
message += "\"version\":\""; message += "\"version\":\"";
message += "0.1"; // TODO: Get from Git message += ICBM_GIT_VERSION;
message += "\",\n";
message += "\"build date\":\"";
message += ICBM_GIT_TIMESTAMP;
message += "\",\n"; message += "\",\n";
message += "\"uptime\": \""; message += "\"uptime\": \"";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment