@@ -12,6 +12,7 @@ import fetch from "node-fetch";
1212import { spawnSync } from "child_process" ;
1313import { Octokit } from "@octokit/core" ;
1414import printDiff from "print-diff" ;
15+ import { generateChangelogFrom } from "../lib/changelog.js" ;
1516
1617// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1718// @ts -ignore
@@ -44,6 +45,9 @@ const go = async () => {
4445 . readdirSync ( join ( generatedDir , dirName ) )
4546 . filter ( ( f ) => f . endsWith ( ".d.ts" ) ) ;
4647
48+ /** @type {string[] } */
49+ let releaseNotes = [ ] ;
50+
4751 // Look through each .d.ts file included in a package to
4852 // determine if anything has changed
4953 let upload = false ;
@@ -57,6 +61,11 @@ const go = async () => {
5761 console . log ( `Comparing ${ file } from unpkg, to generated version:` ) ;
5862 printDiff ( npmDTSText , generatedDTSContent ) ;
5963
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+
6069 upload = upload || npmDTSText !== generatedDTSContent ;
6170 } catch ( error ) {
6271 // Could not find a previous build
@@ -93,8 +102,10 @@ Assuming that this means we need to upload this package.`);
93102
94103 uploaded . push ( dirName ) ;
95104 }
96- }
97105
106+ console . log ( "\n# Release notes:" ) ;
107+ console . log ( releaseNotes . join ( "\n" ) , "\n\n" ) ;
108+ }
98109 // Warn if we did a dry run.
99110 if ( ! process . env . NODE_AUTH_TOKEN ) {
100111 console . log (
@@ -109,7 +120,7 @@ Assuming that this means we need to upload this package.`);
109120 }
110121} ;
111122
112- async function createRelease ( tag ) {
123+ async function createRelease ( tag , body ) {
113124 const authToken = process . env . GITHUB_TOKEN || process . env . GITHUB_API_TOKEN ;
114125 const octokit = new Octokit ( { auth : authToken } ) ;
115126
@@ -119,6 +130,7 @@ async function createRelease(tag) {
119130 repo : "TypeScript-DOM-lib-generator" ,
120131 tag_name : tag ,
121132 target_commitish : process . env . GITHUB_SHA ,
133+ body,
122134 } ) ;
123135 } catch ( error ) {
124136 console . error (
0 commit comments