chore: release v0.2.3 #5
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: Release — WASM SDK (npm) | |
| on: | |
| push: | |
| tags: ['v[0-9]+.[0-9]+.[0-9]+'] | |
| workflow_dispatch: | |
| inputs: | |
| tag_name: | |
| description: 'Tag name to publish (e.g. v0.2.2) — used for version sync' | |
| required: true | |
| default: 'v0.2.2' | |
| permissions: | |
| contents: write | |
| jobs: | |
| publish-wasm: | |
| name: Publish WASM package | |
| runs-on: ubuntu-latest | |
| environment: npm | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: wasm32-unknown-unknown | |
| - uses: Swatinem/rust-cache@v2 | |
| - uses: taiki-e/install-action@wasm-pack | |
| - name: Verify version consistency | |
| env: | |
| INPUT_TAG_NAME: ${{ inputs.tag_name }} | |
| run: | | |
| TAG_NAME="${INPUT_TAG_NAME:-$GITHUB_REF_NAME}" | |
| TAG_VERSION="${TAG_NAME#v}" | |
| CARGO_VERSION=$(cargo metadata --no-deps --format-version 1 \ | |
| | jq -r '.packages[] | select(.name=="edgeparse-wasm") | .version') | |
| if [[ "$TAG_VERSION" != "$CARGO_VERSION" ]]; then | |
| echo "ERROR: tag $TAG_VERSION ≠ Cargo.toml $CARGO_VERSION" | |
| exit 1 | |
| fi | |
| - name: Build WASM package | |
| run: | | |
| cd crates/edgeparse-wasm | |
| wasm-pack build --target web --release | |
| - name: Sync npm metadata | |
| env: | |
| INPUT_TAG_NAME: ${{ inputs.tag_name }} | |
| run: | | |
| node -e " | |
| const fs = require('fs'); | |
| const refName = process.env.INPUT_TAG_NAME || process.env.GITHUB_REF_NAME; | |
| const version = refName.replace(/^v/, ''); | |
| const path = 'crates/edgeparse-wasm/pkg/package.json'; | |
| const pkg = JSON.parse(fs.readFileSync(path, 'utf8')); | |
| pkg.name = 'edgeparse-wasm'; | |
| pkg.version = version; | |
| pkg.description = 'EdgeParse PDF parser — WebAssembly build for browsers'; | |
| pkg.homepage = 'https://edgeparse.io/docs/api/wasm/'; | |
| pkg.repository = { | |
| type: 'git', | |
| url: 'git+https://github.com/raphaelmansuy/edgeparse.git', | |
| directory: 'crates/edgeparse-wasm' | |
| }; | |
| pkg.publishConfig = { access: 'public' }; | |
| pkg.files = [ | |
| 'edgeparse_wasm_bg.wasm', | |
| 'edgeparse_wasm.js', | |
| 'edgeparse_wasm.d.ts', | |
| 'README.md', | |
| 'LICENSE' | |
| ]; | |
| fs.writeFileSync(path, JSON.stringify(pkg, null, 2) + '\n'); | |
| console.log('Version synced to: ' + version); | |
| " | |
| - name: Stage package docs | |
| run: | | |
| cp README.md crates/edgeparse-wasm/pkg/README.md | |
| cp LICENSE crates/edgeparse-wasm/pkg/LICENSE | |
| - name: Pack npm tarball | |
| run: | | |
| cd crates/edgeparse-wasm/pkg | |
| npm pack | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: wasm-package | |
| path: crates/edgeparse-wasm/pkg/*.tgz | |
| - name: Skip WASM npm publication | |
| run: | | |
| echo "::warning::WASM npm publication is disabled. The package tarball will still be uploaded to the GitHub Release." | |
| - name: Ensure GitHub Release exists | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| INPUT_TAG_NAME: ${{ inputs.tag_name }} | |
| run: | | |
| TAG_NAME="${INPUT_TAG_NAME:-$GITHUB_REF_NAME}" | |
| gh release view "$TAG_NAME" --repo "${{ github.repository }}" \ | |
| || gh release create "$TAG_NAME" \ | |
| --repo "${{ github.repository }}" \ | |
| --title "$TAG_NAME" \ | |
| --generate-notes | |
| - name: Upload npm tarball to GitHub Release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| INPUT_TAG_NAME: ${{ inputs.tag_name }} | |
| run: | | |
| TAG_NAME="${INPUT_TAG_NAME:-$GITHUB_REF_NAME}" | |
| gh release upload "$TAG_NAME" crates/edgeparse-wasm/pkg/*.tgz \ | |
| --repo "${{ github.repository }}" --clobber |