4 function error($text) {
9 function output($text) {
13 function getJSON($url) {
15 curl_setopt_array($ch, [
17 CURLOPT_RETURNTRANSFER => 1,
18 CURLOPT_HTTPHEADER => [
19 'User-Agent: ssddanbrown',
22 $data = curl_exec($ch);
24 $err = curl_error($ch);
26 if (!empty($err)) error($err);
28 return json_decode($data, true);
31 // Check a milestone is provided
32 if (count($argv) < 2) {
33 error("Milestone ID required");
36 // Get milestone info from GitHub
37 $milestoneID = intval($argv[1]);
42 $issueURL = 'https://api.github.com/repos/BookStackApp/BookStack/issues?milestone='. $milestoneID .'&state=all';
44 $requestIssues = getJSON($issueURL . '&page=' . $page);
45 $issues = array_merge($issues, $requestIssues);
47 } while (count($requestIssues) > 0);
49 // Get BookStack version and check if a feature or minor release
50 $milestone = $issues[0]['milestone'];
52 preg_match('/v[0-9.]{5,7}/', $milestone['title'], $versionMatch);
53 $version = $versionMatch[0];
54 $splitVersion = explode('.', $version);
55 $isFeature = count($splitVersion) === 2;
58 output("# BookStack {$version}\n");
60 // Output header text and links
61 output("### Links\n");
62 output("- [Update instructions](https://www.bookstackapp.com/docs/admin/updates)");
64 $urlVersion = implode('-', $splitVersion);
65 output("- [Update details on blog](https://www.bookstackapp.com/blog/bookstack-release-{$urlVersion}/)");
68 output("\n### Full List of Changes\n");
69 output("This release contains the following fixes and changes:\n");
72 foreach ($issues as $issue) {
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']}).";
78 $output .= " ([#{$issue['number']}]({$issue['html_url']}))";