Skip to content

Commit 3155c9b

Browse files
feat(changelog): add git-cliff changelog target and init scaffolding
Sync Makefile with dev-toolchain: add `make changelog` / `_changelog` target, git-cliff to tool-versions report, cliff.toml to `make init`. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4b5758e commit 3155c9b

2 files changed

Lines changed: 43 additions & 2 deletions

File tree

DEVELOPMENT.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ Every DevRail-managed repo exposes these public targets:
5252
| `make security` | Run security scanners (bandit, tfsec, checkov, etc.) |
5353
| `make scan` | Run universal scanners (trivy, gitleaks) |
5454
| `make docs` | Generate documentation (terraform-docs, tool version report) |
55+
| `make changelog` | Generate CHANGELOG.md from conventional commits (git-cliff) |
5556
| `make check` | Run all of the above in sequence |
5657
| `make install-hooks` | Install pre-commit hooks |
58+
| `make init` | Scaffold config files for declared languages |
5759

5860
### Naming Rules
5961

@@ -273,6 +275,7 @@ type(scope): description
273275
| `container` | Dev-toolchain container image |
274276
| `ci` | CI/CD pipeline configuration |
275277
| `makefile` | Makefile targets and patterns |
278+
| `changelog` | Changelog generation and git-cliff config |
276279
| `standards` | DevRail standards documentation |
277280

278281
### Code Comments

Makefile

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ HAS_JAVASCRIPT := $(filter javascript,$(LANGUAGES))
4444
# ---------------------------------------------------------------------------
4545
# .PHONY declarations
4646
# ---------------------------------------------------------------------------
47-
.PHONY: help lint format test security scan docs check install-hooks init
48-
.PHONY: _lint _format _test _security _scan _docs _check _check-config _init
47+
.PHONY: help lint format test security scan docs changelog check install-hooks init
48+
.PHONY: _lint _format _test _security _scan _docs _changelog _check _check-config _init
4949

5050
# ===========================================================================
5151
# Public targets (run on host, delegate to Docker container)
@@ -57,6 +57,9 @@ help: ## Show this help
5757
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
5858
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
5959

60+
changelog: ## Generate CHANGELOG.md from conventional commits
61+
$(DOCKER_RUN) make _changelog
62+
6063
check: ## Run all checks (lint, format, test, security, scan, docs)
6164
$(DOCKER_RUN) make _check
6265

@@ -704,6 +707,7 @@ _docs: _check-config
704707
fi; \
705708
_tv trivy "trivy --version"; \
706709
_tv gitleaks "gitleaks version"; \
710+
_tv git-cliff "git-cliff --version"; \
707711
printf '}}\n'; \
708712
} > .devrail-output/tool-versions.json; \
709713
generators="$${generators}\"tool-versions\","; \
@@ -716,6 +720,34 @@ _docs: _check-config
716720
fi; \
717721
exit $$overall_exit
718722

723+
# --- _changelog: generate CHANGELOG.md from conventional commits ---
724+
_changelog: _check-config
725+
@start_time=$$(date +%s%3N); \
726+
config=""; \
727+
if [ -f "cliff.toml" ]; then \
728+
config="cliff.toml"; \
729+
elif [ -f "/opt/devrail/config/cliff.toml" ]; then \
730+
config="/opt/devrail/config/cliff.toml"; \
731+
fi; \
732+
if [ -z "$$config" ]; then \
733+
echo '{"target":"changelog","status":"error","error":"no cliff.toml found","exit_code":2}'; \
734+
exit 2; \
735+
fi; \
736+
if ! git rev-parse --git-dir >/dev/null 2>&1; then \
737+
echo '{"target":"changelog","status":"error","error":"not a git repository","exit_code":2}'; \
738+
exit 2; \
739+
fi; \
740+
git-cliff --config "$$config" --output CHANGELOG.md; \
741+
cl_exit=$$?; \
742+
end_time=$$(date +%s%3N); \
743+
duration=$$((end_time - start_time)); \
744+
if [ $$cl_exit -eq 0 ]; then \
745+
echo "{\"target\":\"changelog\",\"status\":\"pass\",\"duration_ms\":$$duration,\"config\":\"$$config\",\"output\":\"CHANGELOG.md\"}"; \
746+
else \
747+
echo "{\"target\":\"changelog\",\"status\":\"fail\",\"duration_ms\":$$duration,\"config\":\"$$config\",\"exit_code\":$$cl_exit}"; \
748+
exit $$cl_exit; \
749+
fi
750+
719751
# --- _init: scaffold config files for declared languages ---
720752
_init: _check-config
721753
@created=""; \
@@ -748,6 +780,12 @@ _init: _check-config
748780
'' \
749781
'[*.sh]' \
750782
'indent_size = 2'; \
783+
if [ -f "/opt/devrail/config/cliff.toml" ] && [ ! -f "cliff.toml" ]; then \
784+
cp /opt/devrail/config/cliff.toml cliff.toml; \
785+
created="$${created}\"cliff.toml\","; \
786+
elif [ -f "cliff.toml" ]; then \
787+
skipped="$${skipped}\"cliff.toml\","; \
788+
fi; \
751789
if [ -n "$(HAS_PYTHON)" ]; then \
752790
scaffold ruff.toml \
753791
'line-length = 120' \

0 commit comments

Comments
 (0)