feat: improve image conversion #31
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI - WASM Bindings | |
| on: | |
| push: | |
| branches: [main] | |
| tags: | |
| - "wasm@**" | |
| paths: | |
| - "crates/**" | |
| - "packages/wasm/**" | |
| - ".github/workflows/ci-wasm.yml" | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - "crates/**" | |
| - "packages/wasm/**" | |
| - ".github/workflows/ci-wasm.yml" | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| name: Build WASM | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| - uses: dtolnay/rust-toolchain@1.95.0 | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| ~/.cache/pdfium-rs | |
| target | |
| key: ${{ runner.os }}-cargo-wasm-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Install wasm-pack | |
| run: cargo install wasm-pack --locked | |
| - name: Build WASM package | |
| working-directory: packages/wasm | |
| run: npm run build | |
| - name: Verify output | |
| run: | | |
| test -f packages/wasm/pkg/pdfitdown_wasm_bg.wasm | |
| test -f packages/wasm/pkg/pdfitdown_wasm.js | |
| test -f packages/wasm/pkg/pdfitdown_wasm.d.ts | |
| WASM_SIZE=$(stat --format=%s packages/wasm/pkg/pdfitdown_wasm_bg.wasm) | |
| echo "WASM binary size: $(numfmt --to=iec $WASM_SIZE)" | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wasm-pkg | |
| path: packages/wasm/pkg/ | |
| if-no-files-found: error | |
| edge-test: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| name: Edge runtime PDF parse test | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| - name: Download WASM artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: wasm-pkg | |
| path: packages/wasm/pkg/ | |
| - name: Install Miniflare | |
| run: npm install miniflare@latest | |
| - name: Run edge runtime parse test | |
| run: node scripts/edge-compat/wasm-test.mjs | |
| publish: | |
| name: Publish - WASM Bindings | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
| needs: | |
| - build | |
| - edge-test | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Setup node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| - name: Install dependencies | |
| run: npm ci | |
| working-directory: packages/wasm | |
| - name: Download WASM artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: wasm-pkg | |
| path: packages/wasm/pkg/ | |
| - name: Publish | |
| run: | | |
| npm config set provenance true | |
| echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc | |
| npm publish --access public | |
| working-directory: packages/wasm | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |