Skip to content

Commit

Permalink
ci: 👷 修改发布脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
hymbz committed Jun 21, 2023
1 parent 594d5b2 commit 545c381
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"dev": "rollup --config --watch --environment NODE_ENV:development --configPlugin rollup-plugin-ts",
"build": "rollup --config --configPlugin rollup-plugin-ts",
"release": "node release.mjs",
"release:push": "node release.mjs push",
"test": "vitest"
},
"dependencies": {
Expand Down
23 changes: 14 additions & 9 deletions release.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { fileURLToPath } from 'url';
import path from 'path';
import shell from 'shelljs';
import release from 'release-it';
import packageJSON from './package.json' assert { type: 'json' };

const __dirname = path.dirname(fileURLToPath(import.meta.url));

Expand All @@ -15,11 +16,23 @@ const exec = (...commands) => {
};

(async () => {
if (process.argv.slice(2).includes('push')) {
const { version } = packageJSON;
// 提交上传更改
exec(
'git add .',
`git commit -m "chore: :bookmark: Release ${version}"`,
`git tag --annotate v${version} --message="Release ${version}"`,
'git push --follow-tags',
);
return;
}

// 测试
exec('pnpm test run');

// 使用 release-it 更新版本,并获得更新日志
const { changelog, version } = await release({
const { changelog } = await release({
ci: true,
git: {
requireCommits: true,
Expand Down Expand Up @@ -47,12 +60,4 @@ const exec = (...commands) => {
path.join(__dirname, './dist/index.js'),
path.join(__dirname, './ComicRead.user.js'),
);

// 提交上传更改
exec(
'git add .',
`git commit -m "chore: :bookmark: Release ${version}"`,
`git tag --annotate v${version} --message="Release ${version}"`,
'git push --follow-tags',
);
})();

0 comments on commit 545c381

Please sign in to comment.