]> BookStack Code Mirror - devops/blob - meta-scripts/bookstack-changelog
Debian 13 script: Fixed mysql use for mariadb, removed composer use
[devops] / meta-scripts / bookstack-changelog
1 #!/usr/bin/php
2 <?php
3
4 function error($text) {
5         echo $text . "\n";
6         exit(1);
7 }
8
9 function output($text) {
10     echo $text . "\n";
11 }
12
13 function getJSON($url) {
14         $ch = curl_init();
15         curl_setopt_array($ch, [
16                 CURLOPT_URL => $url,
17                 CURLOPT_RETURNTRANSFER => 1,
18                 CURLOPT_HTTPHEADER => [
19                         'User-Agent: ssddanbrown',
20                 ]
21         ]);
22         $data = curl_exec($ch);
23
24         $err = curl_error($ch);
25         curl_close($ch);
26         if (!empty($err)) error($err);
27
28         return json_decode($data, true);
29 }
30
31 // Check a milestone is provided
32 if (count($argv) < 2) {
33         error("Milestone ID required");
34 }
35
36 // Get milestone info from GitHub
37 $milestoneID = intval($argv[1]);
38
39 $issues = [];
40 $requestIssues = [];
41 $page = 1;
42 $issueURL = 'https://api.github.com/repos/BookStackApp/BookStack/issues?milestone='. $milestoneID .'&state=all';
43 do {
44         $requestIssues = getJSON($issueURL . '&page=' . $page);
45         $issues = array_merge($issues, $requestIssues);
46         $page++;
47 } while (count($requestIssues) > 0);
48
49 // Get BookStack version and check if a feature or minor release
50 $milestone = $issues[0]['milestone'];
51 $versionMatch = [];
52 preg_match('/v[0-9.]{5,7}/', $milestone['title'], $versionMatch);
53 $version = $versionMatch[0];
54 $splitVersion = explode('.', $version);
55 $isFeature = count($splitVersion) === 2;
56
57 // Output title
58 output("# BookStack {$version}\n");
59
60 // Output header text and links
61 output("### Links\n");
62 output("- [Update instructions](https://www.bookstackapp.com/docs/admin/updates)");
63 if ($isFeature) {
64     $urlVersion = implode('-', $splitVersion);
65     output("- [Update details on blog](https://www.bookstackapp.com/blog/bookstack-release-{$urlVersion}/)");
66 }
67
68 output("\n### Full List of Changes\n");
69 output("This release contains the following fixes and changes:\n");
70
71 // Output issues
72 foreach ($issues as $issue) {
73         $output = '* ';
74         $output .= trim($issue['title'], '.') . '.';
75         if (isset($issue['pull_request']) && $issue['user']['login'] !== 'ssddanbrown') {
76         $output .= " Thanks to [@{$issue['user']['login']}]({$issue['html_url']}).";
77     }
78         $output .= " ([#{$issue['number']}]({$issue['html_url']}))";
79     output($output);
80 }
Morty Proxy This is a proxified and sanitized view of the page, visit original site.