diff --git a/.github/workflows/build-crate-and-npm.yml b/.github/workflows/build-crate-and-npm.yml deleted file mode 100644 index 3b9d79d2f..000000000 --- a/.github/workflows/build-crate-and-npm.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Build crate and npm package - -on: - push: - branches: - - main - tags: - - "**" - pull_request: - branches: - - "**" - -jobs: - build_crate: - name: Crate & NPM - runs-on: ubuntu-latest - strategy: - fail-fast: false - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up rusts - uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt, clippy - - - name: fmt - run: cargo fmt -- --files-with-diff --check - - name: clippy - run: cargo clippy - - name: tests - run: cargo test && cargo test --release - - name: build - run: cargo build --release - - - name: Upload crate artifacts - uses: actions/upload-artifact@v4 - with: - name: crate - path: ./target/package/*-*.crate - - - name: install wasm-pack - run: cargo install wasm-pack --locked - - - name: wasm-pack build and pack - run: cd wasm && wasm-pack build && wasm-pack pack - - - name: Upload npm pkg artifacts - uses: actions/upload-artifact@v4 - with: - name: npm-pkg - path: ./wasm/pkg/*-*.tgz - - - name: publish to crates.io if tagged - if: startsWith(github.event.ref, 'refs/tags') - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.cargo_registry_token }} - run: | - cargo install cargo-workspaces --locked - cargo ws publish --publish-as-is - - # this has not been tested, so probably needs to be debugged next time a tag is created - - name: publish to npmjs.com if tagged - if: startsWith(github.event.ref, 'refs/tags') - uses: JS-DevTools/npm-publish@v3 - with: - token: ${{ secrets.node_auth_token }} - package: wasm/pkg/package.json diff --git a/.github/workflows/build-crate.yml b/.github/workflows/build-crate.yml new file mode 100644 index 000000000..511ad101f --- /dev/null +++ b/.github/workflows/build-crate.yml @@ -0,0 +1,49 @@ +name: Rust crate + +on: + push: + branches: + - main + tags: + - "**" + pull_request: + branches: + - "**" + +jobs: + build_crate: + name: Build 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 + + - name: Tests + run: cargo test && cargo test --release + + - name: Build + run: cargo build --release + + - 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 install cargo-workspaces --locked + cargo ws publish --publish-as-is diff --git a/.github/workflows/build-npm.yml b/.github/workflows/build-npm.yml new file mode 100644 index 000000000..4679bd3c8 --- /dev/null +++ b/.github/workflows/build-npm.yml @@ -0,0 +1,43 @@ +name: NPM package + +on: + push: + branches: + - main + tags: + - "**" + pull_request: + branches: + - "**" + +jobs: + build_npm: + name: Build npm + 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: WASM build and pack + run: | + cd wasm + wasm-pack build + wasm-pack pack + + - name: Upload NPM pkg 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