Manual Publish to npm #19
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | |
] | |
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: | | |
LAYOUTS=(${{ matrix.layout }}) | |
HASHERS=(${{ matrix.hash }}) | |
STONES=(${{ matrix.stone }}) | |
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 "$output_dir/.gitignore" | |
rm "$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 }} |