1+ name : Semantic Version Check
2+
3+ on :
4+ pull_request :
5+ types : [opened, synchronize, reopened]
6+
7+ jobs :
8+ semver-check :
9+ name : Validate Semantic Version
10+ runs-on : ubuntu-latest
11+ permissions :
12+ contents : read
13+ pull-requests : write
14+
15+ steps :
16+ - name : Checkout
17+ uses : actions/checkout@v4
18+ with :
19+ fetch-depth : 0
20+ persist-credentials : false
21+
22+ - name : Install pnpm
23+ uses : pnpm/action-setup@v4
24+ with :
25+ version : 8
26+ run_install : false
27+
28+ - name : Setup Node.js
29+ uses : actions/setup-node@v4
30+ with :
31+ node-version : ' lts/*'
32+ cache : ' pnpm'
33+
34+ - name : Install dependencies
35+ run : pnpm install
36+
37+ - name : Check Release
38+ uses : cycjimmy/semantic-release-action@v4
39+ with :
40+ dry_run : true
41+ ci : false
42+ unset_gha_env : true
43+ env :
44+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
45+
46+ - name : Comment PR
47+ if : always()
48+ uses : actions/github-script@v7
49+ with :
50+ script : |
51+ const semanticResult = process.env.SEMANTIC_OUTPUT;
52+ let comment = '## Semantic Version Check\n\n';
53+
54+ if (semanticResult && semanticResult.includes('The next release version is')) {
55+ const versionMatch = semanticResult.match(/The next release version is (.*)/);
56+ if (versionMatch) {
57+ comment += `✅ Valid semantic version changes detected!\n\n`;
58+ comment += `Next version will be: **${versionMatch[1]}**\n`;
59+ }
60+ } else {
61+ comment += `⚠️ No semantic version changes detected.\n\n`;
62+ comment += 'Please ensure your commits follow the [Conventional Commits](https://www.conventionalcommits.org/) format:\n\n';
63+ comment += '- `feat: new feature` (triggers MINOR version bump)\n';
64+ comment += '- `fix: bug fix` (triggers PATCH version bump)\n';
65+ comment += '- `BREAKING CHANGE: description` (triggers MAJOR version bump)\n';
66+ }
67+
68+ github.rest.issues.createComment({
69+ issue_number: context.issue.number,
70+ owner: context.repo.owner,
71+ repo: context.repo.repo,
72+ body: comment
73+ });
0 commit comments