Skip to content

Commit b1ec53c

Browse files
committed
ci: Add python-semantic-release
1 parent d2abc8a commit b1ec53c

File tree

3 files changed

+85
-1
lines changed

3 files changed

+85
-1
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Semantic Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
issues: write
15+
pull-requests: write
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Setup Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: "3.11"
26+
27+
- name: Install uv and sync dev dependencies
28+
run: |
29+
pip install uv
30+
uv venv
31+
echo "VIRTUAL_ENV=$PWD/.venv" >> $GITHUB_ENV
32+
echo "$PWD/.venv/bin" >> $GITHUB_PATH
33+
uv sync --dev
34+
35+
- name: Release
36+
env:
37+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
39+
run: semantic-release publish

.releaserc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[build_command]
2+
command = "pip install build && python -m build"
3+
4+
[commit_parser]
5+
pattern = "^(?P<type>feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\((?P<scope>[^()\s]+)\))?:\s(?P<message>.+)"
6+
field_pattern = "^(?P<type>feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\((?P<scope>[^()\s]+)\))?:\s(?P<message>.+)"
7+
8+
[changelog_sections]
9+
feat = "Features"
10+
fix = "Bug Fixes"
11+
docs = "Documentation"
12+
style = "Style"
13+
refactor = "Refactor"
14+
perf = "Performance"
15+
test = "Tests"
16+
build = "Build"
17+
ci = "CI"
18+
chore = "Chores"
19+
revert = "Reverts"
20+
21+
[changelog_exclude]
22+
types = ["style", "test", "build", "ci", "chore"]
23+
24+
[changelog_section_headers]
25+
feat = "### Features"
26+
fix = "### Bug Fixes"
27+
docs = "### Documentation"
28+
refactor = "### Refactor"
29+
perf = "### Performance"
30+
revert = "### Reverts"

pyproject.toml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ dev-dependencies = [
3232

3333
# --- Security
3434
"pip-audit",
35-
"bandit"
35+
"bandit",
36+
37+
# --- Release
38+
"python-semantic-release"
3639
]
3740

3841
[tool.hatch.metadata]
@@ -62,3 +65,15 @@ msg-template = "{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}"
6265
output-format = "colorized"
6366
reports = "no"
6467
score = "no"
68+
69+
[tool.semantic_release]
70+
version_toml = [
71+
"pyproject.toml:project.version"
72+
]
73+
branch = "main"
74+
upload_to_pypi = true
75+
upload_to_release = true
76+
build_command = "uv build"
77+
version_source = "tag"
78+
commit_version_number = true
79+
commit_message = "RELEASE: {version}"

0 commit comments

Comments
 (0)