Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 44 additions & 13 deletions automated_packaging/update_os_package.pl
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,24 @@
# 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";
Comment thread
hanefi marked this conversation as resolved.
if ( $PROJECT eq "enterprise" ) {
$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";
$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();

Expand Down Expand Up @@ -56,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' $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$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$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";
Expand All @@ -81,18 +97,33 @@ 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 "$github_repo_name ($VERSION.citus-1) stable; urgency=low\n";
print DEB_CLOG_FILE @changelog_print;
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;
}
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);
}


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`;