Skip to content

Commit

Permalink
Split crate and NPM build
Browse files Browse the repository at this point in the history
  • Loading branch information
Rigidity committed Aug 26, 2024
1 parent 9ec89f0 commit f424de9
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 71 deletions.
71 changes: 0 additions & 71 deletions .github/workflows/build-crate-and-npm.yml

This file was deleted.

53 changes: 53 additions & 0 deletions .github/workflows/build-crate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build Rust crate

on:
push:
branches:
- main
tags:
- "**"
pull_request:
branches:
- "**"

jobs:
build_crate:
name: Rust crate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: Fmt
run: cargo fmt -- --files-with-diff --check

- name: Clippy
run: cargo clippy --workspace --all-features --all-targets

- name: Tests (debug)
run: cargo test --workspace --all-features

- name: Tests (release)
run: cargo test --workspace --all-features --release

- name: Install cargo-workspaces
run: cargo install cargo-workspaces --locked

- name: Publish (dry run)
run: cargo ws publish --publish-as-is --dry-run

- name: Upload crate artifacts
uses: actions/upload-artifact@v4
with:
name: crate
path: ./target/package/*-*.crate

- name: Publish (crates.io)
if: startsWith(github.event.ref, 'refs/tags')
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.cargo_registry_token }}
run: cargo ws publish --publish-as-is
43 changes: 43 additions & 0 deletions .github/workflows/build-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build NPM package

on:
push:
branches:
- main
tags:
- "**"
pull_request:
branches:
- "**"

jobs:
build_npm:
name: NPM package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable

- name: Install wasm-pack
run: cargo install wasm-pack --locked

- name: Build wasm
run: |
cd wasm
wasm-pack build
wasm-pack pack
- name: Upload NPM package artifacts
uses: actions/upload-artifact@v4
with:
name: npm-pkg
path: ./wasm/pkg/*-*.tgz

- name: Publish (npmjs.com)
if: startsWith(github.event.ref, 'refs/tags')
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.node_auth_token }}
package: wasm/pkg/package.json

0 comments on commit f424de9

Please sign in to comment.