Skip to content

Publishing WASM packages to NPM #1875

Publishing WASM packages to NPM

Publishing WASM packages to NPM #1875

Workflow file for this run

name: CI
on:
push:
branches:
- master
pull_request:
merge_group:
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_VERSION: 1.69.0
NIGHTLY_RUST_VERSION: nightly-2023-05-23
jobs:
cargo:
runs-on: buildjet-4vcpu-ubuntu-2204
strategy:
fail-fast: false
matrix:
include:
- command: clippy
args: --all-targets --all-features -- -D warnings -D clippy::dbg_macro
- command: check
args: --all-targets
- command: check
args: --all-targets -p fuel-asm
- command: check
args: --all-targets -p fuel-crypto
- command: check
args: --all-targets -p fuel-merkle
- command: check
args: --all-targets -p fuel-storage
- command: check
args: --all-targets -p fuel-tx
- command: check
args: --all-targets -p fuel-types
- command: check
args: --all-targets -p fuel-vm
- command: check
args: --all-targets --no-default-features
- command: check
args: --all-targets --all-features
- command: check
args: --target thumbv6m-none-eabi -p fuel-asm -p fuel-storage -p fuel-merkle --no-default-features
- command: check
args: --target wasm32-unknown-unknown -p fuel-crypto --no-default-features
- command: rustc
args: --target wasm32-unknown-unknown -p fuel-types --features typescript --crate-type=cdylib
- command: rustc
args: --target wasm32-unknown-unknown -p fuel-asm --features typescript --crate-type=cdylib
- command: make
args: check
- command: test
args: --all-targets --all-features
- command: test
args: --all-targets --no-default-features
- command: test
args: --all-targets --no-default-features --features serde
- command: test
args: --all-targets --no-default-features --features alloc
- command: test
args: --all-targets --features random
- command: test
args: --all-targets --features serde
- command: test
args: --all-targets --features random,profile-gas,profile-coverage,serde
steps:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
targets: "thumbv6m-none-eabi,wasm32-unknown-unknown"
components: "clippy"
- name: Install Cargo Make
uses: davidB/rust-cargo-make@v1
with:
version: "0.36.4"
- run: cargo ${{ matrix.command }} ${{ matrix.args }}
rustfmt:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install latest nightly
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.NIGHTLY_RUST_VERSION }}
components: rustfmt
- name: Rustfmt check
run: cargo +${{ env.NIGHTLY_RUST_VERSION }} fmt --all -- --check
cargo-toml-fmt-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- name: setup binstall
uses: taiki-e/install-action@cargo-binstall
- name: Install Cargo.toml linter
run: cargo binstall --no-confirm cargo-sort
- name: Run Cargo.toml sort check
run: cargo sort -w --check
verifications-complete:
needs:
- rustfmt
- cargo
- cargo-toml-fmt-check
runs-on: ubuntu-latest
steps:
- run: true
publish-check:
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- name: Publish crate check
uses: katyo/publish-crates@v2
with:
dry-run: true
publish:
# Only do this job if publishing a release and all checks pass.
needs:
- verifications-complete
- publish-check
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- name: Verify tag version
run: |
curl -sSLf "https://github.com/TomWright/dasel/releases/download/v1.24.3/dasel_linux_amd64" -L -o dasel && chmod +x dasel
mv ./dasel /usr/local/bin/dasel
./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} Cargo.toml
- name: Publish crate
uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
cargo_audit:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v3
- uses: rustsec/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
publish-wasm-packages:
needs:
# - publish
- verifications-complete
# if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- name: Setup Node
uses: actions/setup-node@v3
with:
cache: "pnpm"
node-version: 18.14.1
- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: 8.6.9
- name: Build and Test packages
run: |
pnpm -C .npm install
pnpm -C .npm all
- name: Publish
run: |
npm whoami
pnpm -C .npm publish -r --tag --dry-run
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}