Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python build + publish workflow #24

Merged
merged 7 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Python

on:
push:
branches:
- main
pull_request:
release:
types: [published]

jobs:
detect-packages:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.find-packages.outputs.packages }}
steps:
- uses: actions/checkout@v4

- name: Find Python packages
id: find-packages
working-directory: src
run: |
PACKAGES=$(find . -name pyproject.toml -exec dirname {} \; | sed 's/^\.\///' | jq -R -s -c 'split("\n")[:-1]')
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT

build:
needs: [detect-packages]
strategy:
matrix:
package: ${{ fromJson(needs.detect-packages.outputs.packages) }}
name: Build ${{ matrix.package }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: "src/${{ matrix.package }}/.python-version"

- name: Install dependencies
working-directory: src/${{ matrix.package }}
run: uv sync --frozen --all-extras --dev

- name: Run pyright
working-directory: src/${{ matrix.package }}
run: uv run --frozen pyright

- name: Build package
working-directory: src/${{ matrix.package }}
run: uv build

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.package }}
path: src/${{ matrix.package }}/dist/

publish:
runs-on: ubuntu-latest
needs: [build, detect-packages]
if: github.event_name == 'release'

strategy:
matrix:
package: ${{ fromJson(needs.detect-packages.outputs.packages) }}
name: Publish ${{ matrix.package }}

environment: release
permissions:
id-token: write # Required for trusted publishing

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist-${{ matrix.package }}
path: dist/

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: TypeScript

on:
push:
branches:
Expand Down
9 changes: 6 additions & 3 deletions src/git/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
name = "mcp-git"
name = "mcp-server-git"
jspahrsummers marked this conversation as resolved.
Show resolved Hide resolved
version = "0.2.0"
description = "A Model Context Protocol server providing tools to read, search, and manipulate Git repositories programmatically via LLMs"
readme = "README.md"
Expand All @@ -23,11 +23,14 @@ dependencies = [
]

[project.scripts]
mcp-git = "mcp_git:main"
mcp-server-git = "mcp_server_git:main"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv]
dev-dependencies = ["ruff>=0.7.3"]
dev-dependencies = [
"pyright>=1.1.389",
"ruff>=0.7.3",
]
5 changes: 0 additions & 5 deletions src/git/src/mcp_git/__main__.py

This file was deleted.

File renamed without changes.
5 changes: 5 additions & 0 deletions src/git/src/mcp_server_git/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# __main__.py

from mcp_server_git import main

main()
30 changes: 28 additions & 2 deletions src/git/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions src/sqlite/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
[project]
name = "sqlite"
name = "mcp-server-sqlite"
version = "0.1.0"
description = "A simple SQLite MCP server"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
"mcp>=0.9.1",
]
dependencies = ["mcp>=0.9.1"]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv]
dev-dependencies = [
"pyright>=1.1.389",
]

[project.scripts]
sqlite = "sqlite:main"
mcp-server-sqlite = "mcp_server_sqlite:main"
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
from pathlib import Path
from mcp.server.models import InitializationOptions
import mcp.types as types
from mcp.server import NotificationOptions, Server, AnyUrl
from mcp.server import NotificationOptions, Server
import mcp.server.stdio
from pydantic import AnyUrl

# Set up logging to file
log_file = Path('mcp_server.log')
Expand Down Expand Up @@ -332,7 +333,7 @@ async def handle_call_tool(
memo = self._synthesize_memo()

# Notify clients that the memo resource has changed
await self.request_context.session.send_resource_updated("memo://insights")
await self.request_context.session.send_resource_updated(AnyUrl("memo://insights"))

return [types.TextContent(type="text", text="Insight added to memo")]
if not arguments:
Expand Down
52 changes: 41 additions & 11 deletions src/sqlite/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.