Skip to content

Commit 29aa138

Browse files
committed
chore(versioning): Add aditional labels and sync
1 parent 135e759 commit 29aa138

File tree

3 files changed

+230
-42
lines changed

3 files changed

+230
-42
lines changed

.github/labels.yml

Lines changed: 44 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,123 +15,136 @@
1515

1616
# Type labels (based on conventional commits)
1717
- name: enhancement
18-
color: '7B68EE'
19-
description: 'New feature or enhancement - adds functionality (conventional commit: feat)'
18+
color: 'A28EFF'
19+
description: 'Enhancement - improves existing functionality'
2020

2121
- name: bug
22-
color: 'DC143C'
22+
color: 'FF1744'
2323
description: '🐛 Bug fix - resolves an issue or error (conventional commit: fix)'
2424

2525
- name: documentation
26-
color: '20B2AA'
26+
color: '00E5FF'
2727
description: '📚 Documentation improvements - updates docs, comments, or guides (conventional commit: docs)'
2828

2929
- name: style
30-
color: 'FF69B4'
30+
color: 'FF4081'
3131
description: '💅 Code style changes - formatting, whitespace, missing semicolons (conventional commit: style)'
3232

3333
- name: refactor
34-
color: 'FFD700'
34+
color: 'FFEA00'
3535
description: '♻️ Code refactoring - restructuring without changing behavior (conventional commit: refactor)'
3636

3737
- name: performance
38-
color: '9370DB'
38+
color: 'AA00FF'
3939
description: '⚡ Performance improvements - optimizations and speed enhancements (conventional commit: perf)'
4040

4141
- name: testing
42-
color: '48D1CC'
42+
color: '00E676'
4343
description: '🧪 Test updates - adding or updating tests (conventional commit: test)'
4444

4545
- name: maintenance
46-
color: 'D2B48C'
46+
color: 'FFB300'
4747
description: '🔧 Maintenance tasks - routine upkeep and housekeeping (conventional commit: chore)'
4848

4949
- name: ci/cd
50-
color: '228B22'
50+
color: '00C853'
5151
description: '🚀 CI/CD changes - workflow automation and deployment (conventional commit: ci)'
5252

5353
- name: build
54-
color: '808080'
54+
color: '9E9E9E'
5555
description: '🏗️ Build system changes - build tools, dependencies, config (conventional commit: build)'
5656

5757
- name: revert
58-
color: '696969'
58+
color: '78909C'
5959
description: '⏪ Revert changes - undoing previous commits (conventional commit: revert)'
6060

6161
- name: breaking change
62-
color: 'FF4500'
62+
color: 'FF3D00'
6363
description: '💥 BREAKING CHANGE - incompatible API changes requiring major version bump'
6464

6565
# Size labels (auto-added based on PR size)
6666
- name: size/XS
6767
color: '00E676'
68-
description: '📏 Extra small change - less than 10 lines modified'
68+
description: '🐭 Extra small change - less than 10 lines modified'
6969

7070
- name: size/S
7171
color: '76FF03'
72-
description: '📏 Small change - less than 50 lines modified'
72+
description: '🐿️ Small change - less than 50 lines modified'
7373

7474
- name: size/M
7575
color: 'FDD835'
76-
description: '📏 Medium change - less than 200 lines modified'
76+
description: '🐕 Medium change - less than 200 lines modified'
7777

7878
- name: size/L
7979
color: 'FF6D00'
80-
description: '📏 Large change - less than 500 lines modified'
80+
description: '🐘 Large change - less than 500 lines modified'
8181

8282
- name: size/XL
8383
color: 'D50000'
84-
description: '📏 Extra large change - 500+ lines modified, consider splitting'
84+
description: '🦖 Extra large change - 500+ lines modified, consider splitting'
8585

8686
# Additional useful labels
8787
- name: dependencies
88-
color: '0366D6'
88+
color: '2196F3'
8989
description: '📦 Dependency updates - library and package upgrades'
9090

9191
- name: security
92-
color: 'B22222'
92+
color: 'D50000'
9393
description: '🔒 Security fixes - patches for vulnerabilities'
9494

