Skip to content

Commit 73efd7c

Browse files
authored
Merge branch 'master' into dev
2 parents 06e8f97 + 13d42e9 commit 73efd7c

File tree

2 files changed

+155
-0
lines changed

2 files changed

+155
-0
lines changed

.github/workflows/ci.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,110 @@ jobs:
179179
{"type":"ci","section":"Continuous Integration","hidden":false},
180180
{"type":"chore","section":"Miscellaneous Chores","hidden":true}
181181
]
182+
183+
# Checkout code to work with tags and commits
182184
- uses: actions/checkout@v4
185+
with:
186+
fetch-depth: 0
187+
188+
# Always update the latest release description, even if no new release is created
189+
- name: Update Latest Release Description
190+
if: ${{ !steps.release.outputs.release_created }}
191+
uses: actions/github-script@v6
192+
with:
193+
github-token: ${{ secrets.GITHUB_TOKEN }}
194+
script: |
195+
const { repo, owner } = context.repo;
196+
197+
// Get latest release
198+
const releases = await github.rest.repos.listReleases({
199+
owner,
200+
repo,
201+
per_page: 1
202+
});
203+
204+
if (releases.data.length === 0) {
205+
console.log('No releases found to update');
206+
return;
207+
}
208+
209+
const latestRelease = releases.data[0];
210+
console.log(`Found latest release: ${latestRelease.tag_name}`);
211+
212+
// Get previous release to calculate commits in between
213+
const allReleases = await github.rest.repos.listReleases({
214+
owner,
215+
repo,
216+
per_page: 2
217+
});
218+
219+
const previousTag = allReleases.data.length > 1 ?
220+
allReleases.data[1].tag_name :
221+
'HEAD~20'; // Fallback to last 20 commits if no previous release
222+
223+
// Get commits between the two tags
224+
const { execSync } = require('child_process');
225+
let commitList;
226+
try {
227+
commitList = execSync(
228+
`git log --pretty=format:"* %s (%h)" ${previousTag}..${latestRelease.tag_name} | grep -v "Merge pull request"`
229+
).toString().trim();
230+
} catch (e) {
231+
console.log('Error getting commit list:', e);
232+
commitList = 'Could not generate commit list automatically';
233+
}
234+
235+
// Format the release notes with sections
236+
const features = commitList.split('\n')
237+
.filter(line => line.includes('feat:') || line.includes('feat('))
238+
.join('\n');
239+
240+
const fixes = commitList.split('\n')
241+
.filter(line => line.includes('fix:') || line.includes('fix('))
242+
.join('\n');
243+
244+
const docs = commitList.split('\n')
245+
.filter(line => line.includes('docs:') || line.includes('docs('))
246+
.join('\n');
247+
248+
const other = commitList.split('\n')
249+
.filter(line => !line.includes('feat:') && !line.includes('fix:') && !line.includes('docs:') &&
250+
!line.includes('feat(') && !line.includes('fix(') && !line.includes('docs('))
251+
.join('\n');
252+
253+
// Build release body
254+
let releaseBody = `# What's Changed\n\n`;
255+
256+
if (features) {
257+
releaseBody += `## Features\n${features}\n\n`;
258+
}
259+
260+
if (fixes) {
261+
releaseBody += `## Bug Fixes\n${fixes}\n\n`;
262+
}
263+
264+
if (docs) {
265+
releaseBody += `## Documentation\n${docs}\n\n`;
266+
}
267+
268+
if (other) {
269+
releaseBody += `## Other Changes\n${other}\n\n`;
270+
}
271+
272+
releaseBody += `**Full Changelog**: https://github.com/${owner}/${repo}/compare/${previousTag}...${latestRelease.tag_name}`;
273+
274+
// Update the release
275+
console.log(`Updating release ${latestRelease.id} with new description`);
276+
await github.rest.repos.updateRelease({
277+
owner,
278+
repo,
279+
release_id: latestRelease.id,
280+
body: releaseBody
281+
});
282+
283+
console.log('Release description updated successfully');
284+
285+
# Tag stable version (existing logic)
183286
- name: tag stable versions
184287
if: ${{ steps.release.outputs.release_created }}
185288
run: |
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Refresh Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_bump:
7+
description: "Type of version bump (patch, minor, major)"
8+
required: true
9+
default: "patch"
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
16+
jobs:
17+
refresh-release:
18+
runs-on: ubuntu-latest
19+
# Add permissions for GitHub token
20+
permissions:
21+
contents: write # Needed to push to branches
22+
pull-requests: write # Needed to create/update PRs
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
# Add token for authentication
30+
token: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Setup Git
33+
run: |
34+
git config user.name "GitHub Actions Bot"
35+
git config user.email "[email protected]"
36+
37+
- name: Create conventional commit to trigger release
38+
run: |
39+
# Create empty commit with appropriate conventional commit message
40+
if [[ "${{ github.event.inputs.version_bump }}" == "minor" ]]; then
41+
git commit --allow-empty -m "feat: trigger new release refresh"
42+
elif [[ "${{ github.event.inputs.version_bump }}" == "major" ]]; then
43+
git commit --allow-empty -m "feat!: trigger major release refresh"
44+
else
45+
git commit --allow-empty -m "fix: trigger patch release refresh"
46+
fi
47+
48+
# Push to master branch
49+
git push origin HEAD:master
50+
51+
- name: Provide feedback
52+
run: echo "Release refresh triggered successfully with a ${{ github.event.inputs.version_bump }} version bump!"

0 commit comments

Comments
 (0)