feat: update version to 1.0.5 and enhance changelog update process with automatic git push

This commit is contained in:
Manuel Weiser 2025-02-16 10:47:18 +01:00
parent 8741216374
commit cc17140dc4
2 changed files with 28 additions and 1 deletions

View File

@ -9,7 +9,7 @@
; https://docs.platformio.org/page/projectconf.html ; https://docs.platformio.org/page/projectconf.html
[common] [common]
version = "1.0.4" version = "1.0.5"
[env:esp32dev] [env:esp32dev]
platform = espressif32 platform = espressif32

View File

@ -64,6 +64,31 @@ def get_changes_from_git():
return changes return changes
def push_changes(version):
"""Push changes to upstream"""
try:
# Stage the CHANGELOG.md
subprocess.run(['git', 'add', 'CHANGELOG.md'], check=True)
# Commit the changelog
commit_msg = f"docs: update changelog for version {version}"
subprocess.run(['git', 'commit', '-m', commit_msg], check=True)
# Push to origin (local)
subprocess.run(['git', 'push', 'origin'], check=True)
print("Successfully pushed to origin")
# Ask for upstream push
response = input("Do you want to push to GitHub (upstream)? (y/n): ").lower()
if response == 'y':
subprocess.run(['git', 'push', 'upstream'], check=True)
print("Successfully pushed to upstream")
except subprocess.CalledProcessError as e:
print(f"Error during git operations: {e}")
return False
return True
def update_changelog(): def update_changelog():
version = get_version() version = get_version()
today = datetime.now().strftime('%Y-%m-%d') today = datetime.now().strftime('%Y-%m-%d')
@ -90,6 +115,7 @@ def update_changelog():
if not os.path.exists(changelog_path): if not os.path.exists(changelog_path):
with open(changelog_path, 'w') as f: with open(changelog_path, 'w') as f:
f.write(f"# Changelog\n\n{changelog_entry}") f.write(f"# Changelog\n\n{changelog_entry}")
push_changes(version)
else: else:
with open(changelog_path, 'r') as f: with open(changelog_path, 'r') as f:
content = f.read() content = f.read()
@ -98,6 +124,7 @@ def update_changelog():
updated_content = content.replace("# Changelog\n", f"# Changelog\n\n{changelog_entry}") updated_content = content.replace("# Changelog\n", f"# Changelog\n\n{changelog_entry}")
with open(changelog_path, 'w') as f: with open(changelog_path, 'w') as f:
f.write(updated_content) f.write(updated_content)
push_changes(version)
else: else:
print(f"Version {version} already exists in changelog") print(f"Version {version} already exists in changelog")