Skip to content

Manual Publish to npm #2

Manual Publish to npm

Manual Publish to npm #2

Workflow file for this run

name: Manual Publish to npm
on:
workflow_dispatch:
inputs:
npm_version:
description: 'Version to publish'
required: true
default: 'patch' # could be 'patch', 'minor', 'major', or a specific version
jobs:
publish:
runs-on: ubuntu-latest
env:
WORKING_DIR: wasm-binding # define the working directory here
strategy:
fail-fast: false
matrix:
layout: ["starknet_with_keccak"]
hash: ["blake2s"]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18' # specify your desired Node.js version
- name: Update version
run: npm version ${{ github.event.inputs.npm_version }} --no-git-tag-version
working-directory: ${{ env.WORKING_DIR }}
- name: Configure npm
run: npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
working-directory: ${{ env.WORKING_DIR }}
- name: Install wasm-pack
run: cargo install wasm-pack
- name: Build package
run: wasm-pack build --target web --workspace --features ${{ matrix.layout }},${{ matrix.hash }} --no-default-features --out-dir pkg
working-directory: ${{ env.WORKING_DIR }}
- name: Rename package
run: jq '.name = "swiftness-${{ matrix.layout }}-${{ matrix.hash }}"' package.json > tmp.json && mv tmp.json package.json
working-directory: ${{ env.WORKING_DIR }}/pkg
- name: Publish to npm
run: npm publish --dry-run
working-directory: ${{ env.WORKING_DIR }}/pkg