From 7875ff7807dce7419bb7fbd2b4af2a205af5896c Mon Sep 17 00:00:00 2001 From: Zihua Li Date: Mon, 13 May 2024 14:53:09 +0800 Subject: [PATCH] Update changelog actions --- .github/workflows/changelog.yml | 2 +- scripts/changelog.mjs | 26 ++++++++++---------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 301da69b2b..0d6ca6b2ed 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -2,7 +2,7 @@ name: Generate Changelog on: release: - types: [published] + types: [published, created] jobs: changelog: diff --git a/scripts/changelog.mjs b/scripts/changelog.mjs index d2df907c49..79f62dab5c 100644 --- a/scripts/changelog.mjs +++ b/scripts/changelog.mjs @@ -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 "635902+luin@users.noreply.github.com"`; +await $`git add ${changelogFilename}`; +const message = `Update ${changelogFilename}: ${release.tagName}`; +await $`git commit -m ${message}`; +await $`git push origin main`;