11// release.config.cjs
22module . exports = {
3- branches : [ "main" , { name : "next" , prerelease : true } ] ,
3+ branches : [
4+ "main" ,
5+ { name : "next" , prerelease : true } ,
6+ { name : "develop" , prerelease : "beta" } // اگر میخواهید develop هم release داشته باشد
7+ ] ,
48
5- // Debug mode
6- debug : process . env . CI ? false : true ,
9+ // Debug mode فقط در محیط local
10+ debug : ! process . env . CI ,
711
812 plugins : [
9- // 1. Analyze commits to determine release type
13+ // 1. تحلیل commit ها
1014 [
1115 "@semantic-release/commit-analyzer" ,
1216 {
@@ -19,56 +23,150 @@ module.exports = {
1923 // Code improvements
2024 { type : "refactor" , release : "patch" } ,
2125 { type : "perf" , release : "patch" } ,
26+ { type : "style" , release : "patch" } , // CSS/UI changes
2227
23- // Features and fixes (default behavior)
28+ // Features and fixes
2429 { type : "feat" , release : "minor" } ,
30+ { type : "feature" , release : "minor" } ,
2531 { type : "fix" , release : "patch" } ,
32+ { type : "bugfix" , release : "patch" } ,
2633
2734 // Breaking changes
2835 { breaking : true , release : "major" } ,
2936
37+ // Security fixes
38+ { type : "security" , release : "patch" } ,
39+
40+ // Dependencies
41+ { type : "deps" , release : "patch" } ,
42+ { type : "dep" , release : "patch" } ,
43+
3044 // No release for these
31- { type : "style" , release : false } ,
3245 { type : "chore" , release : false } ,
3346 { type : "test" , release : false } ,
3447 { type : "ci" , release : false } ,
3548 { type : "build" , release : false } ,
49+ { type : "revert" , release : false } ,
3650 ] ,
3751 parserOpts : {
38- noteKeywords : [ "BREAKING CHANGE" , "BREAKING CHANGES" ] ,
52+ noteKeywords : [ "BREAKING CHANGE" , "BREAKING CHANGES" , "BREAKING" ] ,
53+ // Patterns برای شناسایی commit types
54+ headerPattern : / ^ ( \w * ) (?: \( ( .* ) \) ) ? : ( .* ) $ / ,
55+ headerCorrespondence : [ "type" , "scope" , "subject" ] ,
56+ // مثالهای معتبر:
57+ // feat: add new feature
58+ // fix: resolve bug
59+ // feat(auth): add login functionality
60+ // fix(ui): correct button styling
3961 } ,
4062 } ,
4163 ] ,
4264
43- // 2. Generate release notes
65+ // 2. تولید release notes
4466 [
4567 "@semantic-release/release-notes-generator" ,
4668 {
4769 preset : "angular" ,
4870 writerOpts : {
4971 commitsSort : [ "subject" , "scope" ] ,
72+ // سفارشی سازی sections
73+ transform : ( commit , context ) => {
74+ const issues = [ ] ;
75+
76+ commit . notes . forEach ( note => {
77+ note . title = "BREAKING CHANGES" ;
78+ } ) ;
79+
80+ if ( commit . type === "feat" || commit . type === "feature" ) {
81+ commit . type = "✨ Features" ;
82+ } else if ( commit . type === "fix" || commit . type === "bugfix" ) {
83+ commit . type = "🐛 Bug Fixes" ;
84+ } else if ( commit . type === "perf" ) {
85+ commit . type = "⚡ Performance" ;
86+ } else if ( commit . type === "revert" ) {
87+ commit . type = "⏪ Reverts" ;
88+ } else if ( commit . type === "docs" || commit . type === "doc" ) {
89+ commit . type = "📚 Documentation" ;
90+ } else if ( commit . type === "style" ) {
91+ commit . type = "💄 Styles" ;
92+ } else if ( commit . type === "refactor" ) {
93+ commit . type = "♻️ Code Refactoring" ;
94+ } else if ( commit . type === "test" ) {
95+ commit . type = "✅ Tests" ;
96+ } else if ( commit . type === "build" ) {
97+ commit . type = "🔧 Build System" ;
98+ } else if ( commit . type === "ci" ) {
99+ commit . type = "👷 CI" ;
100+ } else if ( commit . type === "chore" ) {
101+ return ;
102+ } else {
103+ return ;
104+ }
105+
106+ if ( typeof commit . hash === "string" ) {
107+ commit . shortHash = commit . hash . substring ( 0 , 7 ) ;
108+ }
109+
110+ if ( typeof commit . subject === "string" ) {
111+ let url = context . repository
112+ ? `${ context . host } /${ context . owner } /${ context . repository } `
113+ : context . repoUrl ;
114+ if ( url ) {
115+ url = `${ url } /issues/` ;
116+ // Issue references
117+ commit . subject = commit . subject . replace ( / # ( [ 0 - 9 ] + ) / g, ( _ , issue ) => {
118+ issues . push ( issue ) ;
119+ return `[#${ issue } ](${ url } ${ issue } )` ;
120+ } ) ;
121+ }
122+ if ( context . host ) {
123+ // User references
124+ commit . subject = commit . subject . replace ( / \B @ ( [ a - z 0 - 9 ] (?: - ? [ a - z 0 - 9 / ] ) { 0 , 38 } ) / g, ( _ , username ) => {
125+ if ( username . includes ( "/" ) ) {
126+ return `@${ username } ` ;
127+ }
128+
129+ return `[@${ username } ](${ context . host } /${ username } )` ;
130+ } ) ;
131+ }
132+ }
133+
134+ // remove references that already appear in the subject
135+ commit . references = commit . references . filter ( reference => {
136+ if ( issues . indexOf ( reference . issue ) === - 1 ) {
137+ return true ;
138+ }
139+
140+ return false ;
141+ } ) ;
142+
143+ return commit ;
144+ } ,
50145 } ,
51146 } ,
52147 ] ,
53148
54- // 3. Update CHANGELOG.md
149+ // 3. بهروزرسانی CHANGELOG.md
55150 [
56151 "@semantic-release/changelog" ,
57152 {
58153 changelogFile : "CHANGELOG.md" ,
154+ changelogTitle : "# 📝 Changelog\n\nAll notable changes to this project will be documented in this file." ,
59155 } ,
60156 ] ,
61157
62- // 4. Update package.json and publish to NPM
158+ // 4. بهروزرسانی package.json و انتشار در NPM
63159 [
64160 "@semantic-release/npm" ,
65161 {
66162 npmPublish : true ,
67163 tarballDir : "dist" ,
164+ // اطمینان از build قبل از publish
165+ prepublishOnly : false ,
68166 } ,
69167 ] ,
70168
71- // 5. Create GitHub release
169+ // 5. ایجاد GitHub release
72170 [
73171 "@semantic-release/github" ,
74172 {
@@ -77,18 +175,30 @@ module.exports = {
77175 path : "dist/*.tgz" ,
78176 label : "Package tarball" ,
79177 } ,
178+ {
179+ path : "CHANGELOG.md" ,
180+ label : "Changelog" ,
181+ } ,
80182 ] ,
183+ // سفارشی سازی عنوان و توضیحات release
184+ successComment : "🎉 This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version}" ,
185+ labels : [ "released" ] ,
186+ releasedLabels : [ "released<%= nextRelease.channel ? ` on @${nextRelease.channel}` : " " %> from <%= nextRelease.gitTag %>" ] ,
81187 } ,
82188 ] ,
83189
84- // 6. Commit updated files (must be last )
190+ // 6. Commit فایلهای بهروزرسانی شده (باید آخرین باشد )
85191 [
86192 "@semantic-release/git" ,
87193 {
88194 assets : [ "CHANGELOG.md" , "package.json" , "package-lock.json" ] ,
89195 message :
90- "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" ,
196+ "chore(release): 🚀 ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" ,
91197 } ,
92198 ] ,
93199 ] ,
94- } ;
200+
201+ // تنظیمات اضافی برای troubleshooting
202+ repositoryUrl : "https://github.com/mostafarastegar/react-constore.git" ,
203+ tagFormat : "v${version}" ,
204+ } ;
0 commit comments