Skip to content

Commit 2cd1cf1

Browse files
fix(crate): allowlist package contents to fit crates.io size cap (#152)
cargo publish of 0.1.5 failed with 413: the crate packaged everything (260 files, 10.1MiB compressed) and tests/fixtures alone is 10.2MB. Add an explicit include list (src, external/bcmaps which tounicode.rs loads at runtime, readme, license) — 1.3MiB compressed. Also add a workflow_dispatch fallback to publish-crate.yml so a failed publish can be retried without a version bump (0.1.5 is already on main, so a re-push won't register as a version change). Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 2c97f49 commit 2cd1cf1

2 files changed

Lines changed: 33 additions & 8 deletions

File tree

.github/workflows/publish-crate.yml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
push:
55
branches: [main]
66
paths: ['Cargo.toml']
7+
# Manual fallback: retry a publish that failed after the version was
8+
# already merged (a plain re-push won't register as a version change).
9+
workflow_dispatch:
710

811
permissions:
912
contents: read
@@ -14,6 +17,10 @@ env:
1417
jobs:
1518
check-version:
1619
name: Check version change
20+
# Guard manual dispatches: crates.io trusted publishing matches
21+
# repo+workflow+environment but NOT branch, so without this a
22+
# workflow_dispatch from any branch could publish unmerged code.
23+
if: github.ref == 'refs/heads/main'
1724
runs-on: ubuntu-latest
1825
outputs:
1926
changed: ${{ steps.check.outputs.changed }}
@@ -28,17 +35,26 @@ jobs:
2835
id: check
2936
run: |
3037
NEW_VERSION=$(python3 -c 'import pathlib, tomllib; print(tomllib.loads(pathlib.Path("Cargo.toml").read_text())["package"]["version"])')
31-
OLD_VERSION=$(git show HEAD~1:Cargo.toml | python3 -c 'import sys, tomllib; print(tomllib.loads(sys.stdin.read())["package"]["version"])')
32-
echo "old=$OLD_VERSION new=$NEW_VERSION"
3338
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
3439
35-
if [ "$NEW_VERSION" = "$OLD_VERSION" ]; then
36-
echo "changed=false" >> "$GITHUB_OUTPUT"
37-
echo "published=false" >> "$GITHUB_OUTPUT"
38-
exit 0
39-
fi
40+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
41+
# Manual dispatch publishes the current version regardless of the
42+
# previous commit; the crates.io check below still prevents
43+
# double-publishing an already-released version.
44+
echo "manual dispatch: publishing v$NEW_VERSION"
45+
echo "changed=true" >> "$GITHUB_OUTPUT"
46+
else
47+
OLD_VERSION=$(git show HEAD~1:Cargo.toml | python3 -c 'import sys, tomllib; print(tomllib.loads(sys.stdin.read())["package"]["version"])')
48+
echo "old=$OLD_VERSION new=$NEW_VERSION"
49+
50+
if [ "$NEW_VERSION" = "$OLD_VERSION" ]; then
51+
echo "changed=false" >> "$GITHUB_OUTPUT"
52+
echo "published=false" >> "$GITHUB_OUTPUT"
53+
exit 0
54+
fi
4055
41-
echo "changed=true" >> "$GITHUB_OUTPUT"
56+
echo "changed=true" >> "$GITHUB_OUTPUT"
57+
fi
4258
4359
HTTP_STATUS=$(curl --silent --show-error --output /tmp/crate-version.json --write-out "%{http_code}" \
4460
-H "User-Agent: firecrawl/pdf-inspector publish workflow (https://github.com/firecrawl/pdf-inspector)" \

Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ description = "Fast PDF inspection, classification, and text extraction with sma
88
license = "MIT"
99
repository = "https://github.com/firecrawl/pdf-inspector"
1010
readme = "docs/rust-api.md"
11+
# Explicit allowlist: crates.io caps uploads at 10 MiB and tests/fixtures
12+
# alone exceeds that. external/bcmaps ships in the crate — tounicode.rs
13+
# loads it at runtime relative to CARGO_MANIFEST_DIR.
14+
include = [
15+
"src/**",
16+
"external/bcmaps/**",
17+
"docs/rust-api.md",
18+
"LICENSE",
19+
]
1120

1221
[lib]
1322
name = "pdf_inspector"

0 commit comments

Comments
 (0)