-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
11 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: Generate Changelog | |
|
||
on: | ||
release: | ||
types: [published] | ||
types: [published, created] | ||
|
||
jobs: | ||
changelog: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* Fetch the latest release from GitHub and prepend it to the CHANGELOG.md | ||
* Nothing will happen if the latest release is already in the CHANGELOG.md | ||
*/ | ||
import { execa } from "execa"; | ||
import { $ } from "execa"; | ||
import { readFile, writeFile } from "node:fs/promises"; | ||
import { fileURLToPath } from "node:url"; | ||
import { dirname, join } from "node:path"; | ||
|
@@ -17,12 +17,8 @@ const changeLogFilePath = join( | |
|
||
const currentChangeLog = await readFile(changeLogFilePath, "utf-8"); | ||
|
||
const { stdout } = await execa("gh", [ | ||
"release", | ||
"list", | ||
"--exclude-drafts", | ||
"--json=tagName,publishedAt,name,isLatest", | ||
]); | ||
const { stdout } = | ||
await $`gh release list --exclude-drafts --json=tagName,publishedAt,name,isLatest`; | ||
|
||
const release = JSON.parse(stdout).find((release) => release.isLatest); | ||
|
||
|
@@ -51,18 +47,16 @@ const formatDate = (date) => { | |
}; | ||
|
||
const { body } = JSON.parse( | ||
(await execa("gh", ["release", "view", release.tagName, "--json=body"])) | ||
.stdout | ||
(await $`gh release view ${release.tagName} --json=body`).stdout | ||
); | ||
|
||
const note = `# ${release.tagName} (${formatDate(new Date(release.publishedAt))})\n\n${filteredReleaseNote(body)}\n\n[All changes](https://github.com/quilljs/quill/releases/tag/${release.tagName})\n`; | ||
|
||
await writeFile(changeLogFilePath, `${note}\n${currentChangeLog}`); | ||
|
||
await execa("git", ["add", changelogFilename]); | ||
await execa("git", [ | ||
"commit", | ||
"-m", | ||
`Update ${changelogFilename}: ${release.tagName}`, | ||
]); | ||
await execa("git", ["push", "origin", "main"]); | ||
await $`git config --global user.name "Zihua Li"`; | ||
await $`git config --global user.email "[email protected]"`; | ||
await $`git add ${changelogFilename}`; | ||
const message = `Update ${changelogFilename}: ${release.tagName}`; | ||
await $`git commit -m ${message}`; | ||
await $`git push origin main`; |