name: Release
on:
push:
tags:
- "v*.*.*"
- "*.*.*"
permissions:
contents: write
id-token: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
publish:
name: Publish crates.io and npm packages
runs-on: ubuntu-latest
env:
CARGO_TERM_COLOR: always
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy,rustfmt
targets: wasm32-unknown-unknown
- name: Cache Cargo
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-release-${{ hashFiles('Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-release-
${{ runner.os }}-cargo-
- name: Install cargo-binstall
uses: cargo-bins/cargo-binstall@main
- name: Install Rust CLI tools
run: cargo binstall --no-confirm just wasm-pack@0.14.0
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
cache-dependency-path: tests/package-lock.json
registry-url: https://registry.npmjs.org
- name: Run release checks
run: |
just check-release-version "$GITHUB_REF_NAME"
just check
just test
just build-npm
just check-npm-package "$GITHUB_REF_NAME"
- name: Check Cargo package
run: cargo package --allow-dirty
- name: Check crates.io publish metadata
run: cargo publish --dry-run
- name: Check npm package
run: npm pack ./pkg --dry-run
- name: Authenticate to crates.io
id: crates_io_auth
uses: rust-lang/crates-io-auth-action@v1
- name: Publish crates.io package
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.crates_io_auth.outputs.token }}
- name: Publish npm package
run: npm publish ./pkg --access public
- name: Create GitHub Release
run: gh release create "$GITHUB_REF_NAME" --verify-tag --generate-notes
env:
GH_TOKEN: ${{ github.token }}