Skip to content

Commit

Permalink
release script添加changelog验证
Browse files Browse the repository at this point in the history
  • Loading branch information
hanaTsuk1 committed Jun 27, 2024
1 parent 3bac22a commit 2ded276
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
15 changes: 14 additions & 1 deletion scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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('<release>').choices(['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease']))
Expand All @@ -39,6 +51,7 @@ program
})
if (!versionConfirm)
return
await checkChangelog(newVersion)
repleaceVersion(newVersion)
await run('git', ['add', '.'])
await run('git', ['commit', '-m', `release: ${targetVersion}`])
Expand Down
2 changes: 2 additions & 0 deletions src-tauri/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Generated by Cargo
# will have compiled files and executables
/target/

.bin
4 changes: 4 additions & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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!!
Expand Down

0 comments on commit 2ded276

Please sign in to comment.