From 71431081e38ced73b7c13c704ce3a290be7d5ea9 Mon Sep 17 00:00:00 2001 From: Jelte Fennema Date: Wed, 6 May 2020 12:45:10 +0200 Subject: [PATCH 1/3] Support pgautofailover in update_os_package.pl --- automated_packaging/update_os_package.pl | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/automated_packaging/update_os_package.pl b/automated_packaging/update_os_package.pl index c3c0a091..33ab5606 100644 --- a/automated_packaging/update_os_package.pl +++ b/automated_packaging/update_os_package.pl @@ -13,6 +13,17 @@ $github_repo_name = "citus-enterprise"; $log_repo_name = "Citus Enterprise"; } +my $package_name = $github_repo_name; +if ( $PROJECT eq "pgautofailover" ) { + $github_repo_name = "pg_auto_failover"; + $package_name = "pg-auto-failover"; + $log_repo_name = "pg_auto_failover"; +} +if ( $PROJECT eq "pgautofailover-enterprise" ) { + $github_repo_name = "citus-ha"; + $package_name = "pg-auto-failover-enterprise"; + $log_repo_name = "pg_auto_failover enterprise"; +} my $github_token = get_and_verify_token(); @@ -70,9 +81,9 @@ sub get_changelog_for_debian { # Based on the repo, update the package related variables if ( $DISTRO_VERSION eq "redhat" || $DISTRO_VERSION eq "microsoft" || $DISTRO_VERSION eq "all") { - `sed -i 's|^Version:.*|Version: $VERSION.citus|g' $github_repo_name.spec`; - `sed -i 's|^Source0:.*|Source0: https:\/\/github.com\/citusdata\/$github_repo_name\/archive\/v$VERSION.tar.gz|g' $github_repo_name.spec`; - `sed -i 's|^%changelog|%changelog\\n* $abbr_day[$wday] $abbr_mon[$mon] $mday $year - $git_name <$microsoft_email> $VERSION.citus-1\\n- Update to $log_repo_name $VERSION\\n|g' $github_repo_name.spec`; + `sed -i 's|^Version:.*|Version: $VERSION.citus|g' $package_name.spec`; + `sed -i 's|^Source0:.*|Source0: https:\/\/github.com\/citusdata\/$package_name\/archive\/v$VERSION.tar.gz|g' $package_name.spec`; + `sed -i 's|^%changelog|%changelog\\n* $abbr_day[$wday] $abbr_mon[$mon] $mday $year - $git_name <$microsoft_email> $VERSION.citus-1\\n- Update to $log_repo_name $VERSION\\n|g' $package_name.spec`; } if ( $DISTRO_VERSION eq "debian" || $DISTRO_VERSION eq "microsoft" || $DISTRO_VERSION eq "all") { open( DEB_CLOG_FILE, "<./debian/changelog" ) || die "Debian changelog file not found"; @@ -85,7 +96,7 @@ sub get_changelog_for_debian { # Update the changelog file of the debian branch open( DEB_CLOG_FILE, ">./debian/changelog" ) || die "Debian changelog file not found"; - print DEB_CLOG_FILE "$github_repo_name ($VERSION.citus-1) stable; urgency=low\n"; + print DEB_CLOG_FILE "$package_name ($VERSION.citus-1) stable; urgency=low\n"; print DEB_CLOG_FILE @changelog_print; print DEB_CLOG_FILE " -- $git_name <$microsoft_email> $abbr_day[$wday], $mday $abbr_mon[$mon] $year $print_hour:$min:$sec +0000\n\n"; print DEB_CLOG_FILE @lines; From fcd0e22e186ab82b9be6fab9efa869a79c8a9c79 Mon Sep 17 00:00:00 2001 From: Jelte Fennema Date: Thu, 7 May 2020 13:21:18 +0200 Subject: [PATCH 2/3] Do not put the whole changelog into the package for pgautofailover --- automated_packaging/update_os_package.pl | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/automated_packaging/update_os_package.pl b/automated_packaging/update_os_package.pl index 33ab5606..615c7928 100644 --- a/automated_packaging/update_os_package.pl +++ b/automated_packaging/update_os_package.pl @@ -83,7 +83,7 @@ sub get_changelog_for_debian { if ( $DISTRO_VERSION eq "redhat" || $DISTRO_VERSION eq "microsoft" || $DISTRO_VERSION eq "all") { `sed -i 's|^Version:.*|Version: $VERSION.citus|g' $package_name.spec`; `sed -i 's|^Source0:.*|Source0: https:\/\/github.com\/citusdata\/$package_name\/archive\/v$VERSION.tar.gz|g' $package_name.spec`; - `sed -i 's|^%changelog|%changelog\\n* $abbr_day[$wday] $abbr_mon[$mon] $mday $year - $git_name <$microsoft_email> $VERSION.citus-1\\n- Update to $log_repo_name $VERSION\\n|g' $package_name.spec`; + `sed -i 's|^%changelog|%changelog\\n* $abbr_day[$wday] $abbr_mon[$mon] $mday $year - $git_name <$microsoft_email> $VERSION.citus-1\\n- Official $VERSION release of $log_repo_name\\n|g' $package_name.spec`; } if ( $DISTRO_VERSION eq "debian" || $DISTRO_VERSION eq "microsoft" || $DISTRO_VERSION eq "all") { open( DEB_CLOG_FILE, "<./debian/changelog" ) || die "Debian changelog file not found"; @@ -92,12 +92,21 @@ sub get_changelog_for_debian { # Change hour and get changelog (TODO: may update it !) $print_hour = $hour - 3; - @changelog_print = get_changelog_for_debian(); + if ($PROJECT eq 'citus' || $PROJECT eq 'enterprise') { + @changelog_print = get_changelog_for_debian(); + } + # Update the changelog file of the debian branch open( DEB_CLOG_FILE, ">./debian/changelog" ) || die "Debian changelog file not found"; print DEB_CLOG_FILE "$package_name ($VERSION.citus-1) stable; urgency=low\n"; - print DEB_CLOG_FILE @changelog_print; + if ($PROJECT eq 'citus' || $PROJECT eq 'enterprise') { + print DEB_CLOG_FILE @changelog_print; + } + else + { + print DEB_CLOG_FILE "\n * Official $VERSION release of $log_repo_name\n\n"; + } print DEB_CLOG_FILE " -- $git_name <$microsoft_email> $abbr_day[$wday], $mday $abbr_mon[$mon] $year $print_hour:$min:$sec +0000\n\n"; print DEB_CLOG_FILE @lines; close(DEB_CLOG_FILE); From 95132b63efd47264bf7917b583b69c4ed706db9d Mon Sep 17 00:00:00 2001 From: Jelte Fennema Date: Thu, 7 May 2020 15:16:09 +0200 Subject: [PATCH 3/3] Some improvements of update_os_package.pl * Handles $DISTRO_VERSION "all" better * Branch name includes $VERSION --- automated_packaging/update_os_package.pl | 31 ++++++++++++++++-------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/automated_packaging/update_os_package.pl b/automated_packaging/update_os_package.pl index 615c7928..860cb75d 100644 --- a/automated_packaging/update_os_package.pl +++ b/automated_packaging/update_os_package.pl @@ -9,6 +9,7 @@ # Name of the repo is represented differently on logs and repos my $github_repo_name = "citus"; my $log_repo_name = "Citus"; +my $version_suffix = ".citus"; if ( $PROJECT eq "enterprise" ) { $github_repo_name = "citus-enterprise"; $log_repo_name = "Citus Enterprise"; @@ -18,11 +19,13 @@ $github_repo_name = "pg_auto_failover"; $package_name = "pg-auto-failover"; $log_repo_name = "pg_auto_failover"; + $version_suffix = ""; } if ( $PROJECT eq "pgautofailover-enterprise" ) { $github_repo_name = "citus-ha"; $package_name = "pg-auto-failover-enterprise"; $log_repo_name = "pg_auto_failover enterprise"; + $version_suffix = ""; } my $github_token = get_and_verify_token(); @@ -67,23 +70,25 @@ sub get_changelog_for_debian { # Necessary to create unique branch $curTime = time(); +my $main_branch = "$DISTRO_VERSION-$PROJECT"; +my $pr_branch = "$DISTRO_VERSION-$PROJECT-$VERSION-push-$curTime"; # Checkout the distro's branch -`git checkout $DISTRO_VERSION-$PROJECT`; +`git checkout $main_branch`; # Update distro's branch -`git pull origin $DISTRO_VERSION-$PROJECT`; +`git pull origin $main_branch`; # Create a new branch based on the distro's branch -`git checkout -b $DISTRO_VERSION-$PROJECT-push-$curTime`; +`git checkout -b $pr_branch`; # Update pkgvars -`sed -i 's/^pkglatest.*/pkglatest=$VERSION.citus-1/g' pkgvars`; +`sed -i 's/^pkglatest.*/pkglatest=$VERSION$version_suffix-1/g' pkgvars`; # Based on the repo, update the package related variables if ( $DISTRO_VERSION eq "redhat" || $DISTRO_VERSION eq "microsoft" || $DISTRO_VERSION eq "all") { - `sed -i 's|^Version:.*|Version: $VERSION.citus|g' $package_name.spec`; + `sed -i 's|^Version:.*|Version: $VERSION$version_suffix|g' $package_name.spec`; `sed -i 's|^Source0:.*|Source0: https:\/\/github.com\/citusdata\/$package_name\/archive\/v$VERSION.tar.gz|g' $package_name.spec`; - `sed -i 's|^%changelog|%changelog\\n* $abbr_day[$wday] $abbr_mon[$mon] $mday $year - $git_name <$microsoft_email> $VERSION.citus-1\\n- Official $VERSION release of $log_repo_name\\n|g' $package_name.spec`; + `sed -i 's|^%changelog|%changelog\\n* $abbr_day[$wday] $abbr_mon[$mon] $mday $year - $git_name <$microsoft_email> $VERSION$version_suffix-1\\n- Official $VERSION release of $log_repo_name\\n|g' $package_name.spec`; } if ( $DISTRO_VERSION eq "debian" || $DISTRO_VERSION eq "microsoft" || $DISTRO_VERSION eq "all") { open( DEB_CLOG_FILE, "<./debian/changelog" ) || die "Debian changelog file not found"; @@ -99,7 +104,7 @@ sub get_changelog_for_debian { # Update the changelog file of the debian branch open( DEB_CLOG_FILE, ">./debian/changelog" ) || die "Debian changelog file not found"; - print DEB_CLOG_FILE "$package_name ($VERSION.citus-1) stable; urgency=low\n"; + print DEB_CLOG_FILE "$package_name ($VERSION$version_suffix-1) stable; urgency=low\n"; if ($PROJECT eq 'citus' || $PROJECT eq 'enterprise') { print DEB_CLOG_FILE @changelog_print; } @@ -112,7 +117,13 @@ sub get_changelog_for_debian { close(DEB_CLOG_FILE); } + +my $commit_message_distro_version = "$DISTRO_VERSION "; +if ($DISTRO_VERSION eq "all") { + $commit_message_distro_version = ""; +} # Commit, push changes and open a pull request -`git commit -a -m "Bump $DISTRO_VERSION $log_repo_name $VERSION"`; -`git push origin $DISTRO_VERSION-$PROJECT-push-$curTime`; -`curl -g -H "Accept: application/vnd.github.v3.full+json" -X POST --user "$github_token:x-oauth-basic" -d '{\"title\":\"Bump $PROJECT $DISTRO_VERSION version to $VERSION\", \"head\":\"$DISTRO_VERSION-$PROJECT-push-$curTime\", \"base\":\"$DISTRO_VERSION-$PROJECT\"}' https://api.github.com/repos/citusdata/packaging/pulls`; +my $commit_message = "Bump $commit_message_distro_version$log_repo_name version to $VERSION"; +`git commit -a -m "$commit_message"`; +`git push origin $pr_branch`; +`curl -g -H "Accept: application/vnd.github.v3.full+json" -X POST --user "$github_token:x-oauth-basic" -d '{\"title\":\"$commit_message\", \"head\":\"$pr_branch\", \"base\":\"$main_branch\"}' https://api.github.com/repos/citusdata/packaging/pulls`;