feat: add GitHub Actions workflow for automated release creation and update CHANGELOG.md structure
This commit is contained in:
parent
2f34a0ca4e
commit
7ccacec68f
33
.github/workflows/release.yml
vendored
Normal file
33
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
name: Create Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Get version from tag
|
||||||
|
id: get_version
|
||||||
|
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/}
|
||||||
|
|
||||||
|
- name: Read CHANGELOG.md
|
||||||
|
id: changelog
|
||||||
|
run: |
|
||||||
|
CHANGELOG=$(awk "/## \[${{ steps.get_version.outputs.VERSION }}\]/{p=1;print;next} /## \[/{p=0} p" CHANGELOG.md)
|
||||||
|
echo "::set-output name=CHANGES::$CHANGELOG"
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.ref }}
|
||||||
|
release_name: Release ${{ steps.get_version.outputs.VERSION }}
|
||||||
|
body: ${{ steps.changelog.outputs.CHANGES }}
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
14
CHANGELOG.md
Normal file
14
CHANGELOG.md
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## [1.0.2] - 2025-02-16
|
||||||
|
### Added
|
||||||
|
- Feature 1
|
||||||
|
- Feature 2
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Change 1
|
||||||
|
- Change 2
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fix 1
|
||||||
|
- Fix 2
|
@ -8,6 +8,9 @@
|
|||||||
; Please visit documentation for the other options and examples
|
; Please visit documentation for the other options and examples
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
|
[common]
|
||||||
|
version = "1.0.2"
|
||||||
|
|
||||||
[env:esp32dev]
|
[env:esp32dev]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
board = esp32dev
|
board = esp32dev
|
||||||
@ -37,7 +40,12 @@ build_flags =
|
|||||||
-fdata-sections
|
-fdata-sections
|
||||||
-DNDEBUG
|
-DNDEBUG
|
||||||
-mtext-section-literals
|
-mtext-section-literals
|
||||||
|
'-D VERSION="${common.version}"'
|
||||||
|
|
||||||
extra_scripts =
|
extra_scripts =
|
||||||
pre:gzip_files.py
|
pre:scripts/combine_html.py
|
||||||
pre:extra_script.py
|
pre:scripts/pre_build.py
|
||||||
|
pre:scripts/pre_spiffs.py
|
||||||
|
pre:scripts/gzip_files.py
|
||||||
|
pre:scripts/extra_script.py
|
||||||
|
pre:scripts/update_changelog.py
|
||||||
|
34
release.sh
Normal file
34
release.sh
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Get version from platformio.ini
|
||||||
|
VERSION=$(grep '^version = ' platformio.ini | sed 's/version = "\(.*\)"/\1/')
|
||||||
|
|
||||||
|
if [ -z "$VERSION" ]; then
|
||||||
|
echo "Error: Could not find version in platformio.ini"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Creating release for version $VERSION"
|
||||||
|
|
||||||
|
# Check if working directory is clean
|
||||||
|
if [ -n "$(git status --porcelain)" ]; then
|
||||||
|
echo "Error: Working directory is not clean. Please commit all changes first."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create and push tag
|
||||||
|
git tag "v$VERSION"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Error: Failed to create tag v$VERSION"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
git push origin "v$VERSION"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Error: Failed to push tag v$VERSION"
|
||||||
|
git tag -d "v$VERSION"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Successfully created and pushed tag v$VERSION"
|
||||||
|
echo "GitHub Actions workflow will now create the release"
|
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)
|
@ -14,7 +14,7 @@ def copy_file(input_file, output_file):
|
|||||||
|
|
||||||
def should_compress(file):
|
def should_compress(file):
|
||||||
# Komprimiere nur bestimmte Dateitypen
|
# Komprimiere nur bestimmte Dateitypen
|
||||||
return file.endswith(('.js', '.png', '.css'))
|
return file.endswith(('.js', '.png', '.css', '.html'))
|
||||||
|
|
||||||
def main(source_dir, target_dir):
|
def main(source_dir, target_dir):
|
||||||
for root, dirs, files in os.walk(source_dir):
|
for root, dirs, files in os.walk(source_dir):
|
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()
|
Loading…
x
Reference in New Issue
Block a user