Skip to content

Commit ec05ee7

Browse files
authored
Merge pull request #61 from citusdata/improve-update_os_package
Some useful improvements for our release script
2 parents 4f584c0 + c9e3eee commit ec05ee7

2 files changed

Lines changed: 33 additions & 8 deletions

File tree

automated_packaging/common_functions.pm

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,31 @@ use JSON;
66

77
# Export subroutines
88
our @ISA = qw(Exporter);
9-
our @EXPORT = qw(get_and_verify_token get_sorted_prs create_release_changelog has_backport_label);
9+
our @EXPORT = qw(get_and_verify_token get_microsoft_email get_git_name get_sorted_prs create_release_changelog has_backport_label);
1010

1111
# untaint environment
1212
local $ENV{'PATH'} = '/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin';
1313

14+
sub get_microsoft_email {
15+
unless (exists $ENV{MICROSOFT_EMAIL}) {
16+
die "You must have a MICROSOFT_EMAIL set";
17+
}
18+
19+
my $microsoft_email = $ENV{MICROSOFT_EMAIL};
20+
return $microsoft_email;
21+
}
22+
23+
sub get_git_name {
24+
my $git_name = `git config user.name`;
25+
# Strip trailing newline
26+
chomp $git_name;
27+
if ($git_name eq "") {
28+
die "You must set your git name using 'git config user.name \"Your name Here\"'";
29+
}
30+
return $git_name;
31+
}
32+
33+
1434
sub get_and_verify_token {
1535
unless (exists $ENV{GITHUB_TOKEN}) {
1636
die "You must have a GITHUB_TOKEN set";

automated_packaging/update_os_package.pl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616

1717
my $github_token = get_and_verify_token();
1818

19+
my $microsoft_email = get_microsoft_email();
20+
my $git_name = get_git_name();
21+
1922
# Debian branch has it's own changelog, we can get them through the CHANGELOG file of the code repo
2023
sub get_changelog_for_debian {
2124

2225
# Update project spec file
23-
@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' 2> /dev/null`;
26+
@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`;
2427

2528
$first_version_has_seen = 0;
2629
my @changelog_items;
@@ -56,6 +59,8 @@ sub get_changelog_for_debian {
5659

5760
# Checkout the distro's branch
5861
`git checkout $DISTRO_VERSION-$PROJECT`;
62+
# Update distro's branch
63+
`git pull origin $DISTRO_VERSION-$PROJECT`;
5964

6065
# Create a new branch based on the distro's branch
6166
`git checkout -b $DISTRO_VERSION-$PROJECT-push-$curTime`;
@@ -64,12 +69,12 @@ sub get_changelog_for_debian {
6469
`sed -i 's/^pkglatest.*/pkglatest=$VERSION.citus-1/g' pkgvars`;
6570

6671
# Based on the repo, update the package related variables
67-
if ( $DISTRO_VERSION eq "redhat" ) {
72+
if ( $DISTRO_VERSION eq "redhat" || $DISTRO_VERSION eq "microsoft") {
6873
`sed -i 's|^Version:.*|Version: $VERSION.citus|g' $github_repo_name.spec`;
69-
`sed -i 's|^Source0:.*|Source0: https:\/\/github.com\/citusdata\/$github_repo_name\/archive\/v$VERSION.tar.gz|g' $github_repo_name.spec`;
70-
`sed -i 's|^%changelog|%changelog\\n* $abbr_day[$wday] $abbr_mon[$mon] $mday $year - Burak Velioglu <velioglub\@citusdata.com> $VERSION.citus-1\\n- Update to $log_repo_name $VERSION\\n|g' $github_repo_name.spec`;
74+
`sed -i 's|^Source0:.*|Source0: https:\/\/github.com\/citusdata\/$github_repo_name\/archive\/v$VERSION.tar.gz|g' $github_repo_name.spec`;
75+
`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`;
7176
}
72-
elsif ( $DISTRO_VERSION eq "debian" ) {
77+
if ( $DISTRO_VERSION eq "debian" || $DISTRO_VERSION eq "microsoft") {
7378
open( DEB_CLOG_FILE, "<./debian/changelog" ) || die "Debian changelog file not found";
7479
my @lines = <DEB_CLOG_FILE>;
7580
close(DEB_CLOG_FILE);
@@ -82,12 +87,12 @@ sub get_changelog_for_debian {
8287
open( DEB_CLOG_FILE, ">./debian/changelog" ) || die "Debian changelog file not found";
8388
print DEB_CLOG_FILE "$github_repo_name ($VERSION.citus-1) stable; urgency=low\n";
8489
print DEB_CLOG_FILE @changelog_print;
85-
print DEB_CLOG_FILE " -- Burak Velioglu <velioglub\@citusdata.com> $abbr_day[$wday], $mday $abbr_mon[$mon] $year $print_hour:$min:$sec +0000\n\n";
90+
print DEB_CLOG_FILE " -- $git_name <$microsoft_email> $abbr_day[$wday], $mday $abbr_mon[$mon] $year $print_hour:$min:$sec +0000\n\n";
8691
print DEB_CLOG_FILE @lines;
8792
close(DEB_CLOG_FILE);
8893
}
8994

9095
# Commit, push changes and open a pull request
9196
`git commit -a -m "Bump $DISTRO_VERSION $log_repo_name $VERSION"`;
9297
`git push origin $DISTRO_VERSION-$PROJECT-push-$curTime`;
93-
`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\", \"head\":\"$DISTRO_VERSION-$PROJECT-push-$curTime\", \"base\":\"$DISTRO_VERSION-$PROJECT\"}' https://api.github.com/repos/citusdata/packaging/pulls`;
98+
`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`;

0 commit comments

Comments
 (0)