9595
- name: good first issue
96-
color: '7057FF'
96+
color: '7C4DFF'
9797
description: '👋 Good for newcomers - great starting point for new contributors'
9898

9999
- name: help wanted
100-
color: '008672'
100+
color: '00BFA5'
101101
description: '🙏 Help wanted - seeking community input or assistance'
102102

103103
- name: priority: high
104-
color: 'FF0000'
104+
color: 'FF1744'
105105
description: '🔴 High priority - needs immediate attention'
106106

107107
- name: priority: medium
108-
color: 'FFA500'
108+
color: 'FF9100'
109109
description: '🟡 Medium priority - should be addressed soon'
110110

111111
- name: priority: low
112-
color: '00FF00'
112+
color: '69F0AE'
113113
description: '🟢 Low priority - can be deferred'
114114

115115
- name: question
116-
color: 'BA68C8'
116+
color: 'E040FB'
117117
description: '❓ Question - seeking clarification or discussion'
118118

119119
- name: wontfix
120-
color: 'E0E0E0'
120+
color: 'CFD8DC'
121121
description: '⛔ Won\'t fix - this will not be worked on'
122122

123123
- name: duplicate
124-
color: '9E9E9E'
124+
color: 'B0BEC5'
125125
description: '🔄 Duplicate - this issue or PR already exists elsewhere'
126126

127127
- name: invalid
128-
color: 'FFEB3B'
128+
color: 'FDD835'
129129
description: '❌ Invalid - not applicable or incorrect'
130130

131131
- name: stale
132-
color: 'BDBDBD'
132+
color: 'EEEEEE'
133133
description: '⏳ Stale - no recent activity, may be closed'
134134

135135
- name: blocked
136-
color: 'B71C1C'
136+
color: 'C62828'
137137
description: '🚫 Blocked - waiting on external dependency or decision'
138+
139+
# Additional workflow labels
140+
- name: chore
141+
color: '00B8D4'
142+
description: '🧹 Repository chore or maintenance work'
143+
144+
- name: feature
145+
color: 'FF6EC7'
146+
description: '🌟 New feature - adds brand new functionality (conventional commit: feat)'
147+
148+
- name: hacktoberfest-accepted
149+
color: 'FF8500'
150+
description: '🎃 Hacktoberfest accepted - auto-applied in October for contributors'

