Skip to content

Commit

Permalink
Lint changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
kui committed Dec 8, 2023
1 parent 8e20b8c commit 49425ab
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ lint: node_modules
npx prettier . --check
npx tsc --project src --noEmit
hadolint Dockerfile
./scripts/lint_changelog.bash

.PHONY: fix
fix: node_modules
Expand Down
31 changes: 31 additions & 0 deletions scripts/lint_changelog.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

set -euo pipefail

cd "$(dirname "$0")/.."

main() {
has_current_version_chengelog
for file in changelog/*.md; do
should_start_with_version_header "$file"
done
}

has_current_version_chengelog() {
local v="$(node -e 'console.log(require("./package.json").version)')"
if ! [[ -f "changelog/$v.md" ]]; then
echo "changelog/$v.md does not exist"
exit 1
fi
}

should_start_with_version_header() {
local file="$1"
local v=$(basename "$file" .md)
if head -n1 "$file" | grep -vq "^# Version $v$"; then
echo "changelog/$v.md does not start with the correct version header"
exit 1
fi
}

main

0 comments on commit 49425ab

Please sign in to comment.