Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.1.3 #62

Merged
merged 7 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading