Skip to content

Commit 90f6e1f

Browse files
committed
feat(release-drafter): add release drafter configuration and update release workflow to handle draft releases
Signed-off-by: samzong <samzong.lu@gmail.com>
1 parent 23dc91d commit 90f6e1f

4 files changed

Lines changed: 265 additions & 47 deletions

File tree

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 55 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,71 @@
1-
## Description
1+
## 📝 Description
22

33
Briefly describe the purpose and changes in this Pull Request.
44

5-
## Change Type
5+
## 🔄 Change Type
66

7-
- [ ] Bug fix (bug fix)
8-
- [ ] New feature (new feature)
9-
- [ ] Code improvement (code improvement)
10-
- [ ] Documentation update (documentation)
11-
- [ ] Build/CI related changes (build/CI)
12-
- [ ] Other (please specify in the description)
7+
**Important**: Select the primary type to help with automatic release note generation.
138

14-
## Related Issues
9+
- [ ]**Feature** - New feature or enhancement (`feat:` in commit)
10+
- [ ] 🐛 **Bug Fix** - Fix for a bug or issue (`fix:` in commit)
11+
- [ ] 🎨 **UI/UX** - User interface improvements (`style:` in commit)
12+
- [ ] 🔧 **Refactor** - Code refactoring without functional changes (`refactor:` in commit)
13+
- [ ] 📚 **Documentation** - Documentation updates (`docs:` in commit)
14+
- [ ] 🧹 **Maintenance** - Chores, dependencies, housekeeping (`chore:` in commit)
15+
- [ ]**Performance** - Performance improvements (`perf:` in commit)
16+
- [ ] 💥 **Breaking Change** - Changes that break backwards compatibility (add `!` to commit)
1517

16-
Please link the issue this PR solves (if any).
17-
For example: Fixes #123
18+
## 📱 Platform Impact
1819

19-
## Testing
20+
- [ ] **macOS App** - Changes affect the main SwiftUI application
21+
- [ ] **CLI Tool** - Changes affect the command-line interface (`cf`)
22+
- [ ] **Build System** - Changes affect Makefile, CI/CD, or build process
23+
- [ ] **Both App & CLI** - Changes affect multiple components
2024

21-
Please describe the tests you performed and the environments you tested in.
25+
## 🔗 Related Issues
2226

23-
- [ ] Tested on Intel Mac
24-
- [ ] Tested on Apple Silicon Mac
25-
- [ ] Unit tests passed
26-
- [ ] UI tests passed
27+
Please link any related issues using keywords:
28+
- `Closes #123` or `Fixes #456` for bug fixes
29+
- `Relates to #789` for general connections
2730

28-
## Screenshots
31+
## 🧪 Testing
2932

30-
If applicable, add screenshots to help explain your changes.
33+
Please describe the tests you performed:
3134

32-
## Checklist
35+
- [ ] **Manual Testing** - Tested functionality manually
36+
- [ ] **Intel Mac** - Tested on x86_64 architecture
37+
- [ ] **Apple Silicon** - Tested on arm64 architecture
38+
- [ ] **Unit Tests** - Added/updated unit tests
39+
- [ ] **Integration Tests** - Tested with other components
40+
- [ ] **CLI Testing** - Tested command-line interface (if applicable)
3341

34-
- [ ] My code follows the project's code style
35-
- [ ] I have performed self-testing
36-
- [ ] I have updated the relevant documentation (if applicable)
37-
- [ ] My changes do not introduce new warnings or errors
38-
- [ ] My changes are compatible with Intel and Apple Silicon architectures
42+
## 📸 Screenshots
3943

40-
## Additional Information
44+
If applicable, add screenshots to help explain UI/UX changes.
4145

