forked from wled/WLED
-
-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathset_version.py
More file actions
27 lines (22 loc) · 1.04 KB
/
set_version.py
File metadata and controls
27 lines (22 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Import('env') # PlatformIO-specific import
import json
import os
from datetime import datetime, timezone
PACKAGE_FILE = "package.json"
with open(PACKAGE_FILE, "r") as package:
version = json.load(package)["version"]
# Handle nightly build
if os.environ.get('WLED_NIGHTLY_BUILD', '').lower() in ('true', '1', 'yes'):
# VERSION format: yymmddb (b = build number, 0 for nightly)
version_code = datetime.now(timezone.utc).strftime("%y%m%d") + "0"
env.Append(BUILD_FLAGS=[f"-DWLED_BUILD_VERSION={version_code}"])
print(f"Nightly build: Setting VERSION to {version_code}")
# Update version tag: replace existing tag with "-nightly" or append "-nightly" if no tag
if "-" in version:
# Replace any existing tag with -nightly (handles multiple hyphens correctly)
version = version.rsplit("-", 1)[0] + "-nightly"
else:
# No tag present, append -nightly
version = version + "-nightly"
print(f"Nightly build: Using version string {version}")
env.Append(BUILD_FLAGS=[f"-DWLED_VERSION={version}"])