Skip to content

Commit e9225c8

Browse files
author
LittleCoinCoin
committed
cicd: migrate to semantic-release
Adopt semantic-release for automated versioning. All future commits must follow Conventional Commits format. - Add semantic-release configuration and workflows - Add commitizen for guided commit messages - Add commitlint for PR validation - Update documentation for new workflow - Update repository URLs to CrackingShells organization This enables fully automated versioning and releases for the validation library.
1 parent ee44530 commit e9225c8

File tree

9 files changed

+9257
-2
lines changed

9 files changed

+9257
-2
lines changed

.commitlintrc.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"extends": ["@commitlint/config-conventional"],
3+
"rules": {
4+
"type-enum": [
5+
2,
6+
"always",
7+
[
8+
"build",
9+
"chore",
10+
"ci",
11+
"docs",
12+
"feat",
13+
"fix",
14+
"perf",
15+
"refactor",
16+
"revert",
17+
"style",
18+
"test"
19+
]
20+
],
21+
"subject-case": [2, "never", ["start-case", "pascal-case", "upper-case"]],
22+
"subject-empty": [2, "never"],
23+
"subject-full-stop": [2, "never", "."],
24+
"header-max-length": [2, "always", 72],
25+
"body-max-line-length": [2, "always", 500]
26+
}
27+
}

.github/workflows/commitlint.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Commit Lint
2+
3+
on:
4+
pull_request:
5+
branches: [main, dev]
6+
7+
jobs:
8+
commitlint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: "lts/*"
20+
21+
- name: Install dependencies
22+
run: npm ci
23+
24+
- name: Validate PR commits with commitlint
25+
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Semantic Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Setup Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.12'
22+
23+
- name: Install Python dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install -e .
27+
28+
- name: Run tests
29+
run: |
30+
python -c "import hatch_validator; print('Package imports successfully')"
31+
32+
release:
33+
needs: test
34+
runs-on: ubuntu-latest
35+
if: github.event_name == 'push'
36+
steps:
37+
- name: Generate GitHub App Token
38+
id: generate_token
39+
uses: tibdex/github-app-token@v2
40+
with:
41+
app_id: ${{ secrets.SEMANTIC_RELEASE_APP_ID }}
42+
private_key: ${{ secrets.SEMANTIC_RELEASE_PRIVATE_KEY }}
43+
44+
- name: Checkout
45+
uses: actions/checkout@v4
46+
with:
47+
fetch-depth: 0
48+
token: ${{ steps.generate_token.outputs.token }}
49+
50+
- name: Setup Node.js
51+
uses: actions/setup-node@v4
52+
with:
53+
node-version: "lts/*"
54+
55+
- name: Install Node dependencies
56+
run: npm ci
57+
58+
- name: Verify npm audit
59+
run: npm audit signatures
60+
61+
- name: Release
62+
env:
63+
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
64+
run: npx semantic-release

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,12 @@ cython_debug/
172172

173173
# PyPI configuration file
174174
.pypirc
175+
176+
# Node.js dependencies for semantic-release
177+
node_modules/
178+
npm-debug.log*
179+
yarn-debug.log*
180+
yarn-error.log*
181+
182+
# Semantic-release
183+
.semantic-release/

.releaserc.json

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"repositoryUrl": "https://github.com/CrackingShells/Hatch-Validator",
3+
"tagFormat": "v${version}",
4+
"branches": [
5+
"main",
6+
{
7+
"name": "dev",
8+
"prerelease": "dev"
9+
}
10+
],
11+
"plugins": [
12+
[
13+
"@semantic-release/commit-analyzer",
14+
{
15+
"preset": "conventionalcommits",
16+
"releaseRules": [
17+
{"type": "docs", "scope": "README", "release": "patch"},
18+
{"type": "refactor", "release": "patch"},
19+
{"type": "style", "release": "patch"},
20+
{"type": "test", "release": false},
21+
{"type": "chore", "release": false}
22+
]
23+
}
24+
],
25+
[
26+
"@semantic-release/release-notes-generator",
27+
{
28+
"preset": "conventionalcommits",
29+
"presetConfig": {
30+
"types": [
31+
{"type": "feat", "section": "Features"},
32+
{"type": "fix", "section": "Bug Fixes"},
33+
{"type": "docs", "section": "Documentation"},
34+
{"type": "refactor", "section": "Code Refactoring"},
35+
{"type": "perf", "section": "Performance Improvements"}
36+
]
37+
}
38+
}
39+
],
40+
[
41+
"@semantic-release/changelog",
42+
{
43+
"changelogFile": "CHANGELOG.md"
44+
}
45+
],
46+
[
47+
"@semantic-release/git",
48+
{
49+
"assets": ["CHANGELOG.md", "pyproject.toml"],
50+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
51+
}
52+
],
53+
[
54+
"@semantic-release/github",
55+
{
56+
"successComment": false,
57+
"failComment": false,
58+
"releasedLabels": false
59+
}
60+
]
61+
]
62+
}

0 commit comments

Comments
 (0)