Skip to content

Commit 52403b2

Browse files
committed
chore: introduce semantic versioning
1 parent 2550577 commit 52403b2

File tree

5 files changed

+214
-32
lines changed

5 files changed

+214
-32
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Semantic Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
issues: write
11+
pull-requests: write
12+
id-token: write # Required for PyPI trusted publishing
13+
14+
jobs:
15+
test:
16+
uses: ./.github/workflows/test.yml
17+
18+
release:
19+
name: Release
20+
needs: test
21+
runs-on: ubuntu-latest
22+
environment:
23+
name: pypi
24+
url: https://pypi.org/p/mcpm
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
persist-credentials: false
32+
token: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Setup Node.js
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: 'lts/*'
38+
39+
- name: Install semantic-release dependencies
40+
run: |
41+
npm install -g semantic-release @semantic-release/git @semantic-release/github @semantic-release/changelog @semantic-release/commit-analyzer @semantic-release/release-notes-generator @semantic-release/exec
42+
43+
- name: Semantic Release
44+
id: semantic
45+
uses: cycjimmy/semantic-release-action@v4
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
49+
- name: Install uv with caching
50+
if: steps.semantic.outputs.new_release_published == 'true'
51+
uses: astral-sh/setup-uv@v5
52+
with:
53+
enable-cache: true
54+
cache-dependency-glob: "pyproject.toml"
55+
56+
- name: Build
57+
if: steps.semantic.outputs.new_release_published == 'true'
58+
run: uv build
59+
60+
- name: Publish distribution to PyPI
61+
if: steps.semantic.outputs.new_release_published == 'true'
62+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/semver-check.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Semantic Version Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
jobs:
8+
semver-check:
9+
name: Validate Semantic Version
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
pull-requests: write
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
persist-credentials: false
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 'lts/*'
26+
27+
- name: Install dependencies
28+
run: |
29+
npm install -g semantic-release @semantic-release/git @semantic-release/github @semantic-release/changelog @semantic-release/commit-analyzer @semantic-release/release-notes-generator @semantic-release/exec
30+
31+
- name: Check Release
32+
uses: cycjimmy/semantic-release-action@v4
33+
with:
34+
dry_run: true
35+
ci: false
36+
unset_gha_env: true
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Comment PR
41+
if: always()
42+
uses: actions/github-script@v7
43+
with:
44+
script: |
45+
const semanticResult = process.env.SEMANTIC_OUTPUT;
46+
let comment = '## Semantic Version Check\n\n';
47+
48+
if (semanticResult && semanticResult.includes('The next release version is')) {
49+
const versionMatch = semanticResult.match(/The next release version is (.*)/);
50+
if (versionMatch) {
51+
comment += `✅ Valid semantic version changes detected!\n\n`;
52+
comment += `Next version will be: **${versionMatch[1]}**\n`;
53+
}
54+
} else {
55+
comment += `⚠️ No semantic version changes detected.\n\n`;
56+
comment += 'Please ensure your commits follow the [Conventional Commits](https://www.conventionalcommits.org/) format:\n\n';
57+
comment += '- `feat: new feature` (triggers MINOR version bump)\n';
58+
comment += '- `fix: bug fix` (triggers PATCH version bump)\n';
59+
comment += '- `BREAKING CHANGE: description` (triggers MAJOR version bump)\n';
60+
}
61+
62+
github.rest.issues.createComment({
63+
issue_number: context.issue.number,
64+
owner: context.repo.owner,
65+
repo: context.repo.repo,
66+
body: comment
67+
});

.github/workflows/test.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Test & Validate
2+
3+
on:
4+
pull_request:
5+
workflow_call:
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
validate-manifests:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Validate Server JSON Files
19+
uses: cardinalby/schema-validator-action@v3
20+
with:
21+
file: 'mcp-registry/servers/*.json'
22+
schema: 'mcp-registry/schema/server-schema.json'
23+
mode: 'default'
24+
fixSchemas: 'false'
25+
26+
test:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
- name: Set up Python
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: '3.10'
34+
- name: Install uv
35+
uses: astral-sh/setup-uv@v5
36+
with:
37+
enable-cache: true
38+
- name: Run tests
39+
run: |
40+
uv sync --group dev
41+
uv run pytest
42+
43+
lint:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v4
47+
- name: Set up Python
48+
uses: actions/setup-python@v5
49+
with:
50+
python-version: '3.10'
51+
- name: Install uv
52+
uses: astral-sh/setup-uv@v5
53+
with:
54+
enable-cache: true
55+
- name: Check code style with ruff
56+
run: |
57+
uv sync --group dev
58+
uv run ruff check src/ tests/

.releaserc.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"branches": [
3+
"main",
4+
"master"
5+
],
6+
"plugins": [
7+
"@semantic-release/commit-analyzer",
8+
"@semantic-release/release-notes-generator",
9+
"@semantic-release/changelog",
10+
[
11+
"@semantic-release/exec",
12+
{
13+
"prepareCmd": "echo '__version__ = \"${nextRelease.version}\"' > src/mcpm/version.py"
14+
}
15+
],
16+
[
17+
"@semantic-release/git",
18+
{
19+
"assets": [
20+
"CHANGELOG.md",
21+
"src/mcpm/version.py"
22+
],
23+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
24+
}
25+
]
26+
]
27+
}

0 commit comments

Comments
 (0)