Skip to content

[major-architecture-refactor] Bump version to 0.3.0 #7

[major-architecture-refactor] Bump version to 0.3.0

[major-architecture-refactor] Bump version to 0.3.0 #7

Workflow file for this run

name: Build, Publish and Release
on:
push:
tags:
- 'v*.*.*' # Run when a version tag is pushed
workflow_dispatch:
inputs:
release_type:
description: 'Type of release to create'
required: true
default: 'auto'
type: 'choice'
options:
- 'auto' # Auto-detect version from source files
- 'prerelease'
- 'release'
permissions:
contents: write # Needed for creating releases
jobs:
extract-version:
name: Extract Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract version from pyproject.toml
id: get-version
run: |
VERSION=$(grep -E '^version\s*=\s*"[^"]+"' pyproject.toml | sed -E 's/^version\s*=\s*"([^"]+)".*/\1/')
echo "Detected version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
build-and-publish:
name: Build and Publish Packages
needs: extract-version
runs-on: ubuntu-latest
environment:
name: pypi
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
# Build and publish main package
- name: Build main package
run: python -m build .
- name: Publish main package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: dist/
# Build and publish CLI package
- name: Build CLI package
run: |
cd cli-package
python -m build .
- name: Publish CLI package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: cli-package/dist/
create-release:
name: Create GitHub Release
needs: [extract-version, build-and-publish]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine release type
id: release-type
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.release_type }}" != "auto" ]]; then
echo "type=${{ github.event.inputs.release_type }}" >> $GITHUB_OUTPUT
else
# Default to non-prerelease
echo "type=release" >> $GITHUB_OUTPUT
fi
# Create tag if it doesn't exist (mainly for manual workflow runs)
- name: Create tag if needed
run: |
VERSION="${{ needs.extract-version.outputs.version }}"
if ! git rev-parse "v$VERSION" >/dev/null 2>&1; then
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git tag -a "v$VERSION" -m "Version $VERSION"
git push origin "v$VERSION"
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: "v${{ needs.extract-version.outputs.version }}"
name: "Release v${{ needs.extract-version.outputs.version }}"
draft: false
prerelease: ${{ steps.release-type.outputs.type == 'prerelease' }}
body: |
# Release v${{ needs.extract-version.outputs.version }}
## Packages
- Main package: [mcp-client-for-ollama ${{ needs.extract-version.outputs.version }}](https://pypi.org/project/mcp-client-for-ollama/${{ needs.extract-version.outputs.version }}/)
- CLI package: [ollmcp ${{ needs.extract-version.outputs.version }}](https://pypi.org/project/ollmcp/${{ needs.extract-version.outputs.version }}/)
## Installation
```bash
pip install mcp-client-for-ollama==${{ needs.extract-version.outputs.version }}
# or
pip install ollmcp==${{ needs.extract-version.outputs.version }}
```