chore(deps): bump actions/download-artifact in /.github/workflows (#398)
[figma-linux.git] / scripts / generate_release_notes.pl
blob7e21ac3f28acfb7669a5fa0c52de3abffca9aee0
1 #!/bin/perl
3 my $isHtml = 0;
4 my $latest = 0;
6 for my $param (@ARGV) {
7 if ($param eq "--html") {
8 $isHtml = 1;
10 if ($param eq "--latest") {
11 $latest = 1;
15 my $features=`git log \$(git tag --sort=version:refname | tail -n2 | head -n1)..HEAD --no-merges --oneline | grep -Eo "feat:.*" | uniq`;
16 my $fixes=`git log \$(git tag --sort=version:refname | tail -n2 | head -n1)..HEAD --no-merges --oneline | grep -Eo "fix:.*" | uniq`;
17 my $other=`git log \$(git tag --sort=version:refname | tail -n2 | head -n1)..HEAD --no-merges --oneline | grep -Eo "(other|chore|impr):.*" | uniq`;
19 if ($latest) {
20 $features=`git log \$(git tag --sort=version:refname | tail -n1)..HEAD --no-merges --oneline | grep -Eo "feat:.*" | uniq`;
21 $fixes=`git log \$(git tag --sort=version:refname | tail -n1)..HEAD --no-merges --oneline | grep -Eo "fix:.*" | uniq`;
22 $other=`git log \$(git tag --sort=version:refname | tail -n1)..HEAD --no-merges --oneline | grep -Eo "(other|chore|impr):.*" | uniq`;
25 my $hasFeatures=`printf "$features" | wc -l | tr -d '\n'`;
26 my $hasFixes=`printf "$fixes" | wc -l | tr -d '\n'`;
27 my $hasOther=`printf "$other" | wc -l | tr -d '\n'`;
28 my @featureList = split /\n/, $features;
29 my @fixList = split /\n/, $fixes;
30 my @otherList = split /\n/, $other;
31 my $baseUrl = "https://github.com/Figma-Linux/figma-linux/issues";
32 my $release_note_file_path = "./release_notes";
34 `echo '' > $release_note_file_path`;
36 sub generate {
37 my $title = $_[0];
38 my @list = @{$_[1]};
40 `echo "$title" >> $release_note_file_path`;
42 for my $msg (@list) {
43 my $issue = `echo "$msg" | grep -Eo "#.*" | tr -d '\n'`;
44 $msg =~ s/^(feat|other|fix|chore|impr): //gi;
46 if ($issue ne "") {
47 my $issueId = substr $issue, 1;
48 $msg =~ s/ ?(Close|#).*$//gi;
50 if ($isHtml) {
51 `echo '<li>$msg <a href="$baseUrl/$issueId" target="_blank">$issue</a></li>' >> $release_note_file_path`;
52 } else {
53 `echo "* $msg [$issue]($baseUrl/$issueId)" >> $release_note_file_path`;
55 } else {
56 if ($isHtml) {
57 `echo "<li>$msg</li>" >> $release_note_file_path`;
58 } else {
59 `echo "* $msg" >> $release_note_file_path`;
64 if ($isHtml) {
65 `echo "<li></li>" >> $release_note_file_path`;
69 if ($hasFeatures > 0) {
70 if ($isHtml) {
71 generate("<li>Features:</li>", \@featureList);
72 } else {
73 generate("## Features:", \@featureList);
76 if ($hasFixes > 0) {
77 `echo '' >> $release_note_file_path`;
81 if ($hasFixes > 0) {
82 if ($isHtml) {
83 generate("<li>Bug Fixes:</li>", \@fixList);
84 } else {
85 generate("## Bug Fixes:", \@fixList);
88 if ($hasOther > 0) {
89 `echo '' >> $release_note_file_path`;
93 if ($hasOther > 0) {
94 if ($isHtml) {
95 generate("<li>Other Changes:</li>", \@otherList);
96 } else {
97 generate("## Other Changes:", \@otherList);