This repository was archived by the owner on Jul 30, 2025. It is now read-only.
Build and publish packages to npm #47
This file contains hidden or 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: "Build and publish packages to npm" | |
on: | |
workflow_dispatch: | |
inputs: | |
package: | |
description: "Package to publish" | |
required: true | |
type: choice | |
options: | |
- shielder-sdk | |
- shielder-sdk-crypto | |
- shielder-sdk-crypto-wasm | |
- shielder-sdk-crypto-mobile | |
tag: | |
description: "NPM tag" | |
required: true | |
type: choice | |
options: | |
- develop | |
- latest | |
jobs: | |
publish: | |
name: Build and push ${{ github.event.inputs.package }} | |
if: | | |
github.event.inputs.package == 'shielder-sdk' || | |
github.event.inputs.package == 'shielder-sdk-crypto' || | |
github.event.inputs.package == 'shielder-sdk-crypto-wasm' | |
runs-on: [self-hosted, Linux, X64, medium] | |
steps: | |
- name: GIT | Checkout | |
uses: actions/checkout@v4 | |
# Rust setup for shielder-sdk-crypto-wasm and shielder-sdk | |
- name: Prepare Rust env | |
if: | | |
github.event.inputs.package == 'shielder-sdk-crypto-wasm' || | |
github.event.inputs.package == 'shielder-sdk' | |
uses: ./.github/actions/prepare-rust-env | |
- name: Install wasm-pack | |
if: github.event.inputs.package == 'shielder-sdk-crypto-wasm' | |
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
- name: Prepare Solidity environment | |
if: github.event.inputs.package == 'shielder-sdk' | |
uses: ./.github/actions/prepare-sol-env | |
- name: Install deps and compile contracts | |
if: github.event.inputs.package == 'shielder-sdk' | |
run: make compile-contracts | |
# Common Node.js setup | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 23 | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 10.2.0 | |
# Build steps | |
- name: Build shielder_bindings (wasm) | |
if: github.event.inputs.package == 'shielder-sdk-crypto-wasm' | |
run: make wasm | |
working-directory: crates/shielder_bindings | |
- name: Install dependencies (workspace) | |
run: pnpm install-deps | |
working-directory: ts | |
- name: Build package | |
run: | | |
if [ "${{ github.event.inputs.package }}" = "shielder-sdk" ]; then | |
pnpm build-package:sdk | |
elif [ "${{ github.event.inputs.package }}" = "shielder-sdk-crypto" ]; then | |
pnpm build-package:crypto | |
else | |
pnpm build-package:crypto-wasm | |
fi | |
working-directory: ts | |
# Publish | |
- name: Add .npmrc with publish token | |
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_PUBLISHING_KEY }}" > .npmrc | |
working-directory: ts/${{ github.event.inputs.package }} | |
- name: Publish package | |
run: pnpm publish --no-git-checks --tag ${{ github.event.inputs.tag }} | |
working-directory: ts/${{ github.event.inputs.package }} | |
publish-mobile: | |
name: Build and push shielder-sdk-crypto-mobile | |
if: github.event.inputs.package == 'shielder-sdk-crypto-mobile' | |
runs-on: macos-14 | |
steps: | |
- name: GIT | Checkout | |
uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: Cardinal-Cryptography/github-actions/install-rust-toolchain@v7 | |
with: | |
channel: nightly | |
- name: Install active toolchain | |
shell: bash | |
run: rustup toolchain install | |
- name: Install C++ tooling | |
run: brew install cmake ninja clang-format | |
- name: Install Android rust toolchain | |
run: | | |
rustup target add \ | |
aarch64-linux-android \ | |
armv7-linux-androideabi \ | |
i686-linux-android \ | |
x86_64-linux-android | |
- name: Install cargo-ndk | |
run: cargo install cargo-ndk | |
- name: Install iOS rust toolchain | |
run: | | |
rustup target add \ | |
aarch64-apple-ios \ | |
aarch64-apple-ios-sim \ | |
x86_64-apple-ios | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 23 | |
- run: corepack enable | |
- name: Add .npmrc with publish token | |
run: | | |
echo "npmAuthToken: ${{ secrets.NPM_PUBLISHING_KEY }}" >> .yarnrc.yml | |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_PUBLISHING_KEY }}" > .npmrc | |
working-directory: ts/shielder-sdk-crypto-mobile | |
- name: Install dependencies | |
run: yarn | |
working-directory: ts/shielder-sdk-crypto-mobile | |
- name: Build android | |
run: yarn ubrn:android | |
working-directory: ts/shielder-sdk-crypto-mobile | |
- name: Build ios | |
run: yarn ubrn:ios | |
working-directory: ts/shielder-sdk-crypto-mobile | |
- name: Pack | |
run: npm publish --tag ${{ github.event.inputs.tag }} | |
working-directory: ts/shielder-sdk-crypto-mobile |