From 3dadf23968ec58b22d1ff7b632f23732409bdfa7 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Wed, 24 Nov 2021 13:25:05 -0500 Subject: [PATCH 1/4] Use dch instead of hack to generate changelog --- .github/actions_scripts/getChangelog.pl | 30 +++++++++++++++------- distributions/build-debian-package-auto.sh | 27 +++++++------------ 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/.github/actions_scripts/getChangelog.pl b/.github/actions_scripts/getChangelog.pl index 99fea2a8b1..b57c1cad4d 100755 --- a/.github/actions_scripts/getChangelog.pl +++ b/.github/actions_scripts/getChangelog.pl @@ -5,15 +5,27 @@ # get the file path my $ChangeLogFile = $ARGV[0]; # get the version -my $Version = quotemeta $ARGV[1]; -# open the file (slurp mode): https://perlmaven.com/slurp +my $Version = $ARGV[1]; +# open the file open my $fh, '<', $ChangeLogFile or die; -$/ = undef; -my $ChangeLog = <$fh>; -close $fh; -if ( $ChangeLog =~ m/^### $Version (.*?)$(.*?)^###/sm ) { - print $2; -} else { - print "No changelog found for this version."; +my $logversion = ""; +my $entry; +while (my $line = <$fh>) { + if ($line =~ /^### (\S+)[^#]*###$/m) { + # The version for this section of the ChangeLog + $logversion = $1; + next; + } + if ($logversion eq $Version) { + if ($line =~ /^- (.*)$/) { # beginning of entry + $entry = $1; + } elsif ($line =~ /^ ( \S.*)$/) { # continuation of entry + $entry .= $1; + } else { # otherwise, separator between entries + print "${entry}\n" if $entry; + $entry = undef; + } + } } +close $fh; diff --git a/distributions/build-debian-package-auto.sh b/distributions/build-debian-package-auto.sh index 30ef539b42..dd15854355 100755 --- a/distributions/build-debian-package-auto.sh +++ b/distributions/build-debian-package-auto.sh @@ -2,30 +2,21 @@ # Create deb files -# set armhf -#sudo dpkg --add-architecture armhf - cp -r debian .. cd .. # get the jamulus version from pro file VERSION=$(cat Jamulus.pro | grep -oP 'VERSION = \K\w[^\s\\]*') -# patch changelog (with hack) - -DATE=$(date "+%a, %d %b %Y %T" ) -echo "jamulus (${VERSION}-0) UNRELEASED; urgency=medium" > debian/changelog -echo "" >> debian/changelog -perl .github/actions_scripts/getChangelog.pl ChangeLog ${VERSION} >> debian/changelog -echo "" >> debian/changelog -echo " -- GitHubActions ${DATE} +0001" >> debian/changelog -echo "" >> debian/changelog -cat distributions/debian/changelog >> debian/changelog - -# patch the control file -# cp the modified control file here - -cp distributions/autobuilddeb/control debian/control +# Generate Changelog +echo -n generating changelog +dch --newversion "${VERSION}" '' +perl .github/actions_scripts/getChangelog.pl ChangeLog "${VERSION}" | while read entry +do + echo -n . + dch "$entry" +done +echo echo "${VERSION} building..." From 15d29445dd28d870dbf4df02adc33b69d363dcae Mon Sep 17 00:00:00 2001 From: Tony Mountifield Date: Mon, 29 Nov 2021 14:48:03 -0500 Subject: [PATCH 2/4] Set dch maintainer name to GitHubActions --- distributions/build-debian-package-auto.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/distributions/build-debian-package-auto.sh b/distributions/build-debian-package-auto.sh index dd15854355..9be693d16a 100755 --- a/distributions/build-debian-package-auto.sh +++ b/distributions/build-debian-package-auto.sh @@ -8,9 +8,12 @@ cd .. # get the jamulus version from pro file VERSION=$(cat Jamulus.pro | grep -oP 'VERSION = \K\w[^\s\\]*') +export DEBFULLNAME=GitHubActions DEBEMAIL=noemail@example.com + # Generate Changelog echo -n generating changelog -dch --newversion "${VERSION}" '' +rm -f debian/changelog +dch --create --package jamulus --empty --newversion "${VERSION}" '' perl .github/actions_scripts/getChangelog.pl ChangeLog "${VERSION}" | while read entry do echo -n . From b7432993235be920e5e312ea1db26f3c02876e6b Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Mon, 29 Nov 2021 15:00:46 -0500 Subject: [PATCH 3/4] Only remove dashes from ChangeLog when given specific option --- .github/actions_scripts/getChangelog.pl | 26 +++++++++++++--------- distributions/build-debian-package-auto.sh | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/actions_scripts/getChangelog.pl b/.github/actions_scripts/getChangelog.pl index b57c1cad4d..e15769507e 100755 --- a/.github/actions_scripts/getChangelog.pl +++ b/.github/actions_scripts/getChangelog.pl @@ -2,13 +2,13 @@ use strict; use warnings; -# get the file path -my $ChangeLogFile = $ARGV[0]; -# get the version -my $Version = $ARGV[1]; +# get arguments +my ($ChangeLogFile, $Version, $FormatOption) = @ARGV; # open the file open my $fh, '<', $ChangeLogFile or die; +my $SingleLineEntries = ($FormatOption or '') eq '--line-per-entry'; + my $logversion = ""; my $entry; while (my $line = <$fh>) { @@ -18,13 +18,17 @@ next; } if ($logversion eq $Version) { - if ($line =~ /^- (.*)$/) { # beginning of entry - $entry = $1; - } elsif ($line =~ /^ ( \S.*)$/) { # continuation of entry - $entry .= $1; - } else { # otherwise, separator between entries - print "${entry}\n" if $entry; - $entry = undef; + if ($SingleLineEntries) { + if ($line =~ /^- (.*)$/) { # beginning of entry + $entry = $1; + } elsif ($line =~ /^ ( \S.*)$/) { # continuation of entry + $entry .= $1; + } else { # otherwise, separator between entries + print "${entry}\n" if $entry; + $entry = undef; + } + } else { + print $line; } } } diff --git a/distributions/build-debian-package-auto.sh b/distributions/build-debian-package-auto.sh index 9be693d16a..16e6a6b3c3 100755 --- a/distributions/build-debian-package-auto.sh +++ b/distributions/build-debian-package-auto.sh @@ -14,7 +14,7 @@ export DEBFULLNAME=GitHubActions DEBEMAIL=noemail@example.com echo -n generating changelog rm -f debian/changelog dch --create --package jamulus --empty --newversion "${VERSION}" '' -perl .github/actions_scripts/getChangelog.pl ChangeLog "${VERSION}" | while read entry +perl .github/actions_scripts/getChangelog.pl ChangeLog "${VERSION}" --line-per-entry | while read entry do echo -n . dch "$entry" From f8faafb46f8454a87c928dbacc122514023a8f18 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 8 Jan 2022 12:12:49 -0500 Subject: [PATCH 4/4] Print error if we fail to find specified version's ChangeLog section Also exit early once we're done processing the version relevant lines. --- .github/actions_scripts/getChangelog.pl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/actions_scripts/getChangelog.pl b/.github/actions_scripts/getChangelog.pl index e15769507e..a866d48e2d 100755 --- a/.github/actions_scripts/getChangelog.pl +++ b/.github/actions_scripts/getChangelog.pl @@ -11,13 +11,20 @@ my $logversion = ""; my $entry; +my $matchedLogversion = 0; while (my $line = <$fh>) { if ($line =~ /^### (\S+)[^#]*###$/m) { # The version for this section of the ChangeLog + if ($matchedLogversion) { + # We've processed the lines corresponding to $Version, and + # we're now on the next section. There's no more to do. + last; + } $logversion = $1; next; } if ($logversion eq $Version) { + $matchedLogversion = 1; if ($SingleLineEntries) { if ($line =~ /^- (.*)$/) { # beginning of entry $entry = $1; @@ -32,4 +39,9 @@ } } } + close $fh; + +if (!$matchedLogversion) { + die "Failed to find entry for version '${Version}'"; +}