diff --git a/.github/actions_scripts/getChangelog.pl b/.github/actions_scripts/getChangelog.pl index 99fea2a8b1..a866d48e2d 100755 --- a/.github/actions_scripts/getChangelog.pl +++ b/.github/actions_scripts/getChangelog.pl @@ -2,18 +2,46 @@ use strict; use warnings; -# 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 +# get arguments +my ($ChangeLogFile, $Version, $FormatOption) = @ARGV; +# open the file open my $fh, '<', $ChangeLogFile or die; -$/ = undef; -my $ChangeLog = <$fh>; + +my $SingleLineEntries = ($FormatOption or '') eq '--line-per-entry'; + +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; + } elsif ($line =~ /^ ( \S.*)$/) { # continuation of entry + $entry .= $1; + } else { # otherwise, separator between entries + print "${entry}\n" if $entry; + $entry = undef; + } + } else { + print $line; + } + } +} + close $fh; -if ( $ChangeLog =~ m/^### $Version (.*?)$(.*?)^###/sm ) { - print $2; -} else { - print "No changelog found for this version."; +if (!$matchedLogversion) { + die "Failed to find entry for version '${Version}'"; } diff --git a/distributions/build-debian-package-auto.sh b/distributions/build-debian-package-auto.sh index 30ef539b42..16e6a6b3c3 100755 --- a/distributions/build-debian-package-auto.sh +++ b/distributions/build-debian-package-auto.sh @@ -2,30 +2,24 @@ # 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 +export DEBFULLNAME=GitHubActions DEBEMAIL=noemail@example.com + +# Generate Changelog +echo -n generating changelog +rm -f debian/changelog +dch --create --package jamulus --empty --newversion "${VERSION}" '' +perl .github/actions_scripts/getChangelog.pl ChangeLog "${VERSION}" --line-per-entry | while read entry +do + echo -n . + dch "$entry" +done +echo echo "${VERSION} building..."