-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathprepare_changelog.pl
More file actions
52 lines (40 loc) · 1.92 KB
/
prepare_changelog.pl
File metadata and controls
52 lines (40 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/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, "<CHANGELOG.md" ) || die "Changelog file not found";
my @changelog_current_lines = <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`;