-
Notifications
You must be signed in to change notification settings - Fork 175
/
Copy pathgenerate_release_notes.pl
executable file
·99 lines (82 loc) · 2.79 KB
/
generate_release_notes.pl
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/perl
my $isHtml = 0;
my $latest = 0;
for my $param (@ARGV) {
if ($param eq "--html") {
$isHtml = 1;
}
if ($param eq "--latest") {
$latest = 1;
}
}
my $features=`git log \$(git tag --sort=version:refname | tail -n2 | head -n1)..HEAD --no-merges --oneline | grep -Eo "feat:.*" | uniq`;
my $fixes=`git log \$(git tag --sort=version:refname | tail -n2 | head -n1)..HEAD --no-merges --oneline | grep -Eo "fix:.*" | uniq`;
my $other=`git log \$(git tag --sort=version:refname | tail -n2 | head -n1)..HEAD --no-merges --oneline | grep -Eo "(other|chore|impr):.*" | uniq`;
if ($latest) {
$features=`git log \$(git tag --sort=version:refname | tail -n1)..HEAD --no-merges --oneline | grep -Eo "feat:.*" | uniq`;
$fixes=`git log \$(git tag --sort=version:refname | tail -n1)..HEAD --no-merges --oneline | grep -Eo "fix:.*" | uniq`;
$other=`git log \$(git tag --sort=version:refname | tail -n1)..HEAD --no-merges --oneline | grep -Eo "(other|chore|impr):.*" | uniq`;
}
my $hasFeatures=`printf "$features" | wc -l | tr -d '\n'`;
my $hasFixes=`printf "$fixes" | wc -l | tr -d '\n'`;
my $hasOther=`printf "$other" | wc -l | tr -d '\n'`;
my @featureList = split /\n/, $features;
my @fixList = split /\n/, $fixes;
my @otherList = split /\n/, $other;
my $baseUrl = "https://github.com/Figma-Linux/figma-linux/issues";
my $release_note_file_path = "./release_notes";
`echo '' > $release_note_file_path`;
sub generate {
my $title = $_[0];
my @list = @{$_[1]};
`echo "$title" >> $release_note_file_path`;
for my $msg (@list) {
my $issue = `echo "$msg" | grep -Eo "#.*" | tr -d '\n'`;
$msg =~ s/^(feat|other|fix|chore|impr): //gi;
if ($issue ne "") {
my $issueId = substr $issue, 1;
$msg =~ s/ ?(Close|#).*$//gi;
if ($isHtml) {
`echo '<li>$msg <a href="$baseUrl/$issueId" target="_blank">$issue</a></li>' >> $release_note_file_path`;
} else {
`echo "* $msg [$issue]($baseUrl/$issueId)" >> $release_note_file_path`;
}
} else {
if ($isHtml) {
`echo "<li>$msg</li>" >> $release_note_file_path`;
} else {
`echo "* $msg" >> $release_note_file_path`;
}
}
}
if ($isHtml) {
`echo "<li></li>" >> $release_note_file_path`;
}
}
if ($hasFeatures > 0) {
if ($isHtml) {
generate("<li>Features:</li>", \@featureList);
} else {
generate("## Features:", \@featureList);
}
if ($hasFixes > 0) {
`echo '' >> $release_note_file_path`;
}
}
if ($hasFixes > 0) {
if ($isHtml) {
generate("<li>Bug Fixes:</li>", \@fixList);
} else {
generate("## Bug Fixes:", \@fixList);
}
if ($hasOther > 0) {
`echo '' >> $release_note_file_path`;
}
}
if ($hasOther > 0) {
if ($isHtml) {
generate("<li>Other Changes:</li>", \@otherList);
} else {
generate("## Other Changes:", \@otherList);
}
}