Skip to content

Commit 096190d

Browse files
8enSmithCopilot
andauthored
feat: implement semantic-release (#22)
* feat: add info wrt npm * feat: implement semantic-release with commit message validation for automated versioning and publishing (#23) * Initial plan * Initial analysis: Plan semantic-release implementation Co-authored-by: 8enSmith <798183+8enSmith@users.noreply.github.com> * feat: implement semantic-release for automated versioning and publishing Co-authored-by: 8enSmith <798183+8enSmith@users.noreply.github.com> * fix: address PR feedback - remove CHANGELOG.md from gitignore and document required secrets Co-authored-by: 8enSmith <798183+8enSmith@users.noreply.github.com> * docs: enhance commit message format documentation and add validation - Expanded README with detailed conventional commit format explanation - Added @commitlint/cli and @commitlint/config-conventional for validation - Created commitlint.config.cjs with strict conventional commit rules - Added commit-msg hook to automatically validate commit messages - Added commitlint script to package.json for manual validation - Documented importance of commit format for semantic versioning Co-authored-by: 8enSmith <798183+8enSmith@users.noreply.github.com> * feat: add semantic-release dry-run script --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: 8enSmith <798183+8enSmith@users.noreply.github.com>
1 parent b5d4327 commit 096190d

File tree

9 files changed

+10866
-2513
lines changed

9 files changed

+10866
-2513
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches-ignore: [main]
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
cache: 'npm'
23+
24+
- name: Install dependencies
25+
run: npm ci
26+
27+
- name: Lint
28+
run: npm run lint
29+
30+
- name: Run tests
31+
run: npm run test:precommit
32+
33+
- name: Build
34+
run: npm run build

.github/workflows/release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
release:
9+
name: Release
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
cache: 'npm'
23+
24+
- name: Install dependencies
25+
run: npm ci
26+
27+
- name: Run tests
28+
run: npm run test:precommit
29+
30+
- name: Build
31+
run: npm run build
32+
33+
- name: Release
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
37+
run: npm run semantic-release

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/
2-
build/
2+
build/
3+
mcp-open-library-*.tgz

.husky/commit-msg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx --no -- commitlint --edit $1

.releaserc.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"branches": [
3+
"main"
4+
],
5+
"plugins": [
6+
"@semantic-release/commit-analyzer",
7+
"@semantic-release/release-notes-generator",
8+
"@semantic-release/changelog",
9+
"@semantic-release/npm",
10+
"@semantic-release/git",
11+
"@semantic-release/github"
12+
]
13+
}

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,73 @@ npm run inspector http://localhost:8080
254254
- `npm test` - Run the test suite
255255
- `npm run format` - Format code with Prettier
256256
- `npm run inspector` - Run the MCP Inspector against the server
257+
- `npm run semantic-release` - Run semantic release (automated in CI)
257258

258259
### Running Tests
259260

260261
```bash
261262
npm test
262263
```
263264

265+
### Releases
266+
267+
This project uses [semantic-release](https://semantic-release.gitbook.io/) for automated versioning and publishing. Releases are automatically created when commits are pushed to the `main` branch using [conventional commit messages](https://www.conventionalcommits.org/).
268+
269+
#### Required Secrets
270+
271+
For the automated release workflow to function, the following secrets must be configured in the GitHub repository:
272+
273+
- `GITHUB_TOKEN` - Automatically provided by GitHub Actions for creating releases and updating the repository
274+
- `NPM_TOKEN` - Required for publishing packages to npm. Generate this token from your npm account with publish permissions
275+
276+
#### Commit Message Format
277+
278+
**⚠️ Important:** This project uses automated semantic versioning. The commit message format directly determines version bumps and changelog generation.
279+
280+
The project follows the [Conventional Commits](https://www.conventionalcommits.org/) specification. Each commit message must be structured as:
281+
282+
```
283+
<type>[optional scope]: <description>
284+
285+
[optional body]
286+
287+
[optional footer(s)]
288+
```
289+
290+
**Supported commit types:**
291+
- `feat:` - new features (triggers **minor** version bump: 1.0.0 → 1.1.0)
292+
- `fix:` - bug fixes (triggers **patch** version bump: 1.0.0 → 1.0.1)
293+
- `feat!:` or `fix!:` - breaking changes (triggers **major** version bump: 1.0.0 → 2.0.0)
294+
- `docs:`, `style:`, `refactor:`, `test:`, `chore:` - maintenance (no version bump)
295+
296+
**Examples:**
297+
```
298+
feat: add new search functionality
299+
fix: resolve timeout issue in API calls
300+
feat!: remove deprecated getBook method
301+
docs: update API documentation
302+
```
303+
304+
**Why this matters:**
305+
- ✅ Proper format → Automatic version bump and release
306+
- ❌ Wrong format → No release, manual intervention required
307+
- 📝 Commit messages become the public changelog
308+
309+
The project validates commit messages automatically to ensure releases work correctly.
310+
311+
#### Development Workflow
312+
313+
The project includes automatic validation to ensure proper commit message format:
314+
315+
- **Pre-commit hooks** validate code quality with linting and tests
316+
- **Commit message validation** ensures conventional commit format using [commitlint](https://commitlint.js.org/)
317+
- **Invalid commit messages** are rejected before they reach the repository
318+
319+
To manually validate a commit message:
320+
```bash
321+
npm run commitlint
322+
```
323+
264324
## Contributing
265325

266326
Contributions are welcome! Please feel free to submit a pull request.

commitlint.config.cjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
rules: {
4+
'type-enum': [
5+
2,
6+
'always',
7+
[
8+
'feat',
9+
'fix',
10+
'docs',
11+
'style',
12+
'refactor',
13+
'test',
14+
'chore',
15+
'revert'
16+
]
17+
],
18+
'subject-case': [2, 'never', ['start-case', 'pascal-case', 'upper-case']],
19+
'subject-empty': [2, 'never'],
20+
'subject-full-stop': [2, 'never', '.'],
21+
'header-max-length': [2, 'always', 72]
22+
}
23+
};

0 commit comments

Comments
 (0)