#!/bin/bash

set -x
INPUT_FILE="changelog"
OUTPUT_FILE="CHANGELOG.md"

echo "# Changelog" > "$OUTPUT_FILE"
echo -e "\n## [Unreleased]\n" >> "$OUTPUT_FILE"

# Procesar el changelog de Debian
awk '
/^ogcore/ {
    version = $2
    gsub(/[()]/, "", version)  # Eliminar paréntesis de la versión
    printf "\n## [%s] - %s\n\n", version, $NF
}
/^\s*\*/ {
    gsub(/^\s*\*\s*/, "- ", $0)  # Convertir a lista de viñetas
    print $0 >> "'"$OUTPUT_FILE"'"
}
' "$INPUT_FILE"
