feat: modularize scripts and improve project architecture
All checks were successful
Auto Changelog & Release / release (push) Successful in 8s

- Added `lib/utils.sh` and `lib/logging.sh` for reusable utility and logging functions.
- Updated `run.sh` and `scripts/generate-changelog.sh` to use the new utility and logging functions (`validate_arg`, `log_info`, `log_error`).
- Add `config.env` for better clarity and updated all references in the project.
- Enhanced documentation in `README.md` to reflect the new configuration file and usage instructions.
- Improved error handling and logging consistency across scripts.
This commit is contained in:
2025-07-02 12:59:16 +02:00
parent a59359545d
commit ba7b9f2928
5 changed files with 116 additions and 31 deletions

View File

@@ -42,22 +42,24 @@ done
# 2 Basic validation
[[ -z "$CONFIG_FILE" || -z "$TAG" ]] && { echo "❌ --config and --tag are required"; show_help; exit 1; }
[[ "$DEBUG" = false && -z "$OUT_FILE" ]] && { echo "❌ --out is required unless --debug is set"; show_help; exit 1; }
[[ ! -r "$CONFIG_FILE" ]] && { echo "Config file not found or unreadable: $CONFIG_FILE"; exit 1; }
[[ ! -r "$CONFIG_FILE" ]] && { log_error "Config file not found or unreadable: $CONFIG_FILE"; exit 1; }
if [[ "$DEBUG" = false ]]; then
OUT_DIR=$(dirname "$OUT_FILE")
[[ ! -d "$OUT_DIR" ]] && { echo "Output directory does not exist: $OUT_DIR"; exit 1; }
[[ ! -d "$OUT_DIR" ]] && { log_error "Output directory does not exist: $OUT_DIR"; exit 1; }
fi
# 3 Required tools
need() { command -v "$1" >/dev/null || { echo "$1 is required but not installed"; exit 1; }; }
source "$(dirname "$0")/../lib/utils.sh"
source "$(dirname "$0")/../lib/logging.sh"
need git; need git-cliff; need sed
# 4 Generate changelog
if $DEBUG; then
echo "📝 Generating changelog (debug mode – stdout only)"
log_info "Generating changelog (debug mode – stdout only)"
git cliff --config "$CONFIG_FILE" -t "$TAG" -s all
else
echo "📝 Generating changelog → $OUT_FILE"
log_info "Generating changelog → $OUT_FILE"
git cliff --config "$CONFIG_FILE" -t "$TAG" -s all > "$OUT_FILE"
echo "Changelog written to $OUT_FILE"
log_info "Changelog written to $OUT_FILE"
fi