diff --git a/.github/workflows/sdk-publish.yml b/.github/workflows/sdk-publish.yml new file mode 100644 index 0000000000..8cabbfe978 --- /dev/null +++ b/.github/workflows/sdk-publish.yml @@ -0,0 +1,32 @@ +name: Publish SDK to NPM +on: + workflow_dispatch: + +defaults: + run: + working-directory: sdk/typescript/packages/sdk + +jobs: + publish: + runs-on: [custom-runner-linux] + steps: + - name: Install Node + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Setup yarn + run: npm install -g yarn + + - name: Install Rust stable + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + + - name: Install wasm-pack + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + + - name: Build and publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} + run: scripts/publish.sh \ No newline at end of file diff --git a/sdk/typescript/packages/sdk/DEVELOPERS.md b/sdk/typescript/packages/sdk/DEVELOPERS.md index 015271fb96..5215673a2b 100644 --- a/sdk/typescript/packages/sdk/DEVELOPERS.md +++ b/sdk/typescript/packages/sdk/DEVELOPERS.md @@ -34,6 +34,16 @@ The output bundle will be created in the `dist` directory. If you're a Nym platform developer who's made changes to the Rust (or JS) files and wants to re-publish the package to NPM, here's how you do it: +Make sure you have logged into the NPM registry (`npm login`). + +### Scripted + +1. bump version numbers as necessary for SemVer +2. make sure you're in the SDK directory (`cd sdk/typescript/packages/sdk`) +3. run `scripts/publish.sh` + +### Manually + 1. bump version numbers as necessary for SemVer 2. `yarn build` builds the release directory in the root of the repo in `dist/sdk` 3. `cd ../../../../dist/sdk` diff --git a/sdk/typescript/packages/sdk/package.json b/sdk/typescript/packages/sdk/package.json index 14a9b02e79..5e661b79c3 100644 --- a/sdk/typescript/packages/sdk/package.json +++ b/sdk/typescript/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/sdk", - "version": "1.1.7", + "version": "1.1.8", "license": "Apache-2.0", "author": "Nym Technologies SA", "type": "module", diff --git a/sdk/typescript/packages/sdk/scripts/publish.sh b/sdk/typescript/packages/sdk/scripts/publish.sh new file mode 100755 index 0000000000..94aa4f689b --- /dev/null +++ b/sdk/typescript/packages/sdk/scripts/publish.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail + +rm -rf dist || true +rm -rf ../../../../dist || true + +yarn +yarn build +cd ../../../../dist/sdk + +cd cjs +echo "Publishing CommonJS package to NPM.." +npm publish --access=public +cd .. + +cd esm +echo "Publishing ESM package to NPM.." +npm publish --access=public +cd ..