feat: add GitHub Actions workflow for automated release creation and update CHANGELOG.md structure
This commit is contained in:
31
scripts/combine_html.py
Normal file
31
scripts/combine_html.py
Normal file
@ -0,0 +1,31 @@
|
||||
Import("env")
|
||||
import os
|
||||
|
||||
def combine_html_files(source, target, env):
|
||||
html_dir = "./html"
|
||||
header_file = os.path.join(html_dir, "header.html")
|
||||
|
||||
# Read header content
|
||||
with open(header_file, 'r') as f:
|
||||
header_content = f.read()
|
||||
|
||||
# Process all HTML files except header.html
|
||||
for filename in os.listdir(html_dir):
|
||||
if filename.endswith('.html') and filename != 'header.html':
|
||||
file_path = os.path.join(html_dir, filename)
|
||||
|
||||
# Read content
|
||||
with open(file_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Replace placeholder with header content
|
||||
if '{{header}}' in content:
|
||||
new_content = content.replace('{{header}}', header_content)
|
||||
|
||||
# Write back combined content
|
||||
with open(file_path, 'w') as f:
|
||||
f.write(new_content)
|
||||
print(f"Combined header with {filename}")
|
||||
|
||||
# Register the script to run before building SPIFFS
|
||||
env.AddPreAction("buildfs", combine_html_files)
|
6
scripts/extra_script.py
Normal file
6
scripts/extra_script.py
Normal file
@ -0,0 +1,6 @@
|
||||
Import("env")
|
||||
|
||||
# Hook in die Build-Prozesse
|
||||
env.AddPreAction("uploadfs", env.VerboseAction("$PROJECT_DIR/scripts/buildfs.sh", "Building Filesystem Image..."))
|
||||
|
||||
env.AddPreAction("upload", env.VerboseAction("$PROJECT_DIR/scripts/uploadfs.sh", "Uploading Filesystem Image..."))
|
45
scripts/gzip_files.py
Normal file
45
scripts/gzip_files.py
Normal file
@ -0,0 +1,45 @@
|
||||
import gzip
|
||||
import os
|
||||
import shutil
|
||||
|
||||
## gzip files
|
||||
|
||||
def compress_file(input_file, output_file):
|
||||
with open(input_file, 'rb') as f_in:
|
||||
with gzip.open(output_file, 'wb') as f_out:
|
||||
f_out.writelines(f_in)
|
||||
|
||||
def copy_file(input_file, output_file):
|
||||
shutil.copy2(input_file, output_file)
|
||||
|
||||
def should_compress(file):
|
||||
# Komprimiere nur bestimmte Dateitypen
|
||||
return file.endswith(('.js', '.png', '.css', '.html'))
|
||||
|
||||
def main(source_dir, target_dir):
|
||||
for root, dirs, files in os.walk(source_dir):
|
||||
rel_path = os.path.relpath(root, source_dir)
|
||||
for file in files:
|
||||
input_file = os.path.join(root, file)
|
||||
output_file_compressed = os.path.join(target_dir, rel_path, file + '.gz')
|
||||
output_file_original = os.path.join(target_dir, rel_path, file)
|
||||
|
||||
os.makedirs(os.path.dirname(output_file_compressed), exist_ok=True)
|
||||
|
||||
if should_compress(file):
|
||||
compress_file(input_file, output_file_compressed)
|
||||
print(f'Compressed {input_file} to {output_file_compressed}')
|
||||
else:
|
||||
copy_file(input_file, output_file_original)
|
||||
print(f'Copied {input_file} to {output_file_original}')
|
||||
|
||||
def init():
|
||||
source_dir = 'html'
|
||||
target_dir = 'data'
|
||||
|
||||
if os.path.exists(target_dir):
|
||||
shutil.rmtree(target_dir)
|
||||
|
||||
main(source_dir, target_dir)
|
||||
|
||||
init()
|
25
scripts/pre_build.py
Normal file
25
scripts/pre_build.py
Normal file
@ -0,0 +1,25 @@
|
||||
Import("env")
|
||||
import os
|
||||
|
||||
def replace_version(source, target, env):
|
||||
# Get version from common section
|
||||
version = env.GetProjectConfig().get("common", "version").strip('"')
|
||||
header_file = "./html/header.html"
|
||||
|
||||
with open(header_file, 'r') as file:
|
||||
content = file.read()
|
||||
|
||||
# Replace version in header.html using string manipulation instead of regex
|
||||
search = '<h1>FilaMan<span class="version">v'
|
||||
end = '</span>'
|
||||
start_pos = content.find(search)
|
||||
if start_pos != -1:
|
||||
start_pos += len(search)
|
||||
end_pos = content.find(end, start_pos)
|
||||
if end_pos != -1:
|
||||
content = content[:start_pos] + version + content[end_pos:]
|
||||
|
||||
with open(header_file, 'w') as file:
|
||||
file.write(content)
|
||||
|
||||
env.AddPreAction("buildfs", replace_version)
|
7
scripts/pre_spiffs.py
Normal file
7
scripts/pre_spiffs.py
Normal file
@ -0,0 +1,7 @@
|
||||
Import("env")
|
||||
|
||||
# Wiederverwendung der replace_version Funktion
|
||||
exec(open("./scripts/pre_build.py").read())
|
||||
|
||||
# Bind to SPIFFS build
|
||||
env.AddPreAction("buildfs", replace_version)
|
36
scripts/update_changelog.py
Normal file
36
scripts/update_changelog.py
Normal file
@ -0,0 +1,36 @@
|
||||
import os
|
||||
import re
|
||||
from datetime import datetime
|
||||
|
||||
def get_version():
|
||||
with open('../platformio.ini', 'r') as f:
|
||||
content = f.read()
|
||||
version_match = re.search(r'version\s*=\s*"([^"]+)"', content)
|
||||
return version_match.group(1) if version_match else None
|
||||
|
||||
def update_changelog():
|
||||
version = get_version()
|
||||
today = datetime.now().strftime('%Y-%m-%d')
|
||||
|
||||
changelog_template = f"""## [{version}] - {today}
|
||||
### Added
|
||||
-
|
||||
|
||||
### Changed
|
||||
-
|
||||
|
||||
### Fixed
|
||||
-
|
||||
"""
|
||||
|
||||
with open('../CHANGELOG.md', 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Insert new version template after the header
|
||||
updated_content = content.replace("# Changelog\n", f"# Changelog\n\n{changelog_template}")
|
||||
|
||||
with open('../CHANGELOG.md', 'w') as f:
|
||||
f.write(updated_content)
|
||||
|
||||
if __name__ == "__main__":
|
||||
update_changelog()
|
Reference in New Issue
Block a user