mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-11-21 12:56:27 +00:00
chore(release): Release v0.2.0
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
195
CHANGELOG.md
195
CHANGELOG.md
@@ -5,79 +5,142 @@ All notable changes to the akkudoktoreos project will be documented in this file
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## 0.1.0+dev (2025-10-26)
|
||||
## 0.2.0 (2025-11-09)
|
||||
|
||||
### feat
|
||||
- setup default device configuration for automatic optimization
|
||||
- allow configuration of genetic algorithm parameters
|
||||
- allow configuration of home appliance time windows
|
||||
- mitigate old config
|
||||
- standardize measurement keys for battery/EV SoC measurements
|
||||
- feed-in tariff prediction support (incl. tests and docs)
|
||||
- energy management plan generation based on S2 standard instructions
|
||||
- make measurement keys configurable through EOS configuration
|
||||
- use pendulum types with pydantic via pydantic_extra_types.pendulum_dt
|
||||
- add Time, TimeWindow, TimeWindowSequence and to_time to datetimeutil
|
||||
- extend DataRecord with configurable field-like data
|
||||
- enrich health endpoints with version and optimization timestamps
|
||||
- add pydantic merge model tests
|
||||
- add plan tab to EOSdash
|
||||
- add predictions tab to EOSdash
|
||||
- add cache management to EOSdash admin tab
|
||||
- add about tab to EOSdash
|
||||
- adapt changelog & documentation for commitizen release flow
|
||||
- improve install and development documentation
|
||||
The most important new feature is **automatic optimization**.
|
||||
EOS can now independently perform optimization at regular intervals.
|
||||
This is based on the configured system parameters and forecasts, and also uses supplied
|
||||
measurement data, such as the current battery SoC.
|
||||
The result is an energy-management plan as well as the optimization output.
|
||||
The existing optimization interface using `POST /optimize` remains available and can still
|
||||
be used as before.
|
||||
|
||||
### fix
|
||||
- automatic optimization (interval execution, locking, new endpoints)
|
||||
- recognize environment variables on EOS server startup
|
||||
- remove 0.0.0.0 → localhost translation on Windows
|
||||
- allow hostnames as well as IPs
|
||||
- access pydantic model fields via class instead of instance
|
||||
- downsampling in key_to_array
|
||||
- /v1/admin/cache/clear now clears all cache files; new /clear-expired endpoint
|
||||
- replace timezonefinder with tzfpy for accurate European timezones
|
||||
- explicit provider settings in config versus union
|
||||
In addition, bugs were fixed and new features were added:
|
||||
|
||||
- Automatic optimization creates a **default configuration** if none is provided.
|
||||
This is intended to make it easier to create a custom configuration by adapting the default.
|
||||
- The parameters of the genetic optimization algorithm (number of generations, etc.) are now
|
||||
configurable.
|
||||
- For home appliances, start windows can now be specified (experimental).
|
||||
- Configuration files from previous versions are converted to the current format on first launch.
|
||||
- There are now measurement keys that are permanently assigned to a specific device simulation.
|
||||
This simplifies providing measurement values for device simulations (e.g. battery SoC).
|
||||
- The infrastructure and first applications for **feed-in tariff forecasting**
|
||||
(currently only fixed tariffs) are now integrated.
|
||||
- EOSdash has been expanded with new tabs for displaying the **energy-management plan**
|
||||
and **predictions**.
|
||||
- The documentation has been updated and expanded in many places.
|
||||
|
||||
### Feat
|
||||
|
||||
- Energy-management plan generation based on S2 standard instructions
|
||||
- Feed-in-tariff prediction support (incl. tests & docs)
|
||||
- `LoadAkkudoktorAdjusted` load prediction variant
|
||||
- Standardized measurement keys for battery/EV SoC
|
||||
- Measurement keys configurable via EOS configuration
|
||||
- Setup default device configuration for automatic optimization
|
||||
- Health endpoints show version + last optimization timestamps
|
||||
- Configuration of genetic algorithm parameters
|
||||
- Configuration options for home-appliance time windows
|
||||
- Mitigation of legacy configuration
|
||||
- Config backup enhancements:
|
||||
|
||||
- Timestamp-based backup IDs
|
||||
- API to list backups
|
||||
- API to revert to a specific backup
|
||||
- EOSdash Admin tab integration
|
||||
|
||||
- Pendulum date types via `pydantic_extra_types.pendulum_dt`
|
||||
- `Time`, `TimeWindow`, `TimeWindowSequence`, and `to_time` helpers in `datetimeutil`
|
||||
- Extended `DataRecord` with configurable field-like semantics
|
||||
- EOSdash: Solution view now displays genetic optimization results and aggregated totals
|
||||
- EOSdash UI:
|
||||
|
||||
- Plan tab
|
||||
- Predictions tab
|
||||
- Cache management in Admin tab
|
||||
- About tab
|
||||
|
||||
- Pydantic merge model tests
|
||||
- Developer profiling entry in Makefile
|
||||
- Changelog & docs updated for commitizen release flow
|
||||
- Developer documentation updated
|
||||
- Improved install & development documentation
|
||||
|
||||
### Changed
|
||||
|
||||
- Battery simulation
|
||||
|
||||
- Performance improvements
|
||||
- Charge + start times now reflect realistic simulation
|
||||
|
||||
- Appliance simulation:
|
||||
|
||||
- Time windows may roll over to next day
|
||||
|
||||
- Revised load prediction by splitting original `LoadAkkudoktor` into:
|
||||
|
||||
- `LoadAkkudoktor`
|
||||
- `LoadAkkudoktorAdjusted`
|
||||
|
||||
### Fixed
|
||||
|
||||
- Correct URL/path for Akkudoktor forum in README
|
||||
- Automatic optimization:
|
||||
|
||||
- Reuses previous start solution
|
||||
- Interval execution + locking + new endpoints
|
||||
- Properly loads required data
|
||||
- EV charge-rate migration for proper availability
|
||||
|
||||
- Genetic common settings consistently available
|
||||
- Config markdown generation
|
||||
- Recognize environment variables on EOS server startup
|
||||
- Remove `0.0.0.0 → localhost` translation on Windows
|
||||
- Allow hostnames as well as IPs
|
||||
- Access Pydantic model fields via class instead of instance
|
||||
- Down-sampling in `key_to_array`
|
||||
- `/v1/admin/cache/clear` clears all cache files; added `/clear-expired`
|
||||
- Use `tzfpy` instead of timezonefinder for more accurate EU timezones
|
||||
- Explicit provider settings in config instead of union
|
||||
- ClearOutside weather prediction irradiance calculation
|
||||
- test config file priority without config_eos fixture
|
||||
- complete optimization sample request documentation
|
||||
- replace gitlint with commitizen
|
||||
- synchronize pre-commit config with real dependencies
|
||||
- add missing babel to requirements
|
||||
- fix documentation, tests, and implementation around optimization and predictions
|
||||
- Test config file priority without `config_eos` fixture
|
||||
- Complete optimization sample-request documentation
|
||||
- Replace gitlint with commitizen
|
||||
- Synchronize pre-commit config with real dependencies
|
||||
- Add missing `babel` to requirements
|
||||
- Fix documentation, tests, and implementation around optimization + predictions
|
||||
|
||||
### chore
|
||||
- use memory cache for inverter interpolation
|
||||
- refactor genetic algorithm modules (split config, remove device singleton)
|
||||
- rename memory cache to CacheEnergyManagementStore
|
||||
- use class properties for config/ems/prediction mixins
|
||||
- skip matplotlib debug logs
|
||||
- auto-sync Bokeh JS CDN version
|
||||
- rename hello.py to about.py in EOSdash
|
||||
- remove demo page from EOSdash
|
||||
- split server test for system test
|
||||
- move doc utils to generate_config_md.py
|
||||
- improve documentation for pydantic merge models
|
||||
- remove pendulum warning from README
|
||||
- drop GitHub Discussions from contributing docs
|
||||
- bump version to 0.1.0+dev
|
||||
- rename or reorganize files/classes during refactoring
|
||||
### Chore
|
||||
|
||||
### build
|
||||
- bump fastapi[standard] 0.115.14 → 0.117.1 and fix pytest-cov version
|
||||
- bump uvicorn 0.36.0 → 0.37.0
|
||||
- Use memory cache for inverter interpolation
|
||||
- Refactor genetic modules (split config, remove device singleton)
|
||||
- Rename memory cache to `CacheEnergyManagementStore`
|
||||
- Use class properties for config/EMS/prediction mixins
|
||||
- Skip matplotlib debug logs
|
||||
- Auto-sync Bokeh JS CDN version
|
||||
- Rename `hello.py` → `about.py` in EOSdash
|
||||
- Remove EOSdash demo page
|
||||
- Split server test from system test
|
||||
- Move doc utils to `generate_config_md.py`
|
||||
- Improve documentation for pydantic merge models
|
||||
- Remove pendulum warning from README
|
||||
- Drop GitHub Discussions from contributing docs
|
||||
- Rename or reorganize files / classes during refactors
|
||||
|
||||
### BREAKING CHANGE
|
||||
EOS configuration and v1 API were changed:
|
||||
### BREAKING CHANGES
|
||||
|
||||
- available_charge_rates_percent removed; replaced by new charge_rate config
|
||||
- optimization param hours renamed to horizon_hours
|
||||
- device config must now list devices and their properties explicitly
|
||||
- specific prediction provider configuration versus union
|
||||
- measurement keys provided as lists
|
||||
- new feed-in tariff providers must be configured
|
||||
- /v1/measurement/loadxxx endpoints removed (use generic measurement endpoints)
|
||||
- /v1/admin/cache/clear clears all cache files; use /v1/admin/cache/clear-expired for expired-only clearing
|
||||
EOS configuration + v1 API have changed:
|
||||
|
||||
- `available_charge_rates_percent` removed → replaced by `charge_rate`
|
||||
- Optimization parameter `hours` → renamed to `horizon_hours`
|
||||
- Device config must explicitly list devices + properties
|
||||
- Prediction providers now explicit (instead of union)
|
||||
- Measurement keys provided as lists
|
||||
- Feed-in-tariff providers must be explicitly configured
|
||||
- `/v1/measurement/loadxxx` endpoints removed → use generic measurement endpoints
|
||||
- `/v1/admin/cache/clear` now clears **all*- cache files;
|
||||
`/v1/admin/cache/clear-expired` only clears expired entries
|
||||
|
||||
## v0.1.0 (2025-09-30)
|
||||
|
||||
|
||||
12
Makefile
12
Makefile
@@ -162,7 +162,15 @@ docker-build:
|
||||
@docker compose build --pull
|
||||
|
||||
# Bump Akkudoktoreos version
|
||||
VERSION ?= 0.2.0
|
||||
NEW_VERSION ?= $(VERSION)+dev
|
||||
|
||||
bump: pip-dev
|
||||
@echo "Bumping akkudoktoreos version to release version"
|
||||
@echo "Bumping akkudoktoreos version from $(VERSION) to $(NEW_VERSION) (dry-run: $(EXTRA_ARGS))"
|
||||
.venv/bin/python scripts/convert_lightweight_tags.py
|
||||
.venv/bin/cz bump
|
||||
.venv/bin/python scripts/bump_version.py $(VERSION) $(NEW_VERSION) $(EXTRA_ARGS)
|
||||
|
||||
bump-dry: pip-dev
|
||||
@echo "Bumping akkudoktoreos version from $(VERSION) to $(NEW_VERSION) (dry-run: --dry-run)"
|
||||
.venv/bin/python scripts/convert_lightweight_tags.py
|
||||
.venv/bin/python scripts/bump_version.py $(VERSION) $(NEW_VERSION) --dry-run
|
||||
|
||||
@@ -21,7 +21,7 @@ Properties:
|
||||
|
||||
| Name | Environment Variable | Type | Read-Only | Default | Description |
|
||||
| ---- | -------------------- | ---- | --------- | ------- | ----------- |
|
||||
| version | `EOS_GENERAL__VERSION` | `str` | `rw` | `0.1.0+dev` | Configuration file version. Used to check compatibility. |
|
||||
| version | `EOS_GENERAL__VERSION` | `str` | `rw` | `0.2.0` | Configuration file version. Used to check compatibility. |
|
||||
| data_folder_path | `EOS_GENERAL__DATA_FOLDER_PATH` | `Optional[pathlib.Path]` | `rw` | `None` | Path to EOS data directory. |
|
||||
| data_output_subpath | `EOS_GENERAL__DATA_OUTPUT_SUBPATH` | `Optional[pathlib.Path]` | `rw` | `output` | Sub-path for the EOS output data directory. |
|
||||
| latitude | `EOS_GENERAL__LATITUDE` | `Optional[float]` | `rw` | `52.52` | Latitude in decimal degrees, between -90 and 90, north is positive (ISO 19115) (°) |
|
||||
@@ -39,7 +39,7 @@ Properties:
|
||||
|
||||
{
|
||||
"general": {
|
||||
"version": "0.1.0+dev",
|
||||
"version": "0.2.0",
|
||||
"data_folder_path": null,
|
||||
"data_output_subpath": "output",
|
||||
"latitude": 52.52,
|
||||
@@ -55,7 +55,7 @@ Properties:
|
||||
|
||||
{
|
||||
"general": {
|
||||
"version": "0.1.0+dev",
|
||||
"version": "0.2.0",
|
||||
"data_folder_path": null,
|
||||
"data_output_subpath": "output",
|
||||
"latitude": 52.52,
|
||||
@@ -1780,7 +1780,7 @@ Validators:
|
||||
|
||||
{
|
||||
"general": {
|
||||
"version": "0.1.0+dev",
|
||||
"version": "0.2.0",
|
||||
"data_folder_path": null,
|
||||
"data_output_subpath": "output",
|
||||
"latitude": 52.52,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Akkudoktor-EOS
|
||||
|
||||
**Version**: `v0.1.0+dev`
|
||||
**Version**: `v0.2.0`
|
||||
|
||||
**Description**: This project provides a comprehensive solution for simulating and optimizing an energy system based on renewable energy sources. With a focus on photovoltaic (PV) systems, battery storage (batteries), load management (consumer requirements), heat pumps, electric vehicles, and consideration of electricity price data, this system enables forecasting and optimization of energy flow and costs over a specified period.
|
||||
|
||||
|
||||
@@ -138,16 +138,16 @@ This method is recommended for users who want a stable, tested version.
|
||||
### 1) Download the Latest Release (M2)
|
||||
|
||||
Visit the [Releases page](https://github.com/Akkudoktor-EOS/EOS/tags) and download the latest
|
||||
release package (e.g., `akkudoktoreos-v0.1.0.tar.gz` or `akkudoktoreos-v0.1.0.zip`).
|
||||
release package (e.g., `akkudoktoreos-v0.2.0.tar.gz` or `akkudoktoreos-v0.2.0.zip`).
|
||||
|
||||
### 2) Extract the Package (M2)
|
||||
|
||||
```bash
|
||||
tar -xzf akkudoktoreos-v0.1.0.tar.gz # For .tar.gz
|
||||
tar -xzf akkudoktoreos-v0.2.0.tar.gz # For .tar.gz
|
||||
# or
|
||||
unzip akkudoktoreos-v0.1.0.zip # For .zip
|
||||
unzip akkudoktoreos-v0.2.0.zip # For .zip
|
||||
|
||||
cd akkudoktoreos-v0.1.0
|
||||
cd akkudoktoreos-v0.2.0
|
||||
```
|
||||
|
||||
### 3) Create a virtual environment and run and configure EOS (M2)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# Release Process
|
||||
|
||||
This document describes how to prepare and publish a new release **via a Pull Request from a fork**,
|
||||
using **Commitizen** to manage versioning and changelogs — and how to set a **development version** after the release.
|
||||
and how to set a **development version** after the release.
|
||||
|
||||
## ✅ Overview of the Process
|
||||
|
||||
@@ -20,7 +20,7 @@ using **Commitizen** to manage versioning and changelogs — and how to set a **
|
||||
|
||||
### 1️⃣ Contributor: Prepare the Release in Your Fork
|
||||
|
||||
**Clone and sync your fork:**
|
||||
#### Clone and sync your fork
|
||||
|
||||
```bash
|
||||
git clone https://github.com/<your-username>/EOS
|
||||
@@ -32,25 +32,50 @@ git checkout main
|
||||
git pull eos main
|
||||
````
|
||||
|
||||
**Create the release branch:**
|
||||
#### Create the release branch
|
||||
|
||||
```bash
|
||||
git checkout -b release/vX.Y.Z
|
||||
```
|
||||
|
||||
**Run Commitizen to bump version and update changelog:**
|
||||
#### Bump the version information
|
||||
|
||||
At least update
|
||||
|
||||
- pyproject.toml
|
||||
- src/akkudoktoreos/core/version.py
|
||||
- src/akkudoktoreos/data/default.config.json
|
||||
- Makefile
|
||||
|
||||
and the generated documentation:
|
||||
|
||||
```bash
|
||||
make bump
|
||||
make bump VERSION=0.1.0+dev NEW_VERSION=X.Y.Z
|
||||
make gen-docs
|
||||
```
|
||||
|
||||
> ✅ This updates version files and `CHANGELOG.md` in a single commit.
|
||||
> 🚫 **Do not push tags** — tags are created by the maintainer via GitHub Releases.
|
||||
|
||||
**Push the branch to your fork:**
|
||||
You may check the changes by:
|
||||
|
||||
```bash
|
||||
git push origin release/vX.Y.Z
|
||||
git diff
|
||||
```
|
||||
|
||||
#### Create a new CHANGELOG.md entry
|
||||
|
||||
Edit CHANGELOG.md
|
||||
|
||||
#### Create the new release commit
|
||||
|
||||
```bash
|
||||
git add pyproject.toml src/akkudoktoreos/core/version.py \
|
||||
src/akkudoktoreos/data/default.config.json Makefile CHANGELOG.md
|
||||
git commit -s -m "chore(release): Release vX.Y.Z"
|
||||
```
|
||||
|
||||
#### Push the branch to your fork
|
||||
|
||||
```bash
|
||||
git push --set-upstream origin release/vX.Y.Z
|
||||
```
|
||||
|
||||
### 2️⃣ Contributor: Open the Release Pull Request
|
||||
@@ -62,7 +87,7 @@ git push origin release/vX.Y.Z
|
||||
**PR Title:**
|
||||
|
||||
```text
|
||||
Release vX.Y.Z
|
||||
chore(release): release vX.Y.Z
|
||||
```
|
||||
|
||||
**PR Description Template:**
|
||||
@@ -73,7 +98,7 @@ Release vX.Y.Z
|
||||
This pull request prepares release **vX.Y.Z**.
|
||||
|
||||
### Changes
|
||||
- Version bump via Commitizen
|
||||
- Version bump
|
||||
- Changelog update
|
||||
|
||||
### Changelog Summary
|
||||
@@ -86,15 +111,15 @@ See `CHANGELOG.md` for full details.
|
||||
|
||||
**Review Checklist:**
|
||||
|
||||
* ✅ Only version files and `CHANGELOG.md` are modified
|
||||
* ✅ Version numbers are consistent
|
||||
* ✅ Changelog is complete and properly formatted
|
||||
* ✅ No unrelated changes are included
|
||||
- ✅ Only version files and `CHANGELOG.md` are modified
|
||||
- ✅ Version numbers are consistent
|
||||
- ✅ Changelog is complete and properly formatted
|
||||
- ✅ No unrelated changes are included
|
||||
|
||||
**Merge Strategy:**
|
||||
|
||||
* Prefer **Merge Commit** (or **Squash Merge**, per project preference)
|
||||
* Use commit message: `Release vX.Y.Z`
|
||||
- Prefer **Merge Commit** (or **Squash Merge**, per project preference)
|
||||
- Use commit message: `chore(release): Release vX.Y.Z`
|
||||
|
||||
### 4️⃣ Maintainer: Publish the GitHub Release
|
||||
|
||||
@@ -121,21 +146,21 @@ git pull eos main
|
||||
git checkout -b release/vX.Y.Z_dev
|
||||
```
|
||||
|
||||
**Set development marker manually:**
|
||||
|
||||
The following files have to be updated:
|
||||
|
||||
* pyproject.toml
|
||||
* src/akkudoktoreos/core/version.py
|
||||
* src/data/default.config.json
|
||||
|
||||
Example for pyproject.toml
|
||||
**Set development version marker manually:**
|
||||
|
||||
```bash
|
||||
sed -i 's/version = "\(.*\)"/version = "\1+dev"/' pyproject.toml
|
||||
git add pyproject.toml
|
||||
git commit -m "chore: set development version marker"
|
||||
git push origin release/vX.Y.Z_dev
|
||||
make bump VERSION=X.Y.Z NEW_VERSION=X.Y.Z+dev
|
||||
make gen-docs
|
||||
```
|
||||
|
||||
```bash
|
||||
git add pyproject.toml src/akkudoktoreos/core/version.py \
|
||||
src/akkudoktoreos/data/default.config.json Makefile
|
||||
git commit -s -m "chore: set development version marker X.Y.Z+dev"
|
||||
```
|
||||
|
||||
```bash
|
||||
git push --set-upstream origin release/vX.Y.Z_dev
|
||||
```
|
||||
|
||||
### 6️⃣ Maintainer (or Contributor): Open the Development Version PR
|
||||
@@ -147,13 +172,13 @@ git push origin release/vX.Y.Z_dev
|
||||
**PR Title:**
|
||||
|
||||
```text
|
||||
Release vX.Y.Z+dev
|
||||
chore: development version vX.Y.Z+dev
|
||||
```
|
||||
|
||||
**PR Description Template:**
|
||||
|
||||
```markdown
|
||||
## Release vX.Y.Z_dev
|
||||
## Development version vX.Y.Z+dev
|
||||
|
||||
This pull request marks the repository as back in active development.
|
||||
|
||||
@@ -167,12 +192,12 @@ No changelog entry is needed.
|
||||
|
||||
**Checklist:**
|
||||
|
||||
* ✅ Only version files updated to `+dev`
|
||||
* ✅ No unintended changes
|
||||
- ✅ Only version files updated to `+dev`
|
||||
- ✅ No unintended changes
|
||||
|
||||
**Merge Strategy:**
|
||||
|
||||
* Merge with commit message: `Release vX.Y.Z_dev`
|
||||
- Merge with commit message: `chore: development version vX.Y.Z+dev`
|
||||
|
||||
## ✅ Quick Reference
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"info": {
|
||||
"title": "Akkudoktor-EOS",
|
||||
"description": "This project provides a comprehensive solution for simulating and optimizing an energy system based on renewable energy sources. With a focus on photovoltaic (PV) systems, battery storage (batteries), load management (consumer requirements), heat pumps, electric vehicles, and consideration of electricity price data, this system enables forecasting and optimization of energy flow and costs over a specified period.",
|
||||
"version": "v0.1.0+dev"
|
||||
"version": "v0.2.0"
|
||||
},
|
||||
"paths": {
|
||||
"/v1/admin/cache/clear": {
|
||||
@@ -2406,7 +2406,7 @@
|
||||
"general": {
|
||||
"$ref": "#/components/schemas/GeneralSettings-Output",
|
||||
"default": {
|
||||
"version": "0.1.0+dev",
|
||||
"version": "0.2.0",
|
||||
"data_output_subpath": "output",
|
||||
"latitude": 52.52,
|
||||
"longitude": 13.405,
|
||||
@@ -4062,7 +4062,7 @@
|
||||
"type": "string",
|
||||
"title": "Version",
|
||||
"description": "Configuration file version. Used to check compatibility.",
|
||||
"default": "0.1.0+dev"
|
||||
"default": "0.2.0"
|
||||
},
|
||||
"data_folder_path": {
|
||||
"anyOf": [
|
||||
@@ -4136,7 +4136,7 @@
|
||||
"type": "string",
|
||||
"title": "Version",
|
||||
"description": "Configuration file version. Used to check compatibility.",
|
||||
"default": "0.1.0+dev"
|
||||
"default": "0.2.0"
|
||||
},
|
||||
"data_folder_path": {
|
||||
"anyOf": [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "akkudoktor-eos"
|
||||
version = "0.0.1"
|
||||
version = "0.2.0"
|
||||
authors = [
|
||||
{ name="Andreas Schmitz", email="author@example.com" },
|
||||
]
|
||||
@@ -111,7 +111,7 @@ ignore_missing_imports = true
|
||||
[tool.commitizen]
|
||||
name = "cz_conventional_commits"
|
||||
version_scheme = "semver"
|
||||
version = "0.1.0+dev" # <-- Set your current version heretag_format = "v$version"
|
||||
version = "0.2.0" # <-- Set your current version heretag_format = "v$version"
|
||||
|
||||
# Files to automatically update when bumping version
|
||||
update_changelog_on_bump = true
|
||||
@@ -133,5 +133,5 @@ template = "keepachangelog"
|
||||
version = [
|
||||
"pyproject.toml", # Auto-update project version
|
||||
"src/akkudoktoreos/core/version.py",
|
||||
"src/data/default.config.json"
|
||||
"src/akkudoktoreos/data/default.config.json"
|
||||
]
|
||||
|
||||
170
scripts/bump_version.py
Normal file
170
scripts/bump_version.py
Normal file
@@ -0,0 +1,170 @@
|
||||
"""Update version strings in multiple project files only if the old version matches.
|
||||
|
||||
This script updates version information in:
|
||||
- pyproject.toml
|
||||
- src/akkudoktoreos/core/version.py
|
||||
- src/akkudoktoreos/data/default.config.json
|
||||
- Makefile
|
||||
|
||||
Supported version formats:
|
||||
- __version__ = "<version>"
|
||||
- version = "<version>"
|
||||
- "version": "<version>"
|
||||
- VERSION ?: <version>
|
||||
|
||||
It will:
|
||||
- Replace VERSION → NEW_VERSION if the old version is found.
|
||||
- Report which files were updated.
|
||||
- Report which files contained mismatched versions.
|
||||
- Report which files had no version.
|
||||
|
||||
Usage:
|
||||
python bump_version.py VERSION NEW_VERSION
|
||||
|
||||
Args:
|
||||
VERSION (str): Version expected before replacement.
|
||||
NEW_VERSION (str): Version to write.
|
||||
|
||||
"""
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import glob
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from typing import List, Tuple
|
||||
|
||||
# Patterns to match version strings
|
||||
VERSION_PATTERNS = [
|
||||
re.compile(r'(__version__\s*=\s*")(?P<ver>[^"]+)(")'),
|
||||
re.compile(r'(version\s*=\s*")(?P<ver>[^"]+)(")'),
|
||||
re.compile(r'("version"\s*:\s*")(?P<ver>[^"]+)(")'),
|
||||
re.compile(r'(VERSION\s*\?=\s*)(?P<ver>[^\s]+)'), # For Makefile: VERSION ?= 0.2.0
|
||||
]
|
||||
|
||||
# Default files to process
|
||||
DEFAULT_FILES = [
|
||||
"pyproject.toml",
|
||||
"src/akkudoktoreos/core/version.py",
|
||||
"src/akkudoktoreos/data/default.config.json",
|
||||
"Makefile",
|
||||
]
|
||||
|
||||
|
||||
def backup_file(file_path: str) -> str:
|
||||
"""Create a backup of the given file with a .bak suffix.
|
||||
|
||||
Args:
|
||||
file_path: Path to the file to backup.
|
||||
|
||||
Returns:
|
||||
Path to the backup file.
|
||||
"""
|
||||
backup_path = f"{file_path}.bak"
|
||||
shutil.copy2(file_path, backup_path)
|
||||
return backup_path
|
||||
|
||||
|
||||
def replace_version_in_file(
|
||||
file_path: Path, old_version: str, new_version: str, dry_run: bool = False
|
||||
) -> Tuple[bool, bool]:
|
||||
"""
|
||||
Replace old_version with new_version in the given file if it matches.
|
||||
|
||||
Args:
|
||||
file_path: Path to the file to modify.
|
||||
old_version: The old version to replace.
|
||||
new_version: The new version to set.
|
||||
dry_run: If True, don't actually modify files.
|
||||
|
||||
Returns:
|
||||
Tuple[bool, bool]: (file_would_be_updated, old_version_found)
|
||||
"""
|
||||
content = file_path.read_text()
|
||||
new_content = content
|
||||
old_version_found = False
|
||||
file_would_be_updated = False
|
||||
|
||||
for pattern in VERSION_PATTERNS:
|
||||
def repl(match):
|
||||
nonlocal old_version_found, file_would_be_updated
|
||||
ver = match.group("ver")
|
||||
if ver == old_version:
|
||||
old_version_found = True
|
||||
file_would_be_updated = True
|
||||
# Some patterns have 3 groups (like quotes)
|
||||
if len(match.groups()) == 3:
|
||||
return f"{match.group(1)}{new_version}{match.group(3)}"
|
||||
else:
|
||||
return f"{match.group(1)}{new_version}"
|
||||
return match.group(0)
|
||||
|
||||
new_content = pattern.sub(repl, new_content)
|
||||
|
||||
if file_would_be_updated:
|
||||
if dry_run:
|
||||
print(f"[DRY-RUN] Would update {file_path}")
|
||||
else:
|
||||
backup_path = file_path.with_suffix(file_path.suffix + ".bak")
|
||||
shutil.copy(file_path, backup_path)
|
||||
file_path.write_text(new_content)
|
||||
print(f"Updated {file_path} (backup saved to {backup_path})")
|
||||
elif not old_version_found:
|
||||
print(f"[SKIP] {file_path}: old version '{old_version}' not found")
|
||||
|
||||
return file_would_be_updated, old_version_found
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Bump version across project files.")
|
||||
parser.add_argument("old_version", help="Old version to replace")
|
||||
parser.add_argument("new_version", help="New version to set")
|
||||
parser.add_argument(
|
||||
"--dry-run", action="store_true", help="Show what would be changed without modifying files"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--glob", nargs="*", help="Optional glob patterns to include additional files"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
updated_files = []
|
||||
not_found_files = []
|
||||
|
||||
# Determine files to update
|
||||
files_to_update: List[Path] = [Path(f) for f in DEFAULT_FILES]
|
||||
if args.glob:
|
||||
for pattern in args.glob:
|
||||
files_to_update.extend(Path(".").glob(pattern))
|
||||
|
||||
files_to_update = list(dict.fromkeys(files_to_update)) # remove duplicates
|
||||
|
||||
any_updated = False
|
||||
for file_path in files_to_update:
|
||||
if file_path.exists() and file_path.is_file():
|
||||
updated, _ = replace_version_in_file(
|
||||
file_path, args.old_version, args.new_version, args.dry_run
|
||||
)
|
||||
any_updated |= updated
|
||||
if updated:
|
||||
updated_files.append(file_path)
|
||||
else:
|
||||
print(f"[SKIP] {file_path}: file does not exist")
|
||||
not_found_files.append(file_path)
|
||||
|
||||
print("\nSummary:")
|
||||
if updated_files:
|
||||
print(f"Updated files ({len(updated_files)}):")
|
||||
for f in updated_files:
|
||||
print(f" {f}")
|
||||
else:
|
||||
print("No files were updated.")
|
||||
|
||||
if not_found_files:
|
||||
print(f"Files where old version was not found ({len(not_found_files)}):")
|
||||
for f in not_found_files:
|
||||
print(f" {f}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -21,7 +21,7 @@ if TYPE_CHECKING:
|
||||
# - tuple[str, Callable[[Any], Any]] (new path + transform)
|
||||
# - None (drop)
|
||||
MIGRATION_MAP: Dict[str, Union[str, Tuple[str, Callable[[Any], Any]], None]] = {
|
||||
# 0.1.0 -> now
|
||||
# 0.1.0 -> 0.2.0
|
||||
"devices/batteries/0/initial_soc_percentage": None,
|
||||
"devices/electric_vehicles/0/initial_soc_percentage": None,
|
||||
"elecprice/provider_settings/import_file_path": "elecprice/provider_settings/ElecPriceImport/import_file_path",
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
# For development add `+dev` to previous release
|
||||
# For release omit `+dev`.
|
||||
__version__ = "0.1.0+dev"
|
||||
__version__ = "0.2.0"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"general": {
|
||||
"version": "0.1.0+dev"
|
||||
"version": "0.2.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user