@@ -34,6 +34,27 @@ async function createPackageJson(version) {
3434}
3535
3636exports . release = async ( { version } ) => {
37+ // 更新版本号
38+ const newVersion = getVersion ( version )
39+ console . log ( `Updating version to ${ newVersion } ` )
40+
41+ // 更新根目录 package.json 版本号
42+ const rootPackageJson = require ( '../../../package.json' )
43+ rootPackageJson . version = newVersion
44+ await fsExtra . outputFile (
45+ path . resolve ( __dirname , '../../../package.json' ) ,
46+ JSON . stringify ( rootPackageJson , null , 2 ) ,
47+ 'utf-8' ,
48+ )
49+
50+ // 更新 ccui package.json 版本号
51+ packageJson . version = newVersion
52+ await fsExtra . outputFile (
53+ path . resolve ( __dirname , '../../ccui/package.json' ) ,
54+ JSON . stringify ( packageJson , null , 2 ) ,
55+ 'utf-8' ,
56+ )
57+
3758 await createPackageJson ( version )
3859 shell . sed ( '-i' , 'workspace:' , '' , path . resolve ( outputDir , 'package.json' ) )
3960 shell . cp ( '-R' , path . resolve ( __dirname , '../../ccui/README.md' ) , outputDir )
@@ -49,5 +70,16 @@ exports.release = async ({ version }) => {
4970 path . resolve ( __dirname , '../../theme/darkTheme.css' ) ,
5071 path . resolve ( outputDir , 'theme' ) ,
5172 )
52- // shell.exec('npm publish');
73+
74+ // 提交版本更新
75+ shell . cd ( path . resolve ( __dirname , '../../../' ) )
76+ shell . exec ( 'git add .' )
77+ shell . exec ( `git commit -m "chore: release v${ newVersion } "` )
78+ shell . exec ( `git tag v${ newVersion } ` )
79+ shell . exec ( 'git push origin master --tags' )
80+
81+ // 发布到 npm
82+ console . log ( 'Publishing to npm...' )
83+ shell . cd ( outputDir )
84+ shell . exec ( 'npm publish' )
5385}
0 commit comments