Skip to content

Commit f012d1f

Browse files
Merge pull request #7 from MostafaRastegar/develop
docs: update README
2 parents f90b4a6 + 330d3a0 commit f012d1f

2 files changed

Lines changed: 151 additions & 24 deletions

File tree

.github/workflows/release.yml

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1+
# .github/workflows/release.yml
12
name: Release
23
on:
3-
pull_request:
4-
types: [closed]
5-
branches:
6-
- main
74
push:
85
branches:
96
- main
7+
# حذف pull_request trigger برای جلوگیری از اجرای مضاعف
108

119
permissions:
1210
contents: write
@@ -17,22 +15,29 @@ permissions:
1715
jobs:
1816
release:
1917
runs-on: ubuntu-latest
18+
# شرط بهبود یافته - فقط زمانی اجرا شود که:
19+
# 1. Push روی main باشد
20+
# 2. Push توسط merge PR باشد (نه push مستقیم)
2021
if: |
21-
github.event.pull_request.merged == true &&
22-
github.event.pull_request.base.ref == 'main'
22+
github.ref == 'refs/heads/main' &&
23+
(
24+
github.event_name == 'push' &&
25+
contains(github.event.head_commit.message, 'Merge pull request')
26+
)
2327
2428
steps:
2529
- name: 🔍 Debug Info
2630
run: |
2731
echo "Event: ${{ github.event_name }}"
2832
echo "Ref: ${{ github.ref }}"
2933
echo "Branch: ${{ github.ref_name }}"
30-
echo "Merged: ${{ github.event.pull_request.merged }}"
34+
echo "Commit Message: ${{ github.event.head_commit.message }}"
35+
echo "Actor: ${{ github.actor }}"
3136
3237
- name: 📥 Checkout
3338
uses: actions/checkout@v4
3439
with:
35-
fetch-depth: 0 # Required for semantic-release
40+
fetch-depth: 0 # برای semantic-release ضروری است
3641
token: ${{ secrets.GITHUB_TOKEN }}
3742

3843
- name: 📦 Setup Node.js
@@ -54,15 +59,27 @@ jobs:
5459
- name: 🧪 Run tests
5560
run: npm run test:ci
5661

62+
# افزودن step برای بررسی commit messages
63+
- name: 🔍 Check Recent Commits
64+
run: |
65+
echo "Last 5 commits:"
66+
git log --oneline -5
67+
echo "Checking for conventional commits..."
68+
git log --pretty=format:"%s" -10 | head -5
69+
5770
- name: 🔍 Debug semantic-release (dry-run)
58-
run: npx semantic-release --dry-run
71+
run: |
72+
echo "Running semantic-release in dry-run mode..."
73+
npx semantic-release --dry-run --debug
5974
env:
6075
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6176
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
6277
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6378

6479
- name: 🚀 Release
65-
run: npx semantic-release
80+
run: |
81+
echo "Running semantic-release..."
82+
npx semantic-release --debug
6683
env:
6784
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6885
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

release.config.cjs

Lines changed: 124 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
// release.config.cjs
22
module.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-z0-9](?:-?[a-z0-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

Comments
 (0)