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
57 changes: 49 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@ name: Test and Publish
on:
push:
branches: [ main ]
paths-ignore:
- '**.md'
- 'docs/**'
pull_request:
branches: [ main ]
release:
types: [published]

permissions:
contents: read
packages: write

jobs:
test:
runs-on: ${{ matrix.os }}
Expand All @@ -18,6 +25,8 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
Expand All @@ -39,10 +48,15 @@ jobs:
shell: pwsh
run: |
choco install tesseract
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
echo "C:\Program Files\Tesseract-OCR" >> $env:GITHUB_PATH
refreshenv
tesseract --version
$tesseractPath = "C:\Program Files\Tesseract-OCR"
# Add to system PATH
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$tesseractPath", [System.EnvironmentVariableTarget]::Machine)
# Add to current session PATH
$env:Path = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine)
# Add to GITHUB_PATH for subsequent steps
echo "$tesseractPath" >> $env:GITHUB_PATH
# Verify installation
& "C:\Program Files\Tesseract-OCR\tesseract.exe" --version

- name: Install dependencies
run: |
Expand All @@ -54,13 +68,29 @@ jobs:
run: |
pytest --cov=mcp_ocr tests/

- name: Upload coverage reports
uses: codecov/codecov-action@v3
if: matrix.os == 'ubuntu-latest'

publish:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
environment: release
if: github.event_name == 'release' && github.event.action == 'published' && startsWith(github.ref, 'refs/tags/v')

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Verify tag matches version
run: |
VERSION=$(grep '^version = ' pyproject.toml | cut -d'"' -f2)
TAG=${GITHUB_REF#refs/tags/v}
if [ "$VERSION" != "$TAG" ]; then
echo "Version in pyproject.toml ($VERSION) does not match tag ($TAG)"
exit 1
fi

- name: Set up Python
uses: actions/setup-python@v4
Expand All @@ -72,10 +102,21 @@ jobs:
python -m pip install --upgrade pip
pip install build twine

- name: Build and publish
- name: Build and verify
run: |
python -m build
twine check dist/*

- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python -m build
twine upload dist/*
twine upload dist/*

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: dist/*
body_path: CHANGELOG.md
generate_release_notes: true
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.0] - 2025-04-13

### Added
- Initial release
- Basic OCR functionality with Tesseract
- Support for file, URL, and bytes input
- Automatic Tesseract installation
- Multi-platform support (Windows, macOS, Linux)
- GitHub Actions CI/CD pipeline
- Test suite with coverage reporting

### Fixed
- Windows CI: Fixed Tesseract PATH handling in GitHub Actions workflow