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

ZK-1337: Publish packages to npm #87

Merged
merged 12 commits into from
Jan 16, 2025
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
134 changes: 0 additions & 134 deletions .github/workflows/manual-publish-dev-env.yml

This file was deleted.

99 changes: 99 additions & 0 deletions .github/workflows/manual-publish-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
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
tag:
description: "NPM tag"
required: true
type: choice
options:
- develop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just making sure that develop is an actual tag and not a misspelling of development

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an actual tag

- latest

jobs:
publish:
name: Build and push ${{ github.event.inputs.package }}
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
with:
poseidon-gadget-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
zkos-circuits-private-key: ${{ secrets.ZKOS_CIRCUITS_SSH_PRIVATE_KEY }}

- 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

# Foundry setup for shielder-sdk
- name: Install Foundry
if: github.event.inputs.package == 'shielder-sdk'
uses: foundry-rs/[email protected]
with:
cache-key: custom-seed-coverage-${{ github.ref_name }}
cache-restore-keys: |-
contract-suite
version: nightly-31dd1f77fd9156d09836486d97963cec7f555343

- name: Install deps and compile contracts
if: github.event.inputs.package == 'shielder-sdk'
run: |
make deps
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: latest

# Build steps
- name: Build shielder-wasm
if: github.event.inputs.package == 'shielder-sdk-crypto-wasm'
run: make all
working-directory: crates/shielder-wasm

- 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you could handle crypto-wasm in another elif and stop the workflow in the else branch, just to have slightly more bug-resistant code in case this script evolves

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I believe the best scenario is to have separate jobs declarations for each package. but now let's keep it simple

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 --access restricted --no-git-checks --tag ${{ github.event.inputs.tag }}
working-directory: ts/${{ github.event.inputs.package }}
12 changes: 0 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,3 @@ format-rust:
lint-rust: # Lint all rust crates
lint-rust:
cargo clippy --release -- -D warnings

.PHONY: generate-tooling-dev
generate-tooling-dev: # Generate tooling-dev package
generate-tooling-dev:
cp tooling-e2e-tests/local_env.sh tooling-dev/
cp crates/shielder-relayer/run-relayer.sh tooling-dev/
cp package.json tooling-dev/
cp package-lock.json tooling-dev/
cp foundry.toml tooling-dev/
cp -r contracts tooling-dev/
cp -r scripts tooling-dev/
git rev-parse --short=7 HEAD > tooling-dev/.git-sha
3 changes: 3 additions & 0 deletions ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"build:crypto": "pnpm --filter shielder-sdk-crypto build",
"build:crypto-wasm": "pnpm --filter shielder-sdk-crypto-wasm build",
"build:sdk": "pnpm --filter shielder-sdk build",
"build-package:crypto": "pnpm build:crypto",
"build-package:crypto-wasm": "pnpm build:crypto && pnpm build:crypto-wasm",
"build-package:sdk": "pnpm build:crypto && pnpm build:sdk",
"test": "pnpm -r test",
"lint": "pnpm -r lint",
"install-deps": "pnpm install --frozen-lockfile"
Expand Down