Merge pull request 'Implement incremental changelog generation for Debian packages' (#25) from feature/incremental-changelog into main
Reviewed-on: #25
This commit is contained in:
commit
a5faddf900
1 changed files with 94 additions and 33 deletions
|
|
@ -69,43 +69,104 @@ echo_info " beast-dump: $(file "$DEB_DIR/usr/bin/beast-dump")"
|
||||||
chmod +x "$DEB_DIR/usr/bin/skyview"
|
chmod +x "$DEB_DIR/usr/bin/skyview"
|
||||||
chmod +x "$DEB_DIR/usr/bin/beast-dump"
|
chmod +x "$DEB_DIR/usr/bin/beast-dump"
|
||||||
|
|
||||||
# Generate changelog from git history
|
# Generate incremental changelog from git history
|
||||||
echo_info "Generating changelog from git history..."
|
echo_info "Generating incremental changelog from git history..."
|
||||||
CHANGELOG_DIR="$DEB_DIR/usr/share/doc/skyview-adsb"
|
CHANGELOG_DIR="$DEB_DIR/usr/share/doc/skyview-adsb"
|
||||||
mkdir -p "$CHANGELOG_DIR"
|
mkdir -p "$CHANGELOG_DIR"
|
||||||
|
|
||||||
# Get the current version and previous version
|
# Function to generate incremental changelog
|
||||||
CURRENT_VERSION=$(git describe --tags --always)
|
generate_incremental_changelog() {
|
||||||
PREV_VERSION=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
|
local changelog_file="$1"
|
||||||
|
|
||||||
|
# Get all tags in reverse chronological order
|
||||||
|
local tags
|
||||||
|
tags=$(git tag -l --sort=-version:refname)
|
||||||
|
|
||||||
|
# If no tags exist, create a single entry for current state
|
||||||
|
if [ -z "$tags" ]; then
|
||||||
|
local current_version
|
||||||
|
current_version=$(git describe --tags --always)
|
||||||
|
echo_info "No tags found, generating initial changelog for $current_version"
|
||||||
|
{
|
||||||
|
echo "skyview-adsb ($current_version) unstable; urgency=medium"
|
||||||
|
echo ""
|
||||||
|
echo " * Initial release"
|
||||||
|
echo " * Multi-source ADS-B aircraft tracker with Beast format support"
|
||||||
|
echo ""
|
||||||
|
echo " -- $(git config user.name) <$(git config user.email)> $(date -R)"
|
||||||
|
echo ""
|
||||||
|
} > "$changelog_file"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create empty changelog
|
||||||
|
: > "$changelog_file"
|
||||||
|
|
||||||
|
# Add entry for current development version if there are commits after the last tag
|
||||||
|
local latest_tag
|
||||||
|
latest_tag=$(echo "$tags" | head -n1)
|
||||||
|
local commits_since_tag
|
||||||
|
commits_since_tag=$(git rev-list "$latest_tag"..HEAD --count 2>/dev/null || echo 0)
|
||||||
|
|
||||||
|
if [ "$commits_since_tag" -gt 0 ]; then
|
||||||
|
local current_version
|
||||||
|
current_version=$(git describe --tags --always)
|
||||||
|
echo_info "Adding entry for current development version: $current_version"
|
||||||
|
{
|
||||||
|
echo "skyview-adsb ($current_version) unstable; urgency=medium"
|
||||||
|
echo ""
|
||||||
|
git log --pretty=format:" * %s" "$latest_tag"..HEAD | head -20
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo " -- $(git config user.name) <$(git config user.email)> $(date -R)"
|
||||||
|
echo ""
|
||||||
|
} >> "$changelog_file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Process all tags to create incremental changelog
|
||||||
|
local prev_tag=""
|
||||||
|
for tag in $tags; do
|
||||||
|
echo_info "Processing version $tag"
|
||||||
|
|
||||||
|
# Get tag date and author info
|
||||||
|
local tag_date
|
||||||
|
tag_date=$(git log -1 --format=%aD "$tag")
|
||||||
|
local tag_author
|
||||||
|
tag_author=$(git log -1 --format='%an <%ae>' "$tag")
|
||||||
|
|
||||||
|
# Add version header
|
||||||
|
{
|
||||||
|
echo "skyview-adsb ($tag) unstable; urgency=medium"
|
||||||
|
echo ""
|
||||||
|
} >> "$changelog_file"
|
||||||
|
|
||||||
|
# Add changes for this version
|
||||||
|
if [ -n "$prev_tag" ]; then
|
||||||
|
# Show changes between this tag and the previous one
|
||||||
|
git log --pretty=format:" * %s" "$tag..$prev_tag" | head -20 >> "$changelog_file"
|
||||||
|
else
|
||||||
|
# For the oldest tag, show changes from the beginning
|
||||||
|
git log --pretty=format:" * %s" "$tag" | head -20 >> "$changelog_file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add footer
|
||||||
|
{
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo " -- $tag_author $tag_date"
|
||||||
|
echo ""
|
||||||
|
} >> "$changelog_file"
|
||||||
|
|
||||||
|
prev_tag="$tag"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
if [ -n "$PREV_VERSION" ]; then
|
# Generate the incremental changelog
|
||||||
echo_info "Generating changelog from $PREV_VERSION to $CURRENT_VERSION"
|
generate_incremental_changelog "$CHANGELOG_DIR/changelog"
|
||||||
# Create changelog with proper Debian format
|
echo_info "Generated incremental changelog with $(grep -c '^skyview-adsb (' "$CHANGELOG_DIR/changelog") version entries"
|
||||||
{
|
|
||||||
echo "skyview-adsb ($CURRENT_VERSION) unstable; urgency=medium"
|
|
||||||
echo ""
|
|
||||||
echo " Changes since $PREV_VERSION:"
|
|
||||||
git log --pretty=format:" * %s" "$PREV_VERSION..HEAD" | head -20
|
|
||||||
echo ""
|
|
||||||
echo " -- $(git config user.name) <$(git config user.email)> $(date -R)"
|
|
||||||
echo ""
|
|
||||||
} > "$CHANGELOG_DIR/changelog"
|
|
||||||
else
|
|
||||||
echo_info "No previous version found, generating initial changelog"
|
|
||||||
# Create initial changelog
|
|
||||||
{
|
|
||||||
echo "skyview-adsb ($CURRENT_VERSION) unstable; urgency=medium"
|
|
||||||
echo ""
|
|
||||||
echo " * Initial release"
|
|
||||||
echo " * Multi-source ADS-B aircraft tracker with Beast format support"
|
|
||||||
echo ""
|
|
||||||
echo " -- $(git config user.name) <$(git config user.email)> $(date -R)"
|
|
||||||
echo ""
|
|
||||||
} > "$CHANGELOG_DIR/changelog"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Compress changelog as per Debian standards
|
# Compress changelog as per Debian standards (force overwrite if exists)
|
||||||
gzip -9 "$CHANGELOG_DIR/changelog"
|
gzip -9f "$CHANGELOG_DIR/changelog"
|
||||||
echo_info "Generated changelog: $CHANGELOG_DIR/changelog.gz"
|
echo_info "Generated changelog: $CHANGELOG_DIR/changelog.gz"
|
||||||
|
|
||||||
# Get package info
|
# Get package info
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue