@@ -12,6 +12,7 @@ import fetch from "node-fetch";
12
12
import { spawnSync } from "child_process" ;
13
13
import { Octokit } from "@octokit/core" ;
14
14
import printDiff from "print-diff" ;
15
+ import { generateChangelogFrom } from "../lib/changelog.js" ;
15
16
16
17
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
17
18
// @ts -ignore
@@ -44,6 +45,9 @@ const go = async () => {
44
45
. readdirSync ( join ( generatedDir , dirName ) )
45
46
. filter ( ( f ) => f . endsWith ( ".d.ts" ) ) ;
46
47
48
+ /** @type {string[] } */
49
+ let releaseNotes = [ ] ;
50
+
47
51
// Look through each .d.ts file included in a package to
48
52
// determine if anything has changed
49
53
let upload = false ;
@@ -57,6 +61,11 @@ const go = async () => {
57
61
console . log ( `Comparing ${ file } from unpkg, to generated version:` ) ;
58
62
printDiff ( npmDTSText , generatedDTSContent ) ;
59
63
64
+ const title = `\n## \`${ file } \`\n` ;
65
+ const notes = generateChangelogFrom ( npmDTSText , generatedDTSContent ) ;
66
+ releaseNotes . push ( title ) ;
67
+ releaseNotes . push ( notes . trim ( ) === "" ? "No changes" : notes ) ;
68
+
60
69
upload = upload || npmDTSText !== generatedDTSContent ;
61
70
} catch ( error ) {
62
71
// Could not find a previous build
@@ -93,8 +102,10 @@ Assuming that this means we need to upload this package.`);
93
102
94
103
uploaded . push ( dirName ) ;
95
104
}
96
- }
97
105
106
+ console . log ( "\n# Release notes:" ) ;
107
+ console . log ( releaseNotes . join ( "\n" ) , "\n\n" ) ;
108
+ }
98
109
// Warn if we did a dry run.
99
110
if ( ! process . env . NODE_AUTH_TOKEN ) {
100
111
console . log (
@@ -109,7 +120,7 @@ Assuming that this means we need to upload this package.`);
109
120
}
110
121
} ;
111
122
112
- async function createRelease ( tag ) {
123
+ async function createRelease ( tag , body ) {
113
124
const authToken = process . env . GITHUB_TOKEN || process . env . GITHUB_API_TOKEN ;
114
125
const octokit = new Octokit ( { auth : authToken } ) ;
115
126
@@ -119,6 +130,7 @@ async function createRelease(tag) {
119
130
repo : "TypeScript-DOM-lib-generator" ,
120
131
tag_name : tag ,
121
132
target_commitish : process . env . GITHUB_SHA ,
133
+ body,
122
134
} ) ;
123
135
} catch ( error ) {
124
136
console . error (
0 commit comments