42-
Any other information that reviewers need to know.
46+
## 📋 Checklist
47+
48+
- [ ] Code follows the project's style guidelines (SwiftFormat/SwiftLint)
49+
- [ ] Self-review of code completed
50+
- [ ] Code is properly commented (especially complex areas)
51+
- [ ] Documentation updated if needed (`CLAUDE.md`, comments, etc.)
52+
- [ ] No compiler warnings or errors introduced
53+
- [ ] Changes are compatible with both Intel and Apple Silicon
54+
- [ ] SwiftGen run if localization strings changed (`make swiftgen`)
55+
- [ ] Commit messages follow [Conventional Commits](https://www.conventionalcommits.org/) format
56+
57+
## 🎯 Release Notes Impact
58+
59+
This change should be included in the release notes under:
60+
- [ ] **New Features**
61+
- [ ] **UI/UX Improvements** 🎨
62+
- [ ] **Bug Fixes** 🐛
63+
- [ ] **Technical Improvements** 🔧
64+
- [ ] **Documentation** 📚
65+
- [ ] **Maintenance** 🧹
66+
- [ ] **Skip Release Notes** (minor changes only)
67+
68+
## 💡 Additional Notes
69+
70+
Any additional context, concerns, or notes for reviewers.
4371

.github/release-drafter.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name-template: 'v$RESOLVED_VERSION'
2+
tag-template: 'v$RESOLVED_VERSION'
3+
template: |
4+
# ConfigForge v$RESOLVED_VERSION 🚀
5+
6+
A $RELEASE_TYPE release with $CHANGES_COUNT change(s).
7+
8+
$CHANGES
9+
10+
## 📦 Binary Assets
11+
12+
- `ConfigForge-arm64.dmg` - Apple Silicon (M1/M2/M3/M4) Macs
13+
- `ConfigForge-x86_64.dmg` - Intel-based Macs
14+
15+
## 🔗 Full Changelog
16+
17+
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
18+
19+
---
20+
21+
*This release continues ConfigForge's commitment to excellence in configuration management.*
22+
23+
categories:
24+
- title: '✨ New Features'
25+
labels:
26+
- 'feature'
27+
- 'enhancement'
28+
- 'feat'
29+
collapse-after: 5
30+
- title: '🎨 UI/UX Improvements'
31+
labels:
32+
- 'ui'
33+
- 'ux'
34+
- 'design'
35+
- 'style'
36+
collapse-after: 8
37+
- title: '🐛 Bug Fixes'
38+
labels:
39+
- 'fix'
40+
- 'bugfix'
41+
- 'bug'
42+
collapse-after: 5
43+
- title: '🔧 Technical Improvements'
44+
labels:
45+
- 'refactor'
46+
- 'performance'
47+
- 'technical-debt'
48+
- 'optimization'
49+
collapse-after: 6
50+
- title: '📚 Documentation'
51+
labels:
52+
- 'documentation'
53+
- 'docs'
54+
collapse-after: 3
55+
- title: '🧹 Maintenance'
56+
labels:
57+
- 'chore'
58+
- 'maintenance'
59+
- 'dependencies'
60+
collapse-after: 8
61+
62+
change-template: '- **$TITLE** by @$AUTHOR (#$NUMBER)'
63+
change-title-escapes: '\<*_&'
64+
65+
version-resolver:
66+
major:
67+
labels:
68+
- 'major'
69+
- 'breaking-change'
70+
- 'breaking'
71+
minor:
72+
labels:
73+
- 'minor'
74+
- 'feature'
75+
- 'enhancement'
76+
- 'feat'
77+
patch:
78+
labels:
79+
- 'patch'
80+
- 'fix'
81+
- 'bugfix'
82+
- 'chore'
83+
- 'style'
84+
- 'refactor'
85+
- 'docs'
86+
default: patch
87+
88+
autolabeler:
89+
- label: 'feature'
90+
title:
91+
- '/^feat(\(.*\))?!?:/i'
92+
- '/^feature(\(.*\))?!?:/i'
93+
- label: 'fix'
94+
title:
95+
- '/^fix(\(.*\))?!?:/i'
96+
- '/^bugfix(\(.*\))?!?:/i'
97+
- label: 'style'
98+
title:
99+
- '/^style(\(.*\))?!?:/i'
100+
- label: 'refactor'
101+
title:
102+
- '/^refactor(\(.*\))?!?:/i'
103+
- label: 'documentation'
104+
title:
105+
- '/^docs(\(.*\))?!?:/i'
106+
- '/^doc(\(.*\))?!?:/i'
107+
- label: 'chore'
108+
title:
109+
- '/^chore(\(.*\))?!?:/i'
110+
- label: 'performance'
111+
title:
112+
- '/^perf(\(.*\))?!?:/i'
113+
- '/^performance(\(.*\))?!?:/i'
114+
- label: 'breaking'
115+
title:
116+
- '/^.*!:/i'
117+
- label: 'ui'
118+
title:
119+
- '/^style\(ui\)/i'
120+
- '/^style\(views\)/i'
121+
- '/^style\(components\)/i'
122+
- label: 'enhancement'
123+
title:
124+
- '/^feat\(.*\): (?:add|enhance|improve)/i'
125+
- '/^enhancement/i'
126+
127+
exclude-labels:
128+
- 'skip-changelog'
129+
- 'dependencies'
130+
131+
sort-direction: 'descending'
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, reopened, synchronize]
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
update_release_draft:
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: release-drafter/release-drafter@v6
21+
with:
22+
config-name: release-drafter.yml
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 55 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,67 @@ jobs:
3434
echo "==> Check release version architecture compatibility..."
3535
make check-arch
3636
37-
- name: Generate Release Notes
38-
id: release_notes
37+
- name: Get Release Draft
38+
id: get_draft
3939
env:
4040
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4141
run: |
42-
# Generate GitHub-style release notes using the GitHub CLI
43-
gh api \
44-
--method POST \
45-
-H "Accept: application/vnd.github+json" \
46-
/repos/${{ github.repository }}/releases/generate-notes \
47-
-f tag_name='${{ env.VERSION }}' > generated_notes.json
42+
# Try to get existing draft release
43+
DRAFT_ID=$(gh release list --json isDraft,tagName,id | jq -r '.[] | select(.isDraft == true) | .id' | head -1)
4844
49-
jq -r '.body' generated_notes.json > release_notes.md
45+
if [ -n "$DRAFT_ID" ] && [ "$DRAFT_ID" != "null" ]; then
46+
echo "Found existing draft release: $DRAFT_ID"
47+
echo "draft_id=$DRAFT_ID" >> $GITHUB_OUTPUT
48+
49+
# Get the draft release body
50+
gh release view --json body | jq -r '.body' > release_notes.md
51+
else
52+
echo "No draft release found, generating basic release notes..."
53+
echo "draft_id=" >> $GITHUB_OUTPUT
54+
55+
# Fallback: generate basic release notes
56+
gh api \
57+
--method POST \
58+
-H "Accept: application/vnd.github+json" \
59+
/repos/${{ github.repository }}/releases/generate-notes \
60+
-f tag_name='${{ env.VERSION }}' | jq -r '.body' > release_notes.md
61+
fi
5062
51-
- name: Create Release
52-
uses: softprops/action-gh-release@v2
53-
with:
54-
name: ${{ env.VERSION }}
55-
body_path: release_notes.md
56-
draft: false
57-
prerelease: false
58-
files: |
59-
build/ConfigForge-x86_64.dmg
60-
build/ConfigForge-arm64.dmg
63+
- name: Create or Update Release
64+
id: create_release
6165
env:
62-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
run: |
68+
if [ -n "${{ steps.get_draft.outputs.draft_id }}" ]; then
69+
echo "Publishing existing draft release..."
70+
71+
# Update the draft release to published and add assets
72+
gh release edit ${{ steps.get_draft.outputs.draft_id }} \
73+
--draft=false \
74+
--tag=${{ env.VERSION }} \
75+
--title="${{ env.VERSION }}"
76+
77+
# Upload assets to the existing release
78+
gh release upload ${{ env.VERSION }} \
79+
build/ConfigForge-x86_64.dmg \
80+
build/ConfigForge-arm64.dmg \
81+
--clobber
82+
83+
echo "Release published successfully from draft"
84+
else
85+
echo "Creating new release..."
86+
87+
# Create new release using softprops action as fallback
88+
gh release create ${{ env.VERSION }} \
89+
--title "${{ env.VERSION }}" \
90+
--notes-file release_notes.md \
91+
--draft=false \
92+
--prerelease=false \
93+
build/ConfigForge-x86_64.dmg \
94+
build/ConfigForge-arm64.dmg
95+
96+
echo "New release created successfully"
97+
fi
6398
6499
- name: Trigger Homebrew Update
65100
#Trigger workflow only when release is successful

0 commit comments

Comments
 (0)