Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ updates:
interval: weekly
open-pull-requests-limit: 99
labels:
- 'pr: dependencies'
- 'dependencies'
42 changes: 42 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
template: |
# What's Changed

$CHANGES

**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION

categories:
- title: 'Breaking'
label: 'breaking'
- title: 'New'
label: 'feature'
- title: 'Bug Fixes'
label: 'bug'
- title: 'Maintenance'
label: 'maintenance'
- title: 'Documentation'
label: 'docs'
- title: 'Other changes'
- title: 'Dependency Updates'
label: 'dependencies'
collapse-after: 5

version-resolver:
major:
labels:
- 'breaking'
minor:
labels:
- 'feature'
patch:
labels:
- 'bug'
- 'maintenance'
- 'docs'
- 'dependencies'
- 'security'

exclude-labels:
- 'skip-changelog'
18 changes: 18 additions & 0 deletions .github/workflows/check-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Validate PR Title"

on:
pull_request:
types:
- opened
- edited
- synchronize
- reopened

jobs:
check-pr-title:
name: Validate PR Title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 16 additions & 0 deletions .github/workflows/draft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Release Drafter
on:
push:
pull_request:
permissions:
contents: read
jobs:
update-release-draft:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75 changes: 75 additions & 0 deletions .github/workflows/pr-auto-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: 'Auto Label by Title'

on:
pull_request:
types:
- opened
- edited # 注意:增加了 edited 类型,标题编辑时也会触发
- synchronize

jobs:
label-by-title:
runs-on: ubuntu-latest
# 添加权限配置
permissions:
issues: write # 或者 contents: write
pull-requests: write
steps:
- name: Label PR based on title keywords
uses: actions/github-script@v7
with:
script: |
const title = context.payload.pull_request.title.toLowerCase();
const labelsToAdd = new Set(); // 使用 Set 避免重复添加

// 定义关键词与标签的映射
const keywordMap = {
'bug': 'bug',
'fix': 'bug',
'error': 'bug',
'feat': 'feature',
'feature': 'feature',
'improvement': 'enhancement',
'doc': 'documentation',
'readme': 'documentation',
'chore': 'chore',
'bump': 'dependencies',
'dependabot': 'dependencies',
'upgrade': 'dependencies',
'security': 'security',
'ci':'ci'
};

// 检查标题是否包含关键词
for (const [keyword, label] of Object.entries(keywordMap)) {
if (title.includes(keyword)) {
labelsToAdd.add(label);
}
}

// 如果有匹配的标签,则先清除现有标签,再添加新标签
if (labelsToAdd.size > 0) {
const labelsArray = Array.from(labelsToAdd);
console.log(`Clearing existing labels and adding: ${labelsArray.join(', ')}`);

// 首先清除所有现有标签
try {
await github.rest.issues.removeAllLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
});
console.log('All existing labels removed');
} catch (error) {
console.log('Error removing labels:', error.message);
}

// 然后添加新的标签
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labelsArray
});
console.log('New labels added successfully');
}
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0 # Use the ref you want to point at
hooks:
- id: check-added-large-files
# - id: trailing-whitespace
# - id: check-yaml
Loading