|
5 | 5 | - main
|
6 | 6 | pull_request:
|
7 | 7 |
|
8 |
| -permissions: |
9 |
| - write-all |
10 |
| - |
11 | 8 | jobs:
|
12 | 9 | check_pr:
|
13 | 10 | name: "PR checks"
|
|
59 | 56 | || (echo "##[error] found changed files after build. please 'pnpm run generate && pnpm run build'" \
|
60 | 57 | "and commit all changes" \
|
61 | 58 | && exit 1)
|
62 |
| -
|
63 |
| - - name: Check semantic versioning |
64 |
| - id: semantic-release |
65 |
| - shell: bash |
66 |
| - run: | |
67 |
| - GITHUB_REF=$HEAD_REF |
68 |
| - pnpm dlx semantic-release --no-ci --dry-run --plugins @semantic-release/commit-analyzer,@semantic-release/release-notes-generator --branches $HEAD_REF > output.txt |
69 |
| - OUTPUT=$(cat output.txt | base64 -w 0) |
70 |
| - echo "::set-output name=releaseNote::$OUTPUT" |
71 |
| - env: |
72 |
| - HEAD_REF: ${{ github.head_ref }} |
73 |
| - |
74 |
| - - name: Report semantic versioning |
75 |
| - uses: actions/github-script@v7 |
76 |
| - if: ${{ steps.semantic-release.outputs.releaseNote != '' }} |
77 |
| - with: |
78 |
| - github-token: ${{ secrets.GITHUB_TOKEN }} |
79 |
| - script: | |
80 |
| - // Build release notes. |
81 |
| - const semanticReleaseOutput = Buffer.from('${{ steps.semantic-release.outputs.releaseNote }}', 'base64').toString('utf8'); |
82 |
| - const semanticReleaseLogMatch = /^[[0-9:\sAMPM]+\]\s\[semantic-release\].*$/; |
83 |
| - const lines = semanticReleaseOutput.split('\n'); |
84 |
| - const lastSemanticReleaseLogIndex = [...lines] |
85 |
| - .reverse() |
86 |
| - .findIndex((line) => line.match(semanticReleaseLogMatch)); |
87 |
| -
|
88 |
| - const releaseNoteIndex = lines.length - lastSemanticReleaseLogIndex; |
89 |
| - const releaseNote = lines.slice(releaseNoteIndex); |
90 |
| -
|
91 |
| - let res = releaseNote.join('\n'); |
92 |
| - if (!releaseNote.length || !res) { |
93 |
| - res = '### No release note would be generated.'; |
94 |
| - } |
95 |
| -
|
96 |
| - const SEMANTIC_RELEASE_BODY_HEADER = '## 📝 Semantic Release Report'; |
97 |
| - const body = [SEMANTIC_RELEASE_BODY_HEADER, res].join('\n'); |
98 |
| -
|
99 |
| - // Get comments on the PR. |
100 |
| - const comments = await github.issues.listComments({ |
101 |
| - issue_number: context.issue.number, |
102 |
| - owner: context.repo.owner, |
103 |
| - repo: context.repo.repo |
104 |
| - }); |
105 |
| -
|
106 |
| - // Find previous comments that were created by this step to delete. |
107 |
| - const commentsToDelete = comments.data.filter((comment) => |
108 |
| - comment.body.startsWith(SEMANTIC_RELEASE_BODY_HEADER) |
109 |
| - ); |
110 |
| -
|
111 |
| - // Delete eligible comments. |
112 |
| - const prms = commentsToDelete.map((comment) => |
113 |
| - github.issues.deleteComment({ |
114 |
| - comment_id: comment.id, |
115 |
| - owner: context.repo.owner, |
116 |
| - repo: context.repo.repo |
117 |
| - }) |
118 |
| - ); |
119 |
| - await Promise.all(prms); |
120 |
| -
|
121 |
| - // Create fresh new comment for release notes. |
122 |
| - github.issues.createComment({ |
123 |
| - issue_number: context.issue.number, |
124 |
| - owner: context.repo.owner, |
125 |
| - repo: context.repo.repo, |
126 |
| - body |
127 |
| - }); |
0 commit comments