Skip to content

Commit 9e15641

Browse files
committed
feat: apply project template (release-please, Makefile, pre-commit, README format)
- Add release-please workflow with auto CHANGELOG and README What's New updates - Add Makefile with fmt/lint/build/test/check targets - Add .githooks/pre-commit mirroring CI checks - Add .editorconfig for consistent editor settings - Add release-please-config.json (rust release-type) and manifest - Add version-tag verification step to release workflow - Reformat README to template standard (centered hero, badges, em-dash style) - Fix docs/index.html title and logo from placeholder to null-e - Update .gitignore with env, PROGRESS.md, docs/dist patterns
1 parent 8abeb6c commit 9e15641

11 files changed

Lines changed: 309 additions & 380 deletions

File tree

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
charset = utf-8
7+
indent_style = space
8+
indent_size = 2
9+
trim_trailing_whitespace = true
10+
11+
[*.rs]
12+
indent_size = 4
13+
14+
[*.{toml,yaml,yml}]
15+
indent_size = 2
16+
17+
[Makefile]
18+
indent_style = tab

.githooks/pre-commit

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
# Pre-commit hook — mirrors CI checks (ci.yml)
3+
# Install: git config core.hooksPath .githooks
4+
# or: make hooks
5+
6+
set -e
7+
8+
echo "Checking format..."
9+
cargo fmt --all -- --check
10+
11+
echo "Running linter..."
12+
cargo clippy -- -D warnings
13+
14+
echo "Building..."
15+
cargo build
16+
17+
echo "Running tests..."
18+
cargo test
19+
20+
echo "All checks passed."
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Release Please
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
release-please:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
release_created: ${{ steps.release.outputs.release_created }}
16+
tag_name: ${{ steps.release.outputs.tag_name }}
17+
version: ${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}
18+
steps:
19+
- uses: googleapis/release-please-action@v4
20+
id: release
21+
with:
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
config-file: release-please-config.json
24+
manifest-file: .release-please-manifest.json
25+
26+
update-readme:
27+
needs: release-please
28+
if: needs.release-please.outputs.release_created == 'true'
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
ref: main
34+
fetch-depth: 0
35+
36+
- name: Update README What's New from CHANGELOG
37+
env:
38+
VERSION: ${{ needs.release-please.outputs.version }}
39+
run: |
40+
python3 << 'PYEOF'
41+
import os, re
42+
43+
version = os.environ["VERSION"]
44+
45+
with open("CHANGELOG.md") as f:
46+
changelog = f.read()
47+
48+
match = re.search(r'(## \[' + re.escape(version) + r'\].*?\n)(.*?)(?=\n## \[|\Z)', changelog, re.DOTALL)
49+
if not match:
50+
print(f"No changelog entry found for {version}, skipping")
51+
exit(0)
52+
53+
body = match.group(2).strip()
54+
55+
with open("README.md") as f:
56+
readme = f.read()
57+
58+
whats_new_match = re.search(r'## What\'s New\n', readme)
59+
if not whats_new_match:
60+
print("No What's New section found in README, skipping")
61+
exit(0)
62+
63+
start = whats_new_match.start()
64+
next_heading = re.search(r'\n## (?!What\'s New)', readme[start + 1:])
65+
end = start + 1 + next_heading.start() if next_heading else len(readme)
66+
67+
new_section = f"## What's New\n\n### v{version}\n\n{body}\n\nSee [CHANGELOG.md](CHANGELOG.md) for the full release history.\n\n"
68+
new_readme = readme[:start] + new_section + readme[end:]
69+
70+
with open("README.md", "w") as f:
71+
f.write(new_readme)
72+
73+
print(f"Updated README What's New to v{version}")
74+
PYEOF
75+
76+
- name: Commit and push README changes
77+
run: |
78+
git config user.name "github-actions[bot]"
79+
git config user.email "github-actions[bot]@users.noreply.github.com"
80+
git add README.md
81+
git diff --staged --quiet && echo "No changes to commit" && exit 0
82+
git commit -m "docs: update README What's New for ${{ needs.release-please.outputs.tag_name }} [skip ci]"
83+
git push

.github/workflows/release.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@ jobs:
145145
steps:
146146
- uses: actions/checkout@v4
147147
- uses: dtolnay/rust-toolchain@stable
148+
- name: Verify version matches tag
149+
run: |
150+
TAG="${GITHUB_REF#refs/tags/v}"
151+
TOML_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
152+
if [ "$TAG" != "$TOML_VERSION" ]; then
153+
echo "Tag v$TAG does not match Cargo.toml version $TOML_VERSION"
154+
exit 1
155+
fi
156+
echo "Publishing v$TAG"
148157
- name: Publish
149158
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
150159
continue-on-error: true

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Progress tracking
2+
PROGRESS.md
3+
14
# Build artifacts
25
/target/
36
debug/
@@ -14,8 +17,18 @@ release/
1417
.DS_Store
1518
Thumbs.db
1619

20+
# Environment
21+
.env
22+
.env.local
23+
.env.*.local
24+
!.env.example
25+
1726
# Cargo
1827
**/*.rs.bk
28+
*.pdb
29+
30+
# Docs
31+
docs/dist/
1932

2033
# Test artifacts
2134
*.log

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "0.2.0"
3+
}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Changelog

Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.PHONY: hooks fmt lint build test check
2+
3+
## Install git pre-commit hook
4+
hooks:
5+
@git config core.hooksPath .githooks
6+
@echo "Pre-commit hook installed."
7+
8+
## Format source code
9+
fmt:
10+
@cargo fmt --all
11+
12+
## Run linter
13+
lint:
14+
@cargo clippy -- -D warnings
15+
16+
## Build the project
17+
build:
18+
@cargo build
19+
20+
## Run tests
21+
test:
22+
@cargo test
23+
24+
## Run all checks in CI order: format → lint → build → test
25+
check: fmt lint build test

0 commit comments

Comments
 (0)