.github/workflows/pr-labeler.yml

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ jobs:
5757
5858
// Map commit types to labels
5959
const labelMap = {
60-
'feat': 'enhancement',
60+
'feat': 'feature',
6161
'fix': 'bug',
6262
'docs': 'documentation',
6363
'style': 'style',
6464
'refactor': 'refactor',
6565
'perf': 'performance',
6666
'test': 'testing',
67-
'chore': 'maintenance',
67+
'chore': 'chore',
6868
'ci': 'ci/cd',
6969
'build': 'build',
7070
'revert': 'revert',
@@ -93,16 +93,20 @@ jobs:
9393
labels: uniqueLabels
9494
});
9595
96-
// Add comment with summary
97-
const typesList = Array.from(types).filter(t => t !== 'breaking').join(', ');
98-
const breakingNote = types.has('breaking') ? '\n\n⚠️ **This PR contains breaking changes!**' : '';
96+
// Only comment when PR is first opened (not on every update)
97+
if (context.payload.action === 'opened') {
98+
const typesList = Array.from(types).filter(t => t !== 'breaking').join(', ');
99+
const breakingNote = types.has('breaking') ? '\n\n⚠️ **This PR contains breaking changes!**' : '';
99100
100-
await github.rest.issues.createComment({
101-
owner: context.repo.owner,
102-
repo: context.repo.repo,
103-
issue_number: context.issue.number,
104-
body: `🏷️ Auto-labeled based on commits: \`${typesList}\`${breakingNote}`
105-
});
101+
await github.rest.issues.createComment({
102+
owner: context.repo.owner,
103+
repo: context.repo.repo,
104+
issue_number: context.issue.number,
105+
body: `🏷️ Auto-labeled based on commits: \`${typesList}\`${breakingNote}`
106+
});
107+
} else {
108+
console.log('Labels updated (no comment on synchronize/reopened to reduce noise)');
109+
}
106110
} else {
107111
console.log('No conventional commit types found, skipping labeling');
108112
}
@@ -162,3 +166,51 @@ jobs:
162166
issue_number: context.issue.number,
163167
labels: [sizeLabel]
164168
});
169+
170+
- name: Hacktoberfest auto-accept
171+
uses: actions/github-script@v7
172+
with:
173+
github-token: ${{ secrets.GITHUB_TOKEN }}
174+
script: |
175+
// Only run during October
176+
const now = new Date();
177+
const month = now.getMonth(); // 0 = January, 9 = October
178+
179+
if (month !== 9) {
180+
console.log('Not October - skipping Hacktoberfest labeling');
181+
return;
182+
}
183+
184+
// Check if PR author is a previous contributor
185+
const author = context.payload.pull_request.user.login;
186+
187+
// Get all merged PRs from this author
188+
const { data: searchResults } = await github.rest.search.issuesAndPullRequests({
189+
q: `repo:${context.repo.owner}/${context.repo.repo} author:${author} type:pr is:merged`,
190+
per_page: 1
191+
});
192+
193+
const hasPreviousContributions = searchResults.total_count > 0;
194+
195+
if (hasPreviousContributions) {
196+
console.log(`${author} is a previous contributor - adding hacktoberfest-accepted label`);
197+
198+
await github.rest.issues.addLabels({
199+
owner: context.repo.owner,
200+
repo: context.repo.repo,
201+
issue_number: context.issue.number,
202+
labels: ['hacktoberfest-accepted']
203+
});
204+
205+
// Only comment on first opened
206+
if (context.payload.action === 'opened') {
207+
await github.rest.issues.createComment({
208+
owner: context.repo.owner,
209+
repo: context.repo.repo,
210+
issue_number: context.issue.number,
211+
body: '🎃 **Happy Hacktoberfest!** Thank you for being a returning contributor. Your PR has been automatically accepted for Hacktoberfest.'
212+
});
213+
}
214+
} else {
215+
console.log(`${author} is a new contributor - manual review required for Hacktoberfest`);
216+
}

