Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(tools-mono): add release-it feature #3

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/kenji-tools-mono-release-it.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@xstools-dev/tools-mono': patch
---

add release it feature
18 changes: 18 additions & 0 deletions packages/tools-mono/bin/release-it.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env node

import releaseIt from 'release-it';
import { configA, defaultConfig } from '../config/release-it.config.js';

// 解析命令行参数
// Example: npx release-it --config=A
const args = process.argv.slice(2);
const customConfigArg = args.find((arg) => arg.startsWith('--config='));
const customConfig = customConfigArg ? customConfigArg.split('=')[1] : null;

let finalConfig = defaultConfig;

if (customConfig === 'A') {
finalConfig = configA;
}

releaseIt(finalConfig);
72 changes: 72 additions & 0 deletions packages/tools-mono/config/release-it.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
export const defaultConfig = {
git: {
// eslint-disable-next-line no-template-curly-in-string
commitMessage: 'chore(release): v${version}',
},
github: {
release: true,
// eslint-disable-next-line no-template-curly-in-string
releaseName: 'v${version}',
tokenRef: 'RELEASE_IT_GITHUB_TOKEN',
},
hooks: {
'before:init': ['npm run format', 'npm run lint:js', 'npm run test'],
'after:bump': 'npm run build',
},
plugins: {
'@release-it/conventional-changelog': {
infile: 'CHANGELOG.md',
preset: {
name: 'conventionalcommits',
types: [
{
type: 'feat',
section: 'Features',
},
{
type: 'fix',
section: 'Bug Fixes',
},
{
type: 'docs',
section: 'Documentation',
},
{
type: 'style',
section: 'Styles',
},
{
type: 'refactor',
section: 'Code Refactoring',
},
{
type: 'perf',
section: 'Performance Improvements',
},
{
type: 'test',
section: 'Tests',
},
{
type: 'build',
section: 'Build System',
},
{
type: 'ci',
section: 'Continuous Integration',
},
{
type: 'chore',
section: 'Chores',
},
{
type: 'revert',
section: 'Reverts',
},
],
},
},
},
};

export const configA = {};
3 changes: 3 additions & 0 deletions packages/tools-mono/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"cz": "./bin/git-cz.js",
"git-cz": "./bin/git-cz.js",
"lint-staged": "./bin/lint-staged.js",
"release-it": "./bin/release-it.js",
"sherif": "./bin/sherif.js",
"simple-git-hooks": "./bin/simple-git-hooks.js",
"turbo": "./bin/turbo.js"
Expand All @@ -24,9 +25,11 @@
"@changesets/cli": "~2.27.6",
"@commitlint/cli": "~19.3.0",
"@commitlint/config-conventional": "~19.2.2",
"@release-it/conventional-changelog": "^8.0.1",
"commitizen": "~4.3.0",
"cz-conventional-changelog": "~3.3.0",
"lint-staged": "~15.2.7",
"release-it": "^17.4.0",
"sherif": "~0.9.0",
"simple-git-hooks": "~2.11.1",
"turbo": "~2.0.6"
Expand Down
Loading