Skip to content

Manual Publish to npm #21

Manual Publish to npm

Manual Publish to npm #21

Workflow file for this run

name: Manual Publish to npm
on:
workflow_dispatch:
inputs:
dry_run:
description: "Run npm publish as a dry run (true) or publish directly (false)"
required: true
default: true
jobs:
publish:
runs-on: ubuntu-latest
env:
WORKING_DIR: ${{ github.workspace }}/wasm_bindings
LAYOUTS: "dex dynamic recursive recursive_with_poseidon small starknet starknet_with_keccak"
HASHERS: "keccak_160_lsb keccak_248_lsb blake2s_160_lsb blake2s_248_lsb"
STONES: "stone5 stone6"
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Configure npm
run: npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
working-directory: ${{ env.WORKING_DIR }}
- name: Cache Cargo registry
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache Cargo build
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Install wasm-pack
run: cargo install wasm-pack
- name: Build WASM packages
run: |
for layout in $LAYOUTS; do
for hasher in $HASHERS; do
for stone in $STONES; do
output_dir="src/pkg/swiftness_${layout}_${hasher}_${stone}"
features="${layout},${hasher},${stone}"
echo "Building WASM package with layout=$layout, hasher=$hasher, stone=$stone"
wasm-pack build --out-dir "$output_dir" --target web --features "$features" --no-default-features
# Clean up unnecessary files
rm -f "$output_dir/.gitignore"
rm -f "$output_dir/README.md"
done
done
done
working-directory: ${{ env.WORKING_DIR }}
- name: Publish to npm (dry run or actual)
run: |
if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then
echo "Running npm publish in dry run mode"
npm publish --dry-run
else
echo "Publishing to npm"
npm publish
fi
working-directory: ${{ env.WORKING_DIR }}