From 2ded276cf3033662ec092c4a4054c528046046ab Mon Sep 17 00:00:00 2001 From: hanaTsuk1 <101488209+hanaTsuk1@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:15:50 +0800 Subject: [PATCH] =?UTF-8?q?release=20script=E6=B7=BB=E5=8A=A0changelog?= =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/release.js | 15 ++++++++++++++- src-tauri/.gitignore | 2 ++ src-tauri/Cargo.toml | 4 ++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/scripts/release.js b/scripts/release.js index e8e5b6c8..94d27dec 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -10,7 +10,9 @@ import inquirer from 'inquirer' const run = (bin, args, opts = {}) => execa(bin, args, { stdio: 'inherit', ...opts }) -const packagePath = path.join(path.dirname(fileURLToPath(import.meta.url)), '../package.json') +const base = p => path.join(path.dirname(fileURLToPath(import.meta.url)), p) + +const packagePath = base('../package.json') const config = fs.readJsonSync(packagePath) const repleaceVersion = (version) => { @@ -20,6 +22,16 @@ const repleaceVersion = (version) => { }) } +export async function checkChangelog(version) { + const dir = base('../changelog') + const list = await fs.readdir(dir) + for (const name of list) { + await run('cargo', ['bin', 'parse-changelog', '-t', path.join(dir, name), version], { + cwd: base('../src-tauri'), + }) + } +} + const program = new Command() program .addArgument(new Argument('').choices(['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease'])) @@ -39,6 +51,7 @@ program }) if (!versionConfirm) return + await checkChangelog(newVersion) repleaceVersion(newVersion) await run('git', ['add', '.']) await run('git', ['commit', '-m', `release: ${targetVersion}`]) diff --git a/src-tauri/.gitignore b/src-tauri/.gitignore index aba21e24..385014f5 100644 --- a/src-tauri/.gitignore +++ b/src-tauri/.gitignore @@ -1,3 +1,5 @@ # Generated by Cargo # will have compiled files and executables /target/ + +.bin diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 72e197b6..1d244c87 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -41,6 +41,10 @@ open = "5.0.1" zip = "0.6" zip-extensions = "0.6" +[package.metadata.bin] +# cargo-run-bin +parse-changelog = { version = "^0.6" } + [features] # this feature is used for production builds or when `devPath` points to the filesystem # DO NOT REMOVE!!