scripts/sync-labels.sh

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
#!/usr/bin/env bash
2+
# Script to sync GitHub labels from .github/labels.yml
3+
# Usage: ./scripts/sync-labels.sh
4+
5+
set -euo pipefail
6+
7+
# Colors for output
8+
RED='\033[0;31m'
9+
GREEN='\033[0;32m'
10+
YELLOW='\033[1;33m'
11+
BLUE='\033[0;34m'
12+
NC='\033[0m' # No Color
13+
14+
LABELS_FILE=".github/labels.yml"
15+
16+
# Check if gh CLI is installed
17+
if ! command -v gh &> /dev/null; then
18+
echo -e "${RED}Error: GitHub CLI (gh) is not installed${NC}"
19+
echo "Install with: brew install gh (macOS) or see https://cli.github.com"
20+
exit 1
21+
fi
22+
23+
# Check if logged in
24+
if ! gh auth status &> /dev/null; then
25+
echo -e "${RED}Error: Not logged in to GitHub CLI${NC}"
26+
echo "Run: gh auth login"
27+
exit 1
28+
fi
29+
30+
# Check if labels file exists
31+
if [[ ! -f "$LABELS_FILE" ]]; then
32+
echo -e "${RED}Error: $LABELS_FILE not found${NC}"
33+
exit 1
34+
fi
35+
36+
echo -e "${BLUE}🏷️ Syncing GitHub labels from $LABELS_FILE${NC}"
37+
echo ""
38+
39+
# Parse YAML and create/update labels
40+
# This uses a simple approach - you could also use yq for more robust parsing
41+
LABEL_NAME=""
42+
LABEL_COLOR=""
43+
LABEL_DESC=""
44+
45+
while IFS= read -r line; do
46+
# Skip comments and empty lines
47+
[[ "$line" =~ ^[[:space:]]*# ]] && continue
48+
[[ -z "${line// }" ]] && continue
49+
50+
# Parse name
51+
if [[ "$line" =~ ^-[[:space:]]*name:[[:space:]]*(.+)$ ]]; then
52+
# If we have a complete label, process it
53+
if [[ -n "$LABEL_NAME" ]]; then
54+
echo -e "${YELLOW}Processing: $LABEL_NAME${NC}"
55+
56+
# Check if label exists
57+
if gh api "repos/:owner/:repo/labels/$LABEL_NAME" &> /dev/null; then
58+
# Update existing label
59+
gh api --method PATCH "repos/:owner/:repo/labels/$LABEL_NAME" \
60+
-f color="$LABEL_COLOR" \
61+
-f description="$LABEL_DESC" \
62+
> /dev/null && \
63+
echo -e "${GREEN} ✓ Updated${NC}" || \
64+
echo -e "${RED} ✗ Failed to update${NC}"
65+
else
66+
# Create new label
67+
gh api --method POST "repos/:owner/:repo/labels" \
68+
-f name="$LABEL_NAME" \
69+
-f color="$LABEL_COLOR" \
70+
-f description="$LABEL_DESC" \
71+
> /dev/null && \
72+
echo -e "${GREEN} ✓ Created${NC}" || \
73+
echo -e "${RED} ✗ Failed to create${NC}"
74+
fi
75+
fi
76+
77+
# Extract new label name
78+
LABEL_NAME="${BASH_REMATCH[1]}"
79+
LABEL_NAME="${LABEL_NAME#"${LABEL_NAME%%[![:space:]]*}"}" # Trim leading
80+
LABEL_NAME="${LABEL_NAME%"${LABEL_NAME##*[![:space:]]}"}" # Trim trailing
81+
LABEL_COLOR=""
82+
LABEL_DESC=""
83+
fi
84+
85+
# Parse color
86+
if [[ "$line" =~ ^[[:space:]]+color:[[:space:]]*[\'\"]*([A-Fa-f0-9]+)[\'\"]*$ ]]; then
87+
LABEL_COLOR="${BASH_REMATCH[1]}"
88+
fi
89+
90+
# Parse description
91+
if [[ "$line" =~ ^[[:space:]]+description:[[:space:]]*[\'\"]*(.+)[\'\"]*$ ]]; then
92+
LABEL_DESC="${BASH_REMATCH[1]}"
93+
# Remove leading/trailing quotes
94+
LABEL_DESC="${LABEL_DESC#[\'\"]}"
95+
LABEL_DESC="${LABEL_DESC%[\'\"]}"
96+
fi
97+
done < "$LABELS_FILE"
98+
99+
# Process the last label
100+
if [[ -n "$LABEL_NAME" ]]; then
101+
echo -e "${YELLOW}Processing: $LABEL_NAME${NC}"
102+
103+
if gh api "repos/:owner/:repo/labels/$LABEL_NAME" &> /dev/null; then
104+
gh api --method PATCH "repos/:owner/:repo/labels/$LABEL_NAME" \
105+
-f color="$LABEL_COLOR" \
106+
-f description="$LABEL_DESC" \
107+
> /dev/null && \
108+
echo -e "${GREEN} ✓ Updated${NC}" || \
109+
echo -e "${RED} ✗ Failed to update${NC}"
110+
else
111+
gh api --method POST "repos/:owner/:repo/labels" \
112+
-f name="$LABEL_NAME" \
113+
-f color="$LABEL_COLOR" \
114+
-f description="$LABEL_DESC" \
115+
> /dev/null && \
116+
echo -e "${GREEN} ✓ Created${NC}" || \
117+
echo -e "${RED} ✗ Failed to create${NC}"
118+
fi
119+
fi
120+
121+
echo ""
122+
echo -e "${GREEN}✓ Label sync complete!${NC}"
123+
echo -e "${BLUE}View labels at: https://github.com/$(gh repo view --json nameWithOwner -q .nameWithOwner)/labels${NC}"

0 commit comments

Comments
 (0)