diff --git a/.github/workflows/publish-crate.yml b/.github/workflows/publish-crate.yml index 168a3ab..91741df 100644 --- a/.github/workflows/publish-crate.yml +++ b/.github/workflows/publish-crate.yml @@ -4,6 +4,9 @@ on: push: branches: [main] paths: ['Cargo.toml'] + # Manual fallback: retry a publish that failed after the version was + # already merged (a plain re-push won't register as a version change). + workflow_dispatch: permissions: contents: read @@ -14,6 +17,10 @@ env: jobs: check-version: name: Check version change + # Guard manual dispatches: crates.io trusted publishing matches + # repo+workflow+environment but NOT branch, so without this a + # workflow_dispatch from any branch could publish unmerged code. + if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest outputs: changed: ${{ steps.check.outputs.changed }} @@ -28,17 +35,26 @@ jobs: id: check run: | NEW_VERSION=$(python3 -c 'import pathlib, tomllib; print(tomllib.loads(pathlib.Path("Cargo.toml").read_text())["package"]["version"])') - OLD_VERSION=$(git show HEAD~1:Cargo.toml | python3 -c 'import sys, tomllib; print(tomllib.loads(sys.stdin.read())["package"]["version"])') - echo "old=$OLD_VERSION new=$NEW_VERSION" echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT" - if [ "$NEW_VERSION" = "$OLD_VERSION" ]; then - echo "changed=false" >> "$GITHUB_OUTPUT" - echo "published=false" >> "$GITHUB_OUTPUT" - exit 0 - fi + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + # Manual dispatch publishes the current version regardless of the + # previous commit; the crates.io check below still prevents + # double-publishing an already-released version. + echo "manual dispatch: publishing v$NEW_VERSION" + echo "changed=true" >> "$GITHUB_OUTPUT" + else + OLD_VERSION=$(git show HEAD~1:Cargo.toml | python3 -c 'import sys, tomllib; print(tomllib.loads(sys.stdin.read())["package"]["version"])') + echo "old=$OLD_VERSION new=$NEW_VERSION" - echo "changed=true" >> "$GITHUB_OUTPUT" + if [ "$NEW_VERSION" = "$OLD_VERSION" ]; then + echo "changed=false" >> "$GITHUB_OUTPUT" + echo "published=false" >> "$GITHUB_OUTPUT" + exit 0 + fi + + echo "changed=true" >> "$GITHUB_OUTPUT" + fi HTTP_STATUS=$(curl --silent --show-error --output /tmp/crate-version.json --write-out "%{http_code}" \ -H "User-Agent: firecrawl/pdf-inspector publish workflow (https://github.com/firecrawl/pdf-inspector)" \ diff --git a/Cargo.toml b/Cargo.toml index c8804ad..30829bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,15 @@ description = "Fast PDF inspection, classification, and text extraction with sma license = "MIT" repository = "https://github.com/firecrawl/pdf-inspector" readme = "docs/rust-api.md" +# Explicit allowlist: crates.io caps uploads at 10 MiB and tests/fixtures +# alone exceeds that. external/bcmaps ships in the crate — tounicode.rs +# loads it at runtime relative to CARGO_MANIFEST_DIR. +include = [ + "src/**", + "external/bcmaps/**", + "docs/rust-api.md", + "LICENSE", +] [lib] name = "pdf_inspector"