Skip to content

feat(#51): replace deprecated antiword with LibreOffice #26

feat(#51): replace deprecated antiword with LibreOffice

feat(#51): replace deprecated antiword with LibreOffice #26

Workflow file for this run

---
name: CI Pipeline
"on":
push:
branches: [main]
tags: [v*]
pull_request:
paths:
- .github/workflows/ci_pipeline.yml
- .github/actions/setup/action.yml
- textract/**
- tests/**
- uv.lock
- pyproject.toml
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
changelog-check:
name: Changelog Check
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Require changelog update when library changes
run: |
BASE=${{ github.event.pull_request.base.sha }}
HEAD=${{ github.event.pull_request.head.sha }}
if git diff --name-only "$BASE" "$HEAD" | grep -qE '^textract/.*\.py$'; then
if ! git diff --name-only "$BASE" "$HEAD" | grep -q '^docs/changelog\.rst$'; then
echo "textract/**/*.py changed but docs/changelog.rst was not updated."
exit 1
fi
fi
changes:
name: Detect Changes
runs-on: ubuntu-latest
outputs:
# Whether to install LibreOffice (and thus run the legacy .doc tests).
libreoffice: ${{ steps.detect.outputs.libreoffice }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Detect .doc-related changes
id: detect
shell: bash
run: |
# Always install on push (main / tags); on PRs only when the change
# touches .doc parsing, its tests, or the CI setup itself.
if [ "${{ github.event_name }}" != "pull_request" ]; then
echo "libreoffice=true" >> "$GITHUB_OUTPUT"
exit 0
fi
BASE=${{ github.event.pull_request.base.sha }}
HEAD=${{ github.event.pull_request.head.sha }}
if git diff --name-only "$BASE" "$HEAD" | grep -qE '^(textract/parsers/doc_parser\.py|textract/exceptions\.py|tests/test_doc\.py|tests/doc/|\.github/actions/setup/action\.yml|\.github/workflows/ci_pipeline\.yml)'; then
echo "libreoffice=true" >> "$GITHUB_OUTPUT"
else
echo "libreoffice=false" >> "$GITHUB_OUTPUT"
fi
test:
needs: changes
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
# On PRs, test all OSes on a single Python for fast feedback. On push
# to main and tags, test the full Python range before release.
python-version: ${{ github.event_name == 'pull_request' && fromJSON('["3.14"]') || fromJSON('["3.9", "3.14"]') }}
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup
with:
python-version: ${{ matrix.python-version }}
install-libreoffice: ${{ needs.changes.outputs.libreoffice }}
- name: Run tests
id: tests
run: uv run pytest --junit-xml=test-results.xml
env:
SKIP_NETWORK_TESTS: "true"
- name: Upload test results
if: always()
uses: actions/upload-artifact@v7
with:
name: test-results-${{ matrix.os }}-py${{ matrix.python-version }}
path: test-results.xml
release:
name: Release and Publish
needs: [test]
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/textract
permissions:
contents: write
id-token: write # IMPORTANT: mandatory for PyPI trusted publishing
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
with:
python-version: "3.14"
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
generate_release_notes: true
tag_name: ${{ github.ref_name }}
- name: Build Package
run: uv build
- name: Publish to PyPI
run: uv publish --trusted-publishing=always