name: npm
on:
push:
tags:
- "cql2-v*"
workflow_dispatch:
jobs:
build:
name: Build WASM package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 - name: Install wasm-pack
run: cargo install wasm-pack
- name: Build WASM for npm
run: wasm-pack build --target web --out-dir pkg wasm
- name: Upload package
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with:
name: npm-package
path: wasm/pkg
publish:
name: Publish to npm
runs-on: ubuntu-latest
needs: build
permissions:
id-token: write
contents: read
attestations: write
environment:
name: npm
url: https://www.npmjs.com/package/cql2-wasm
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c with:
name: npm-package
path: package
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Upgrade npm version
run: npm install -g npm@latest
- name: Generate artifact attestation
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 with:
subject-path: "package/*"
- name: Publish to npm
working-directory: package
run: npm publish --provenance --access public