Skip to content

Commit

Permalink
Set version number using Actions (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeroniemi authored Jun 4, 2024
1 parent 1dc741e commit 1757e34
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pio-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ jobs:
python -m pip install --upgrade pip
pip install --upgrade platformio
- name: Build PlatformIO Project
env:
VERSION: ${{ github.ref_name }}
run: pio run
- name: Archive production artifacts
uses: actions/upload-artifact@v4
Expand Down
3 changes: 2 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ lib_deps =
M5Dial-LVGL=https://github.com/aeroniemi/M5Dial-LVGL.git#v0.1.0
jnthas/Improv WiFi Library@0.0.2
extra_scripts =
post:./support/merge_bin.py
post:./support/merge_bin.py
pre:./support/get_version.py
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void setup()
NULL, /* Task handle. */
0); /* Core where the task should run */
improvSerial.onImprovConnected(*storeImprovSettings);
improvSerial.setDeviceInfo(ImprovTypes::ChipFamily::CF_ESP32_S3, "CircleHome", "1.0.0", "My Device");
improvSerial.setDeviceInfo(ImprovTypes::ChipFamily::CF_ESP32_S3, "CircleHome", VERSION, "My Device");
ha->setHost(settings.getString("ha_hostname", "homeasssistant.local"));
ha->setPort(settings.getInt("ha_port", 8123));
Serial.setDebugOutput(true);
Expand Down
9 changes: 8 additions & 1 deletion src/ui/ui.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#pragma once
#include <lvgl.h>
#include "screens/screens.h"

#ifndef VERSION
#define STRINGIZER(arg) #arg
#define STR_VALUE(arg) STRINGIZER(arg)
#define VERSION STR_VALUE(BUILD_VERSION)
#endif
void ui_init();
extern void globalEventHandler(lv_event_t *e);
extern void globalEventHandler(lv_event_t *e);

24 changes: 24 additions & 0 deletions support/get_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# source from https://github.com/MobiFlight/MobiFlight-FirmwareSource/blob/main/get_version.py

Import("env")
import os

# Get the version number from the build environment.
version = os.environ.get('VERSION', "")

# Clean up the version number
if version == "":
# When no version is specified default to "0.0.1"
version = "0.0.1"

# Strip any leading "v" that might be on the version and
# any leading or trailing periods.
version = version.lstrip("v")
version = version.strip(".")

print(f'Using version {version} for the build')

# Append the version to the build defines so it gets baked into the firmware
env.Append(CPPDEFINES=[
f'BUILD_VERSION={version}'
])

0 comments on commit 1757e34

Please sign in to comment.