Skip to content

Commit

Permalink
v0.1.3 (#62)
Browse files Browse the repository at this point in the history
* version bump

* toolchain defs improved

* npm ci

* fixed cargo lock for wasm

* ci fix
  • Loading branch information
Okm165 authored Dec 28, 2024
1 parent 36f2ea5 commit 2eba10b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 144 deletions.
75 changes: 36 additions & 39 deletions .github/workflows/npm_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,21 @@ 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

strategy:
fail-fast: false
matrix:
layout:
[
"dex",
"dynamic",
"recursive",
"recursive_with_poseidon",
"small",
"starknet",
"starknet_with_keccak",
]
hash:
[
"keccak_160_lsb",
"keccak_248_lsb",
"blake2s_160_lsb",
"blake2s_248_lsb",
]
stone:
[
"stone5",
"stone6",
]

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
Expand All @@ -45,7 +26,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: "18"

- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1

Expand Down Expand Up @@ -74,17 +55,33 @@ jobs:
- name: Install wasm-pack
run: cargo install wasm-pack

- name: Build package
run: wasm-pack build --out-dir pkg --target web --features ${{ matrix.layout }},${{ matrix.hash }},${{ matrix.stone }} --no-default-features
- 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: Rename package
- name: Publish to npm (dry run or actual)
run: |
jq --arg layout "${{ matrix.layout }}" --arg hash "${{ matrix.hash }}" --arg stone "${{ matrix.stone }}" \
'.name = "swiftness-\($layout | gsub("_"; "-"))-\($hash | gsub("_"; "-"))-\($stone | gsub("_"; "-"))"' \
package.json > tmp.json && mv tmp.json package.json
working-directory: ${{ env.WORKING_DIR }}/pkg

- name: Publish to npm
run: npm publish
working-directory: ${{ env.WORKING_DIR }}/pkg
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 }}
106 changes: 1 addition & 105 deletions wasm_bindings/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2eba10b

Please sign in to comment.