Skip to content
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
63 changes: 33 additions & 30 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
name: Release
name: Publish to PyPI

on:
push:
branches:
- main

jobs:
release:
publish:
runs-on: ubuntu-latest
concurrency: release
permissions:
contents: write # For creating commits and tags
id-token: write # For PyPI trusted publishing
contents: write
id-token: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v5
Expand All @@ -28,41 +26,46 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install python-semantic-release build
pip install build

- name: Configure git
- name: Get version from pyproject.toml
id: get_version
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"

- name: Run Semantic Release
id: release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check if tag exists
id: check_tag
run: |
semantic-release version --no-push --no-commit --print > new_version.txt || true
NEW_VERSION=$(cat new_version.txt)
if [ -n "$NEW_VERSION" ]; then
echo "new_release=true" >> $GITHUB_OUTPUT
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "New version will be: $NEW_VERSION"
semantic-release version
if git rev-parse "v${{ steps.get_version.outputs.version }}" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Tag v${{ steps.get_version.outputs.version }} already exists, skipping publish"
else
echo "new_release=false" >> $GITHUB_OUTPUT
echo "No release needed"
echo "exists=false" >> $GITHUB_OUTPUT
echo "Tag v${{ steps.get_version.outputs.version }} does not exist, will publish"
fi

- name: Build package
if: steps.release.outputs.new_release == 'true'
if: steps.check_tag.outputs.exists == 'false'
run: python -m build

- name: Publish to PyPI
if: steps.release.outputs.new_release == 'true'
if: steps.check_tag.outputs.exists == 'false'
uses: pypa/gh-action-pypi-publish@release/v1

- name: Create GitHub Release
if: steps.release.outputs.new_release == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create git tag
if: steps.check_tag.outputs.exists == 'false'
run: |
semantic-release publish
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ steps.get_version.outputs.version }}" -m "Release v${{ steps.get_version.outputs.version }}"
git push origin "v${{ steps.get_version.outputs.version }}"

- name: Create GitHub Release
if: steps.check_tag.outputs.exists == 'false'
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.get_version.outputs.version }}
name: Release v${{ steps.get_version.outputs.version }}
generate_release_notes: true
17 changes: 0 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,3 @@ build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["src/project_context_mcp"]

[tool.semantic_release]
version_toml = ["pyproject.toml:project.version"]
version_variables = ["src/project_context_mcp/__init__.py:__version__"]
branch = "main"
upload_to_pypi = false # We handle this separately with trusted publishing
build_command = "pip install build && python -m build"
commit_message = "chore(release): {version} [skip ci]"

[tool.semantic_release.branches.main]
match = "main"
prerelease = false

[tool.semantic_release.commit_parser_options]
allowed_tags = ["build", "chore", "ci", "docs", "feat", "fix", "perf", "refactor", "style", "test"]
minor_tags = ["feat"]
patch_tags = ["fix", "perf"]
28 changes: 28 additions & 0 deletions scripts/bump-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# Usage: ./scripts/bump-version.sh 0.2.0

set -e

if [ -z "$1" ]; then
echo "Usage: $0 <new-version>"
echo "Example: $0 0.2.0"
exit 1
fi

NEW_VERSION=$1

# Update pyproject.toml
sed -i.bak "s/^version = \".*\"/version = \"$NEW_VERSION\"/" pyproject.toml && rm pyproject.toml.bak

# Update __init__.py
sed -i.bak "s/__version__ = \".*\"/__version__ = \"$NEW_VERSION\"/" src/project_context_mcp/__init__.py && rm src/project_context_mcp/__init__.py.bak

echo "Version bumped to $NEW_VERSION"
echo ""
echo "Files updated:"
echo " - pyproject.toml"
echo " - src/project_context_mcp/__init__.py"
echo ""
echo "Next steps:"
echo " 1. git add -A && git commit -m 'Bump version to $NEW_VERSION'"
echo " 2. Merge to main (GitHub Action will publish to PyPI)"