ci: add cocogitto for conventional commits and automated releases

- Add cog.toml with commit type configs and version bump hooks
- Add .woodpecker.yml pipeline for automated version bumping on main
- Add Version element to csproj for cog to update
- Document cog workflow in CLAUDE.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Barry Walker
2026-01-24 15:07:50 -05:00
parent 162033fecf
commit 7aa8fddea8
4 changed files with 133 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
when:
- event: push
branch: main
steps:
- name: release
image: alpine:latest
# Skip if this is a version bump commit (prevents infinite loop)
when:
- evaluate: 'CI_COMMIT_MESSAGE not contains "chore(release):"'
commands:
# Install dependencies
- apk add --no-cache git curl perl
# Install Cocogitto
- curl -sSL https://github.com/cocogitto/cocogitto/releases/latest/download/cocogitto-6.5.0-x86_64-unknown-linux-musl.tar.gz | tar xz
- mv cog /usr/local/bin/
- cog --version
# Configure Git
- git config --global user.name "woodpecker-ci[bot]"
- git config --global user.email "woodpecker-ci[bot]@noreply.local"
- git config --global --add safe.directory "$CI_WORKSPACE"
# Fetch full history (Woodpecker does shallow clone by default)
- git fetch --unshallow --tags || git fetch --tags
# Check if there are commits to bump
- |
if cog bump --auto --dry-run 2>&1 | grep -qE "(No conventional commits|already on)"; then
echo "No version bump needed"
exit 0
fi
# Bump version
- cog bump --auto
# Push changes and tags using PAT
- git remote set-url origin "https://x-access-token:$GITHUB_TOKEN@github.com/${CI_REPO}.git"
- git push origin HEAD:main
- git push origin --tags
secrets:
- GITHUB_TOKEN
+36
View File
@@ -61,3 +61,39 @@ Tests use xUnit with FluentAssertions for assertions, NSubstitute for mocking, a
- Use [Conventional Commits](https://www.conventionalcommits.org/) - version bumps are automatic based on commit type (`fix:` = patch, `feat:` = minor, `feat!:` = major) - Use [Conventional Commits](https://www.conventionalcommits.org/) - version bumps are automatic based on commit type (`fix:` = patch, `feat:` = minor, `feat!:` = major)
- Trunk-based development: feature branches merge directly to `main` - Trunk-based development: feature branches merge directly to `main`
- All destructive operations (delete, bulk operations) require explicit `confirm=true` and default to dry-run mode - All destructive operations (delete, bulk operations) require explicit `confirm=true` and default to dry-run mode
## Versioning with Cocogitto (cog)
This repo uses [Cocogitto](https://docs.cocogitto.io/) for conventional commit enforcement and version management.
**Git hook:** A `commit-msg` hook enforces conventional commits. Install it after cloning:
```bash
cog install-hook commit-msg
```
**Commit format:**
```
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
```
Types: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert`
**Version bumping:**
```bash
cog bump --auto # Auto-detect bump type from commits
cog bump --patch # Bump patch version (0.1.12 -> 0.1.13)
cog bump --minor # Bump minor version (0.1.12 -> 0.2.0)
cog bump --major # Bump major version (0.1.12 -> 1.0.0)
cog bump --dry-run # Preview what would happen
```
**Other useful commands:**
```bash
cog check # Verify all commits follow conventional format
cog changelog # Generate changelog
cog get-version # Show current version
```
+1
View File
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<Version>0.1.12</Version>
<TargetFramework>net10.0</TargetFramework> <TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
+53
View File
@@ -0,0 +1,53 @@
# Cocogitto configuration
# https://docs.cocogitto.io/
from_latest_tag = true
tag_prefix = "v"
branch_whitelist = ["main"]
skip_ci = "[skip ci]"
skip_untracked = false
ignore_merge_commits = true
disable_changelog = false
disable_bump_commit = false
# Pre-bump hooks run before the version is bumped
pre_bump_hooks = []
# Post-bump hooks run after version bump but before commit
# Updates the Version element in the .csproj file
# Uses perl for cross-platform compatibility (macOS sed differs from GNU sed)
# Regex anchors to line start to avoid replacing PackageReference versions
post_bump_hooks = [
"perl -i -pe 's/^(\\s*)<Version>.*<\\/Version>/$1<Version>{{version}}<\\/Version>/' PaperlessMCP/PaperlessMCP.csproj",
]
# Git hooks configuration
# Validates commit messages follow conventional commit format
[git_hooks.commit-msg]
script = """#!/bin/sh
set -e
cog verify --file $1
"""
# Changelog configuration
[changelog]
path = "CHANGELOG.md"
template = "remote"
remote = "github.com"
repository = "PaperlessMCP"
owner = "barryw"
# Commit type configurations
# Types that bump versions are marked accordingly
[commit_types]
feat = { changelog_title = "Features", bump_minor = true }
fix = { changelog_title = "Bug Fixes", bump_patch = true }
docs = { changelog_title = "Documentation" }
style = { changelog_title = "Styling" }
refactor = { changelog_title = "Refactoring" }
perf = { changelog_title = "Performance", bump_patch = true }
test = { changelog_title = "Tests" }
build = { changelog_title = "Build" }
ci = { changelog_title = "CI/CD" }
chore = { changelog_title = "Chores" }
revert = { changelog_title = "Reverts", bump_patch = true }