diff --git a/Makefile b/Makefile index d5fbf497..bba21aaa 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ export mandir := $(datarootdir)/man export sysconfdir := $(prefix)/etc export pkgsysconfdir := $(sysconfdir)/$(PACKAGE_NAME) -DIRNAMES = automated_packaging packaging uncrustify valgrind +DIRNAMES = packaging uncrustify valgrind ifeq ($(TRAVIS), true) DIRNAMES += travis endif diff --git a/automated_packaging/Makefile b/automated_packaging/Makefile deleted file mode 100644 index 1b9e2aad..00000000 --- a/automated_packaging/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# needed variables will be passed in via top-level Makefile - -INSTALL := install -c -INSTALL_SCRIPT := $(INSTALL) -m 755 -AUTOMATION_SCRIPTS := $(filter-out Makefile,$(wildcard *)) - -all: - -clean: - -installdirs: - $(INSTALL) -d $(DESTDIR)$(bindir) - -install: all installdirs - $(INSTALL_SCRIPT) $(AUTOMATION_SCRIPTS) $(DESTDIR)$(bindir) - -.PHONY: clean installdirs install diff --git a/automated_packaging/common_functions.pm b/automated_packaging/common_functions.pm deleted file mode 100644 index 0c96e0d7..00000000 --- a/automated_packaging/common_functions.pm +++ /dev/null @@ -1,168 +0,0 @@ -#!/usr/bin/perl - -package common_functions; -use Exporter; -use JSON; - -# Export subroutines -our @ISA = qw(Exporter); -our @EXPORT = qw(get_and_verify_token get_microsoft_email get_git_name get_sorted_prs create_release_changelog has_backport_label); - -# untaint environment -local $ENV{'PATH'} = '/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin'; - -sub get_microsoft_email { - unless (exists $ENV{MICROSOFT_EMAIL}) { - die "You must have a MICROSOFT_EMAIL set"; - } - - my $microsoft_email = $ENV{MICROSOFT_EMAIL}; - return $microsoft_email; -} - -sub get_git_name { - my $git_name = `git config user.name`; - # Strip trailing newline - chomp $git_name; - if ($git_name eq "") { - die "You must set your git name using 'git config user.name \"Your name Here\"'"; - } - return $git_name; -} - - -sub get_and_verify_token { - unless (exists $ENV{GITHUB_TOKEN}) { - die "You must have a GITHUB_TOKEN set"; - } - - my $github_token = $ENV{GITHUB_TOKEN}; - if ($ENV{GITHUB_TOKEN} =~ /^(\w+)$/x) { - $github_token = $1; - } - else { - die "Malformed GITHUB_TOKEN: $github_token"; - } - - my $cmd = "curl -sf -H 'Accept: application/vnd.github.v3.full+json' -X GET --user '$github_token:x-oauth-basic' " . 'https://api.github.com/'; - my $result = `$cmd > /dev/null 2>&1`; - my $exit_code = $? >> 8; - - if ($exit_code == 22) { - die "Your token was rejected by GitHub."; - } - - return $github_token; -} - -# Get sorted PRs according to merged-at by collecting PRs up to given data (using created info) -sub get_sorted_prs { - my $earliest_pr_date = @_[0]; - my $repo_name = @_[1]; - my %sorted_pr_hash = (); - my $github_token = get_and_verify_token(); - - my $page_number = 1; - $merged_date = "2100-12-12"; - do { - my $prs_text = `curl -H "Accept: application/vnd.github.v3.full+json" -X GET --user "$github_token:x-oauth-basic" 'https://api.github.com/repos/citusdata/$repo_name/pulls?base=master&state=all&page=$page_number' 2> /dev/null`; - my @prs = @{decode_json($prs_text)}; - - foreach my $pr (@prs) { - my %pr_hash = %$pr; - - if (defined($pr_hash{'merged_at'})) { - - $merged_date = substr($pr_hash{'merged_at'}, 0, 10); - $created_date = substr($pr_hash{'created_at'}, 0, 10); - - if ($created_date lt $earliest_pr_date) { - last; - } - - if ($merged_date lt $earliest_pr_date) { - next; - } - - $sorted_pr_hash{$pr_hash{'merged_at'}} = $pr_hash{'url'}; - } - } - - $page_number += 1; - } while ($created_date gt $earliest_pr_date); - - my @keys = reverse sort keys(%sorted_pr_hash); - my @vals = @sorted_pr_hash{@keys}; - - print( "PRs has been read in the merge order ..." . "\n" ); - - return @vals; -} - -# Search for the backport label given a label array -sub has_backport_label { - - my @labels = @{$_[0]}; - - foreach my $label (@labels) { - %label_hash = %{$label}; - if ($label_hash{'name'} eq 'backport') { - return 1; - } - } - - return 0; -} - -# Creates changelog entries up to the given last date. It extracts lines starting with DESCRIPTION: from -# PR messages to generate these entries. You can use different repo names to generate changelog entries for -# different repos. -sub create_release_changelog { - my $earliest_pr_date = @_[0]; - my $repo_name = @_[1]; - my $is_point_release = @_[2]; - - my @comment_lines = (); - my $github_token = get_and_verify_token(); - - my @sorted_pr_urls = get_sorted_prs($earliest_pr_date, $repo_name); - - foreach my $pr_url (@sorted_pr_urls) { - print("Getting information for " . $pr_url . "\n"); - my $pr_text = `curl -H "Accept: application/vnd.github.v3.full+json" -X GET --user "$github_token:x-oauth-basic" '$pr_url' 2> /dev/null`; - my %pr_hash = %{decode_json($pr_text)}; - my $add_to_changelog = 1; - - if ($is_point_release) { - my $issue_url = $pr_hash{'issue_url'}; - my $issue_text = `curl -H "Accept: application/vnd.github.v3.full+json" -X GET --user "$github_token:x-oauth-basic" '$issue_url' 2> /dev/null`; - my %issue_hash = %{decode_json($issue_text)}; - $add_to_changelog = 0; - - @labels = @{$issue_hash{'labels'}}; - if (has_backport_label(\@labels)) { - $add_to_changelog = 1; - } - } - - if ($add_to_changelog) { - @log_output = split("\n", $pr_hash{'body'}); - foreach $line (@log_output) { - if ($line =~ /^DESCRIPTION: */) { - $description_part = substr($line, length($&), -1); - - if (length($description_part) > 78) { - print("You have to shorten PR message $description_part of $pr_url\n"); - print("Description should not be longer than 78 charachters, please manually shorten this description\n"); - push(@comment_lines, "TODO: " . "PLEASE SHORTEN THE NEXT LINE MANUALLY, IT SHOULD BE NO LONGER THAN 78 CHARS\n"); - } - - print("Description $description_part has been added ... \n"); - push(@comment_lines, "* " . $description_part . "\n\n"); - } - } - } - } - - return @comment_lines; -} diff --git a/automated_packaging/prepare_changelog.pl b/automated_packaging/prepare_changelog.pl deleted file mode 100644 index 2ba51311..00000000 --- a/automated_packaging/prepare_changelog.pl +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/perl -use lib '/usr/local/bin'; -use common_functions; -use JSON; - -$PROJECT = $ARGV[0]; -$NEW_VERSION = $ARGV[1]; -$EARLIEST_PR_DATE = $ARGV[2]; - -# Necessary to write log date and create a unique branch -@month_names = qw(January February March April May June July August September October November December); -( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(time); -$year += 1900; - -# Necessary to create unique branch -$curTime = time(); - -sub add_changelog_header() { - - # Update the changelog file - open( CHANGELOG_FILE, ">CHANGELOG.md" ) || die "Can't open the Changelog file !"; - print CHANGELOG_FILE "### $PROJECT v$NEW_VERSION ($month_names[$mon] $mday, $year) ###\n\n"; - close(CHANGELOG_FILE); -} - -$github_token = get_and_verify_token(); - -# Checkout the master branch -`git checkout master`; - -# Now create a new branch based on master -`git checkout -b $PROJECT-$NEW_VERSION-changelog-$curTime`; - -# Read the current changelog -open( CHANGELOG_FILE, "; -close(CHANGELOG_FILE); - -# Check whether it is a point release -$is_point_release = $NEW_VERSION !~ /.*\.0$/; -@changelog_addings = create_release_changelog( $EARLIEST_PR_DATE, $PROJECT, $is_point_release ); - -add_changelog_header(); -open( CHANGELOG_FILE, "+>>CHANGELOG.md" ) || die "Can't open the Changelog file !"; -print CHANGELOG_FILE @changelog_addings; -print CHANGELOG_FILE @changelog_current_lines; -close(CHANGELOG_FILE); - -# Commit and push the changes, then open a PR -`git commit -a -m "Add changelog entry for $NEW_VERSION"`; -`git push origin $PROJECT-$NEW_VERSION-changelog-$curTime`; -`curl -g -H "Accept: application/vnd.github.v3.full+json" -X POST --user "$github_token:x-oauth-basic" -d '{\"title\":\"Bump $PROJECT to $NEW_VERSION\", \"base\":\"master\", \"head\":\"$PROJECT-$NEW_VERSION-changelog-$curTime\"}' https://api.github.com/repos/citusdata/$PROJECT/pulls`; diff --git a/automated_packaging/prepare_release.pl b/automated_packaging/prepare_release.pl deleted file mode 100644 index 60f44102..00000000 --- a/automated_packaging/prepare_release.pl +++ /dev/null @@ -1,159 +0,0 @@ -#!/usr/bin/perl -use lib '/usr/local/bin'; -use common_functions; -use JSON; - -$PROJECT = $ARGV[0]; -$NEW_VERSION = $ARGV[1]; -$EARLIEST_PR_DATE = $ARGV[2]; - -# Cherry-pick commit using commit end-points -sub cherry_pick_commits { - @commit_urls = @_; - - my $minor_version = substr($NEW_VERSION, 0, 3); - `git checkout release-$minor_version`; - - foreach my $commit_url (@commit_urls) { - my $current_commits_text = `curl -H "Accept: application/vnd.github.v3.full+json" -X GET --user "$github_token:x-oauth-basic" '$commit_url' 2> /dev/null`; - my @current_commits = @{decode_json($current_commits_text)}; - - foreach my $current_commit (@current_commits) { - %current_commit_hash = %$current_commit; - - # Cherry pick commits - my $current_sha_code = $current_commit_hash{'sha'}; - `git cherry-pick $current_sha_code`; - } - } -} - -# Necessary to create unique branch -$curTime = time(); - -my $github_token = get_and_verify_token(); -my $minor_version = substr($NEW_VERSION, 0, 3); - -# We will update the new major-minor version -$minor_version_escape_dot = $minor_version; -$minor_version_escape_dot =~ s/\./\\./g; - -# Means it is a major release -if ( $NEW_VERSION =~ /.*\.0$/ ) { - - my $UPCOMING_VERSION = substr($NEW_VERSION, 0, 2) . (substr($NEW_VERSION, 2, 3) + 1) . "devel"; - my $upcoming_minor_version = substr($UPCOMING_VERSION, 0, 3); - my $current_version_escape_dot = $minor_version_escape_dot . "devel"; - - # Checkout the master branch of the repo - `git checkout master`; - - # Now checkout ot the new release's branch - `git checkout -b release-$minor_version`; - - # Update the version on the configuration file - `sed -i 's/$current_version_escape_dot/$NEW_VERSION/g' configure.in`; - - # Run autoconf to generate new configure file - `autoconf -f`; - - # Update expected version on multi_extension test - `sed -i 's/$current_version_escape_dot/$NEW_VERSION/g' ./src/test/regress/expected/multi_extension.out`; - - # Push the branch of new release - `git commit -a -m "Bump Citus version to $NEW_VERSION"`; - - `git push origin release-$minor_version`; - - print( "New version's branch has been created ..." . "\n" ); - - # Now the new branch for major or minor release is pushed, - # it is time to update the master branch - `git checkout master`; - `git checkout -b master-update-version-$curTime`; - - # Update the version on the configuration file - `sed -i 's/$current_version_escape_dot/$UPCOMING_VERSION/g' configure.in`; - - # Update the version on the config.py file (for upgrade tests) - `sed -i 's/$minor_version_escape_dot/$upcoming_minor_version/g' ./src/test/regress/upgrade/config.py`; - - # Run autoconf to generate new configure file - `autoconf -f`; - - # Update expected version on multi_extension test - `sed -i 's/$current_version_escape_dot/$UPCOMING_VERSION/g' ./src/test/regress/expected/multi_extension.out`; - - # We also need to update two different lines on the multi_extension.out - `sed -i 's/Loaded library requires $minor_version/Loaded library requires $upcoming_minor_version/g' ./src/test/regress/expected/multi_extension.out`; - - my $current_schema_version = `awk -F' += +' -v property=default_version '\$1 ~ property {print \$2}' "./src/backend/distributed/citus.control"`; - # trim output of awk (remove quotes and newline) - $current_schema_version = substr($current_schema_version, 1, -2); - - # We need to append new lines to test files for migrating to new schema version - `sed -i "/^ALTER EXTENSION citus UPDATE TO '$current_schema_version';/a ALTER EXTENSION citus UPDATE TO '$upcoming_minor_version-1';" ./src/test/regress/sql/multi_extension.sql`; - `sed -i "/^ALTER EXTENSION citus UPDATE TO '$current_schema_version';/a ALTER EXTENSION citus UPDATE TO '$upcoming_minor_version-1';" ./src/test/regress/expected/multi_extension.out`; - - # Add a new sql file - open( NEW_SQL_FILE, ">./src/backend/distributed/citus--$current_schema_version--$upcoming_minor_version-1.sql") || die "New SQL file couldn't created"; - print NEW_SQL_FILE "/* citus--$current_schema_version--$upcoming_minor_version-1 */" - . "\n\n" - . "-- bump version to $upcoming_minor_version-1" . "\n\n"; - close(NEW_SQL_FILE); - - # Update citus.control file - `sed -i 's/$current_schema_version/$upcoming_minor_version-1/g' ./src/backend/distributed/citus.control`; - - # Push the changes to the master branch - `git add ./src/backend/distributed/citus--$current_schema_version--$upcoming_minor_version-1.sql`; - `git commit -a -m "Bump $PROJECT version to $UPCOMING_VERSION"`; - `git push origin master-update-version-$curTime`; - `curl -g -H "Accept: application/vnd.github.v3.full+json" -X POST --user "$github_token:x-oauth-basic" -d '{\"title\":\"Bump Citus to $UPCOMING_VERSION\", \"base\":\"master\", \"head\":\"master-update-version-$curTime"}' https://api.github.com/repos/citusdata/$PROJECT/pulls`; -} - -# means it is a point version -else { - # Checkout release's branch - `git checkout release-$minor_version`; - - # Create empty array to hold commit urls - @picked_commits = (); - - my @sorted_pr_urls = get_sorted_prs($EARLIEST_PR_DATE, $PROJECT ); - - foreach my $pr_url (@sorted_pr_urls) { - my $pr_text = `curl -H "Accept: application/vnd.github.v3.full+json" -X GET --user "$github_token:x-oauth-basic" '$pr_url' 2> /dev/null`; - my %pr_hash = %{decode_json($pr_text)}; - - my $issue_url = $pr_hash{'issue_url'}; - my $issue_text = `curl -H "Accept: application/vnd.github.v3.full+json" -X GET --user "$github_token:x-oauth-basic" '$issue_url' 2> /dev/null`; - my %issue_hash = %{decode_json($issue_text) }; - - @labels = @{$issue_hash{'labels'}}; - if (has_backport_label(\@labels)) { - unshift(@picked_commits, $pr_hash{'commits_url'}); - } - } - - cherry_pick_commits(@picked_commits); - - $new_point_version = substr($NEW_VERSION, -1); - $current_point_version = $new_point_version - "1"; - $current_version_escape_dot = $minor_version . "." . $current_point_version; - $current_version_escape_dot =~ s/[^0-9]/\\./g; - - # Update configuration file - `sed -i 's/$current_version_escape_dot/$NEW_VERSION/g' configure.in`; - - # Run autoconf to generate new configure file - `autoconf`; - - # Update multi_extension file - `sed -i 's/$current_version_escape_dot/$NEW_VERSION/g' ./src/test/regress/expected/multi_extension.out`; - - # Commit changes and push a new branch to pass travis tests - `git commit -a -m "Bump version to $NEW_VERSION"`; - `git checkout -b release-$minor_version-push-$curTime`; - `git push origin release-$minor_version-push-$curTime`; -} diff --git a/automated_packaging/update_cloudformation.pl b/automated_packaging/update_cloudformation.pl deleted file mode 100644 index 6643fbcb..00000000 --- a/automated_packaging/update_cloudformation.pl +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/perl -use lib '/usr/local/bin'; -use common_functions; - -$NEW_VERSION = $ARGV[0]; -$OLD_VERSION = $ARGV[1]; - -`git checkout master`; - -# Update configuration file -$old_major_version = substr($OLD_VERSION, 0, 1); -$new_major_version = substr($NEW_VERSION, 0, 1); - -# Means, we are releasing a new major version -if ($new_major_version != $old_major_version) { - `cp -r citus-$old_major_version citus-$new_major_version`; - `git add citus-$new_major_version`; - `aws s3 cp --recursive --acl public-read --region us-east-1 s3://citus-deployment/aws/citus$old_major_version s3://citus-deployment/aws/citus$new_major_version`; -} - -`sed -i 's/$OLD_VERSION/$NEW_VERSION/g' citus-$new_major_version/citusdb.json`; - -# Commit changes to github -`git commit -a -m "Bump Citus version to $NEW_VERSION"`; -`git push origin master`; - -# Push the new json template to S3 -`aws s3 cp --acl public-read --region us-east-1 citus-$new_major_version/citusdb.json s3://citus-deployment/aws/citus$new_major_version/cloudformation/citus-$NEW_VERSION.json`; diff --git a/automated_packaging/update_docker.pl b/automated_packaging/update_docker.pl deleted file mode 100644 index 11f6c730..00000000 --- a/automated_packaging/update_docker.pl +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/perl -use lib '/usr/local/bin'; -use common_functions; - -$VERSION = $ARGV[0]; -$POSTGERSQL_VERSION = $ARGV[1]; -$num_args = $#ARGV + 1; - -my $minor_version = substr( $VERSION, 0, 3 ); -my $github_token = get_and_verify_token(); - -# Necessary to write log date -my @abbr_mon = qw(January February March April May June July August September October November December); -my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(time); -$year += 1900; - -# Necessary to create unique branch -$curTime = time(); - -# Checkout to the release's branch -`git checkout master`; -`git checkout -b release-$VERSION-$curTime`; - -# That means we want to update postgres version -if ( $num_args == 2 ) { - `sed -i 's/postgres:[[:digit:]]*.[[:digit:]]*/postgres:$POSTGERSQL_VERSION/g' Dockerfile`; -} - -# Update citus version on Dockerfile -`sed -i 's/VERSION=[[:digit:]]*.[[:digit:]]*.[[:digit:]]*/VERSION=$VERSION/g' Dockerfile`; -`sed -i 's/PG_MAJOR-citus-[[:digit:]]*.[[:digit:]]*/PG_MAJOR-citus-$minor_version/g' Dockerfile`; - -# Update citus version on alpine Dockerfile -`sed -i 's/VERSION=[[:digit:]]*.[[:digit:]]*.[[:digit:]]*/VERSION=$VERSION/g' alpine/Dockerfile`; -`sed -i 's/PG_MAJOR-citus-[[:digit:]]*.[[:digit:]]*/PG_MAJOR-citus-$minor_version/g' alpine/Dockerfile`; - -# Update citus version on Postgres 12 Dockerfile -`sed -i 's/VERSION=[[:digit:]]*.[[:digit:]]*.[[:digit:]]*/VERSION=$VERSION/g' postgres-12/Dockerfile`; -`sed -i 's/PG_MAJOR-citus-[[:digit:]]*.[[:digit:]]*/PG_MAJOR-citus-$minor_version/g' postgres-12/Dockerfile`; - -# Update citus version on docker-compose -`sed -i 's/citus:[[:digit:]]*.[[:digit:]]*.[[:digit:]]*/citus:$VERSION/g' docker-compose.yml`; - -# Update travis.yml file -`sed -i 's/citus:[[:digit:]]*.[[:digit:]]*.[[:digit:]]*/citus:$VERSION/g' .travis.yml`; - -# Get current changelog entries -open( CHANGELOG, "; -close(CHANGELOG); - -# Update the changelog file -open( CHANGELOG, ">CHANGELOG.md" ) || die "File not found"; -print CHANGELOG "### citus-docker v$VERSION.docker ($abbr_mon[$mon] $mday, $year) ###\n\n"; -print CHANGELOG "* Bump Citus version to $VERSION\n\n"; - -if ( $num_args == 2 ) { - print CHANGELOG "* Bump PostgreSQL version to $POSTGRESQL_VERSION\n\n"; -} - -print CHANGELOG @current_lines; -close(CHANGELOG); - -# Push the branch and open a PR against master -`git commit -a -m "Bump to version $VERSION"`; -`git push origin release-$VERSION-$curTime`; -`curl -g -H "Accept: application/vnd.github.v3.full+json" -X POST --user "$github_token:x-oauth-basic" -d '{\"title\":\"Bump docker to $VERSION\", \"base\":\"master\", \"head\":\"release-$VERSION-$curTime\"}' https://api.github.com/repos/citusdata/docker/pulls`; diff --git a/automated_packaging/update_documentation.pl b/automated_packaging/update_documentation.pl deleted file mode 100644 index 32bf5f46..00000000 --- a/automated_packaging/update_documentation.pl +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/perl -use lib '/usr/local/bin'; -use common_functions; - -$NEW_VERSION = $ARGV[0]; -$OLD_VERSION = $ARGV[1]; - -my $github_token = get_and_verify_token(); - -# Necessary to create unique branch -$curTime = time(); - -`git checkout master`; -`git checkout -b master-$NEW_VERSION-$curTime`; - -$new_release_minor_version = substr($NEW_VERSION, 0, 3); -$old_release_minor_version = substr($OLD_VERSION, 0, 3); -$old_release_minor_version_escape_dot = $old_release_minor_version; -$old_release_minor_version_escape_dot =~ s/\./\\./g; - -# Update multi_machine_aws.rst -`sed -i 's/$OLD_VERSION/$NEW_VERSION/g' ./installation/multi_machine_aws.rst`; - -# Commit changes to github -`git commit -a -m "Bump Citus version to $NEW_VERSION"`; -`git push origin master-$NEW_VERSION-$curTime`; - -# Open a PR to the master -`curl -g -H "Accept: application/vnd.github.v3.full+json" -X POST --user "$github_token:x-oauth-basic" -d '{\"title\":\"Bump Citus to $NEW_VERSION\", \"base\":\"master\", \"head\":\"master-$NEW_VERSION-$curTime\"}' https://api.github.com/repos/citusdata/citus_docs/pulls`; diff --git a/automated_packaging/update_os_package.pl b/automated_packaging/update_os_package.pl deleted file mode 100644 index 860cb75d..00000000 --- a/automated_packaging/update_os_package.pl +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/perl -use lib '/usr/local/bin'; -use common_functions; - -$DISTRO_VERSION = $ARGV[0]; -$PROJECT = $ARGV[1]; -$VERSION = $ARGV[2]; - -# 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"; -} -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(); - -my $microsoft_email = get_microsoft_email(); -my $git_name = get_git_name(); - -# Debian branch has it's own changelog, we can get them through the CHANGELOG file of the code repo -sub get_changelog_for_debian { - - # Update project spec file - @changelog_file = `curl --user "$github_token:x-oauth-basic" -H "Accept: application/vnd.github.v3.raw" -X GET 'https://api.github.com/repos/citusdata/$github_repo_name/contents/CHANGELOG.md?ref=v$VERSION' 2> /dev/null`; - - $first_version_has_seen = 0; - my @changelog_items; - foreach $line (@changelog_file) { - if ( $line =~ /^#/ ) { - if ( $first_version_has_seen == 1 ) { - last; - } - - $first_version_has_seen += 1; - } - elsif ( $line =~ /^\*/ ) { - $line =~ tr/\`//d; - push( @changelog_items, ' ' . $line ); - } - else { - push( @changelog_items, $line ); - } - } - - return @changelog_items; -} - -# Necessary to write log date for both distros and create unique branch -my @abbr_mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); -my @abbr_day = qw(Sun Mon Tue Wed Thu Fri Sat); -my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = - localtime(time); -$year += 1900; - -# 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 $main_branch`; -# Update distro's branch -`git pull origin $main_branch`; - -# Create a new branch based on the distro's branch -`git checkout -b $pr_branch`; - -# Update 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$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"; - my @lines = ; - close(DEB_CLOG_FILE); - - # Change hour and get changelog (TODO: may update it !) - $print_hour = $hour - 3; - 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$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 -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`; diff --git a/automated_packaging/update_pgxn.pl b/automated_packaging/update_pgxn.pl deleted file mode 100644 index 6f2d7482..00000000 --- a/automated_packaging/update_pgxn.pl +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/perl -use lib '/usr/local/bin'; -use common_functions; - -$NEW_VERSION = $ARGV[0]; -$OLD_VERSION = $ARGV[1]; - -my $github_token = get_and_verify_token(); - -$old_version_escape_dot = $OLD_VERSION; -$old_version_escape_dot =~ s/\./\\./g; -$old_minor_version = substr($OLD_VERSION, 0, 3); -$new_minor_version = substr($NEW_VERSION, 0, 3); -$new_point_version = substr($NEW_VERSION, -1); - -# Necessary to create unique branch -$curTime = time(); - -# Move to code directory -`git checkout pgxn-citus`; -`git checkout -b pgxn-citus-push-$curTime`; - -# Update pkgvars -`sed -i 's/pkglatest=[[:digit:]]*.[[:digit:]]*.[[:digit:]]*/pkglatest=$NEW_VERSION/g' pkgvars`; - -# Update META.json file -`sed -i 's/$old_version_escape_dot/$NEW_VERSION/g' META.json`; - -# Commit changes to github -`git commit -a -m "Bump Citus PGXN to $NEW_VERSION"`; -`git push origin pgxn-citus-push-$curTime`; - -# Open a PR to the master -`curl -g -H "Accept: application/vnd.github.v3.full+json" -X POST --user "$github_token:x-oauth-basic" -d '{\"title\":\"Bump Citus PGXN to $NEW_VERSION\", \"base\":\"pgxn-citus\", \"head\":\"pgxn-citus-push-$curTime\"}' https://api.github.com/repos/citusdata/packaging/pulls`; diff --git a/packaging_automation/tests/files/packaging_warning/sample_warning_build_output_deb.txt b/packaging_automation/tests/files/packaging_warning/sample_warning_build_output_deb.txt index f23c935b..744a14b2 100644 --- a/packaging_automation/tests/files/packaging_warning/sample_warning_build_output_deb.txt +++ b/packaging_automation/tests/files/packaging_warning/sample_warning_build_output_deb.txt @@ -146,7 +146,6 @@ Removing tools/CHANGELOG.md Removing tools/HomebrewFormula/ Removing tools/Makefile Removing tools/README.md -Removing tools/automated_packaging/ Removing tools/citus_dev/ Removing tools/dashboard/ Removing tools/packaging/Makefile diff --git a/packaging_automation/tests/files/packaging_warning/sample_warning_build_output_deb_only_base.txt b/packaging_automation/tests/files/packaging_warning/sample_warning_build_output_deb_only_base.txt index 638ef70e..943f1f27 100644 --- a/packaging_automation/tests/files/packaging_warning/sample_warning_build_output_deb_only_base.txt +++ b/packaging_automation/tests/files/packaging_warning/sample_warning_build_output_deb_only_base.txt @@ -137,7 +137,6 @@ Removing tools/CHANGELOG.md Removing tools/HomebrewFormula/ Removing tools/Makefile Removing tools/README.md -Removing tools/automated_packaging/ Removing tools/citus_dev/ Removing tools/dashboard/ Removing tools/packaging/Makefile diff --git a/packaging_automation/tests/files/packaging_warning/sample_warning_build_output_rpm.txt b/packaging_automation/tests/files/packaging_warning/sample_warning_build_output_rpm.txt index 8f63fc7b..8b3014fe 100644 --- a/packaging_automation/tests/files/packaging_warning/sample_warning_build_output_rpm.txt +++ b/packaging_automation/tests/files/packaging_warning/sample_warning_build_output_rpm.txt @@ -144,7 +144,6 @@ Removing tools/CHANGELOG.md Removing tools/HomebrewFormula/ Removing tools/Makefile Removing tools/README.md -Removing tools/automated_packaging/ Removing tools/citus_dev/ Removing tools/dashboard/ Removing tools/packaging/Makefile diff --git a/packaging_automation/tests/files/packaging_warning/sample_warning_build_output_rpm_success.txt b/packaging_automation/tests/files/packaging_warning/sample_warning_build_output_rpm_success.txt index 8f63fc7b..8b3014fe 100644 --- a/packaging_automation/tests/files/packaging_warning/sample_warning_build_output_rpm_success.txt +++ b/packaging_automation/tests/files/packaging_warning/sample_warning_build_output_rpm_success.txt @@ -144,7 +144,6 @@ Removing tools/CHANGELOG.md Removing tools/HomebrewFormula/ Removing tools/Makefile Removing tools/README.md -Removing tools/automated_packaging/ Removing tools/citus_dev/ Removing tools/dashboard/ Removing tools/packaging/Makefile