Skip to content

Commit 20d93f8

Browse files
authored
chore(versioning): Add semantic versioning CI action (#3)
* chore(versioning): Add semantic versioning CI action * chore(versioning): Add labels worflow and badge updates * chore(versioning): Fix dependabot and add label descriptions * chore(versioning): Add aditional labels and sync * chore(versioning): Check for labels to prevent re-labeling
1 parent 57fada7 commit 20d93f8

File tree

13 files changed

+1596
-53
lines changed

13 files changed

+1596
-53
lines changed

.github/dependabot.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ updates:
55
directory: "/"
66
schedule:
77
interval: "monthly"
8+
open-pull-requests-limit: 5
89
labels:
910
- "dependencies"
10-
- "github-actions"
11+
- "ci/cd"
12+
commit-message:
13+
prefix: "chore(deps)"
14+
include: "scope"

.github/labels.yml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# GitHub Labels Configuration
2+
# These labels are used by the PR auto-labeler workflow
3+
#
4+
# To sync these labels with your repository, you can use:
5+
# https://github.com/EndBug/label-sync
6+
# or create them manually in GitHub UI
7+
#
8+
# Color scheme:
9+
# - Blue/Purple: New features and enhancements
10+
# - Red/Orange: Bugs and breaking changes
11+
# - Teal/Cyan: Documentation and testing
12+
# - Yellow: Refactoring and caution
13+
# - Green: CI/CD and automation
14+
# - Gray: Infrastructure and builds
15+
16+
# Type labels (based on conventional commits)
17+
- name: enhancement
18+
color: 'A28EFF'
19+
description: '✨ Enhancement - improves existing functionality'
20+
21+
- name: bug
22+
color: 'FF1744'
23+
description: '🐛 Bug fix - resolves an issue or error (conventional commit: fix)'
24+
25+
- name: documentation
26+
color: '00E5FF'
27+
description: '📚 Documentation improvements - updates docs, comments, or guides (conventional commit: docs)'
28+
29+
- name: style
30+
color: 'FF4081'
31+
description: '💅 Code style changes - formatting, whitespace, missing semicolons (conventional commit: style)'
32+
33+
- name: refactor
34+
color: 'FFEA00'
35+
description: '♻️ Code refactoring - restructuring without changing behavior (conventional commit: refactor)'
36+
37+
- name: performance
38+
color: 'AA00FF'
39+
description: '⚡ Performance improvements - optimizations and speed enhancements (conventional commit: perf)'
40+
41+
- name: testing
42+
color: '00E676'
43+
description: '🧪 Test updates - adding or updating tests (conventional commit: test)'
44+
45+
- name: maintenance
46+
color: 'FFB300'
47+
description: '🔧 Maintenance tasks - routine upkeep and housekeeping (conventional commit: chore)'
48+
49+
- name: ci/cd
50+
color: '00C853'
51+
description: '🚀 CI/CD changes - workflow automation and deployment (conventional commit: ci)'
52+
53+
- name: build
54+
color: '9E9E9E'
55+
description: '🏗️ Build system changes - build tools, dependencies, config (conventional commit: build)'
56+
57+
- name: revert
58+
color: '78909C'
59+
description: '⏪ Revert changes - undoing previous commits (conventional commit: revert)'
60+
61+
- name: breaking change
62+
color: 'FF3D00'
63+
description: '💥 BREAKING CHANGE - incompatible API changes requiring major version bump'
64+
65+
# Size labels (auto-added based on PR size)
66+
- name: size/XS
67+
color: '00E676'
68+
description: '🐭 Extra small change - less than 10 lines modified'
69+
70+
- name: size/S
71+
color: '76FF03'
72+
description: '🐿️ Small change - less than 50 lines modified'
73+
74+
- name: size/M
75+
color: 'FDD835'
76+
description: '🐕 Medium change - less than 200 lines modified'
77+
78+
- name: size/L
79+
color: 'FF6D00'
80+
description: '🐘 Large change - less than 500 lines modified'
81+
82+
- name: size/XL
83+
color: 'D50000'
84+
description: '🦖 Extra large change - 500+ lines modified, consider splitting'
85+
86+
# Additional useful labels
87+
- name: dependencies
88+
color: '2196F3'
89+
description: '📦 Dependency updates - library and package upgrades'
90+
91+
- name: security
92+
color: 'D50000'
93+
description: '🔒 Security fixes - patches for vulnerabilities'
94+
95+
- name: good first issue
96+
color: '7C4DFF'
97+
description: '👋 Good for newcomers - great starting point for new contributors'
98+
99+
- name: help wanted
100+
color: '00BFA5'
101+
description: '🙏 Help wanted - seeking community input or assistance'
102+
103+
- name: priority: high
104+
color: 'FF1744'
105+
description: '🔴 High priority - needs immediate attention'
106+
107+
- name: priority: medium
108+
color: 'FF9100'
109+
description: '🟡 Medium priority - should be addressed soon'
110+
111+
- name: priority: low
112+
color: '69F0AE'
113+
description: '🟢 Low priority - can be deferred'
114+
115+
- name: question
116+
color: 'E040FB'
117+
description: '❓ Question - seeking clarification or discussion'
118+
119+
- name: wontfix
120+
color: 'CFD8DC'
121+
description: '⛔ Won\'t fix - this will not be worked on'
122+
123+
- name: duplicate
124+
color: 'B0BEC5'
125+
description: '🔄 Duplicate - this issue or PR already exists elsewhere'
126+
127+
- name: invalid
128+
color: 'FDD835'
129+
description: '❌ Invalid - not applicable or incorrect'
130+
131+
- name: stale
132+
color: 'EEEEEE'
133+
description: '⏳ Stale - no recent activity, may be closed'
134+
135+
- name: blocked
136+
color: 'C62828'
137+
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/commit-lint.yml

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
name: Commit Lint
2+
3+
on:
4+
pull_request:
5+
branches: [main, develop]
6+
types: [opened, synchronize, reopened, edited]
7+
8+
permissions:
9+
contents: read
10+
pull-requests: read
11+
12+
jobs:
13+
lint-commits:
14+
name: Validate Commit Messages
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Harden Runner
19+
uses: step-security/harden-runner@v2
20+
with:
21+
egress-policy: audit
22+
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Validate commit messages
29+
run: |
30+
# Colors for output
31+
RED='\033[0;31m'
32+
GREEN='\033[0;32m'
33+
YELLOW='\033[1;33m'
34+
BLUE='\033[0;34m'
35+
NC='\033[0m' # No Color
36+
37+
echo -e "${BLUE}Validating commit messages...${NC}"
38+
39+
# Get the base branch
40+
BASE_REF="${{ github.event.pull_request.base.sha }}"
41+
HEAD_REF="${{ github.event.pull_request.head.sha }}"
42+
43+
# Get all commits in this PR
44+
COMMITS=$(git log --pretty=format:"%H %s" "$BASE_REF".."$HEAD_REF")
45+
46+
# Conventional commit pattern
47+
# Types: build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test
48+
PATTERN="^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([a-z0-9_-]+\))?(!)?: .+"
49+
50+
INVALID_COMMITS=()
51+
VALID_COUNT=0
52+
TOTAL_COUNT=0
53+
54+
while IFS= read -r line; do
55+
[[ -z "$line" ]] && continue
56+
57+
TOTAL_COUNT=$((TOTAL_COUNT + 1))
58+
HASH=$(echo "$line" | awk '{print $1}')
59+
MESSAGE=$(echo "$line" | cut -d' ' -f2-)
60+
61+
if [[ "$MESSAGE" =~ $PATTERN ]]; then
62+
echo -e "${GREEN}✓${NC} $MESSAGE"
63+
VALID_COUNT=$((VALID_COUNT + 1))
64+
else
65+
echo -e "${RED}✗${NC} $MESSAGE"
66+
INVALID_COMMITS+=("$HASH: $MESSAGE")
67+
fi
68+
done <<< "$COMMITS"
69+
70+
echo ""
71+
echo -e "${BLUE}Summary:${NC}"
72+
echo -e " Total commits: $TOTAL_COUNT"
73+
echo -e " Valid commits: ${GREEN}$VALID_COUNT${NC}"
74+
echo -e " Invalid commits: ${RED}$((TOTAL_COUNT - VALID_COUNT))${NC}"
75+
76+
# If there are invalid commits, fail the check
77+
if [ ${#INVALID_COMMITS[@]} -gt 0 ]; then
78+
echo ""
79+
echo -e "${RED}❌ Found invalid commit messages:${NC}"
80+
echo ""
81+
for commit in "${INVALID_COMMITS[@]}"; do
82+
echo -e " ${RED}✗${NC} $commit"
83+
done
84+
echo ""
85+
echo -e "${YELLOW}Commit messages must follow the Conventional Commits specification:${NC}"
86+
echo ""
87+
echo -e " Format: ${BLUE}type(scope): description${NC}"
88+
echo ""
89+
echo -e " Types:"
90+
echo -e " ${GREEN}feat${NC} - New feature"
91+
echo -e " ${GREEN}fix${NC} - Bug fix"
92+
echo -e " ${GREEN}docs${NC} - Documentation changes"
93+
echo -e " ${GREEN}style${NC} - Code style changes (formatting, etc.)"
94+
echo -e " ${GREEN}refactor${NC} - Code refactoring"
95+
echo -e " ${GREEN}perf${NC} - Performance improvements"
96+
echo -e " ${GREEN}test${NC} - Test changes"
97+
echo -e " ${GREEN}chore${NC} - Build process or auxiliary tool changes"
98+
echo -e " ${GREEN}ci${NC} - CI configuration changes"
99+
echo -e " ${GREEN}build${NC} - Build system changes"
100+
echo -e " ${GREEN}revert${NC} - Revert a previous commit"
101+
echo ""
102+
echo -e " Examples:"
103+
echo -e " ${BLUE}feat(auth): Add login functionality${NC}"
104+
echo -e " ${BLUE}fix(api): Resolve null pointer exception${NC}"
105+
echo -e " ${BLUE}docs(readme): Update README with installation steps${NC}"
106+
echo -e " ${BLUE}feat(auth)!: Breaking change in auth flow${NC}"
107+
echo ""
108+
echo -e " For more info: ${BLUE}https://www.conventionalcommits.org${NC}"
109+
110+
# Add to step summary
111+
{
112+
echo "## ❌ Commit Message Validation Failed"
113+
echo ""
114+
echo "The following commits do not follow the Conventional Commits specification:"
115+
echo ""
116+
for commit in "${INVALID_COMMITS[@]}"; do
117+
echo "- \`$commit\`"
118+
done
119+
echo ""
120+
echo "### Required Format"
121+
echo ""
122+
echo "\`\`\`"
123+
echo "type(scope): description"
124+
echo "\`\`\`"
125+
echo ""
126+
echo "### Valid Types"
127+
echo ""
128+
echo "- \`feat\` - New feature"
129+
echo "- \`fix\` - Bug fix"
130+
echo "- \`docs\` - Documentation changes"
131+
echo "- \`style\` - Code style changes"
132+
echo "- \`refactor\` - Code refactoring"
133+
echo "- \`perf\` - Performance improvements"
134+
echo "- \`test\` - Test changes"
135+
echo "- \`chore\` - Maintenance tasks"
136+
echo "- \`ci\` - CI changes"
137+
echo "- \`build\` - Build system changes"
138+
echo ""
139+
echo "### Examples"
140+
echo ""
141+
echo "- \`feat(auth): Add login functionality\`"
142+
echo "- \`fix(api): Resolve null pointer exception\`"
143+
echo "- \`docs(readme): Update README\`"
144+
echo ""
145+
echo "Learn more: [Conventional Commits](https://www.conventionalcommits.org)"
146+
} >> $GITHUB_STEP_SUMMARY
147+
148+
exit 1
149+
fi
150+
151+
echo ""
152+
echo -e "${GREEN}✓ All commit messages are valid${NC}"
153+
154+
# Add success to step summary
155+
{
156+
echo "## ✅ Commit Message Validation Passed"
157+
echo ""
158+
echo "All $VALID_COUNT commit(s) follow the Conventional Commits specification."
159+
} >> $GITHUB_STEP_SUMMARY
160+
161+
exit 0

0 commit comments

Comments
 (0)