Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set version number using Actions #68

Merged
merged 5 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}'
])