Deploy NPM Package #32
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: Deploy NPM Package | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Version to publish (e.g., 1.0.0)" | |
| default: "1.0.0" | |
| required: true | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9.11.0 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: lts/Iron | |
| cache: "pnpm" | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| target: wasm32-unknown-unknown | |
| - name: Install wasm-pack | |
| run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
| - name: Install Foundry | |
| uses: foundry-rs/foundry-toolchain@v1.4.0 | |
| - name: Install dependencies | |
| run: pnpm install -r --frozen-lockfile | |
| # SDK depends on contracts | |
| - name: Install contract dependencies | |
| run: pnpm install -r --frozen-lockfile | |
| working-directory: packages/contracts | |
| - name: Build contracts | |
| run: pnpm build | |
| working-directory: packages/contracts | |
| # Web SDK depends on ERC-4337 contracts for WASM build | |
| - name: Install ERC-4337 contract dependencies | |
| run: forge soldeer install | |
| working-directory: packages/erc4337-contracts | |
| - name: Build ERC-4337 contracts | |
| run: forge build | |
| working-directory: packages/erc4337-contracts | |
| # Local node to have target for deploy | |
| - name: Era Test Node Action | |
| uses: dutterbutter/anvil-zksync-action@v1.1.0 | |
| - name: Deploy contracts | |
| run: pnpm run deploy --file ../auth-server/stores/local-node.json | |
| working-directory: packages/contracts | |
| - name: Build the package | |
| run: pnpm nx build sdk | |
| - name: Build the wagmi-connector package | |
| run: pnpm nx build connector-export | |
| - name: Build the web SDK package | |
| run: pnpm nx build web-sdk | |
| - name: Prepare package.json | |
| working-directory: packages/sdk | |
| run: node prepare-package.mjs | |
| env: | |
| INPUT_VERSION: ${{ github.event.inputs.version }} | |
| - name: Prepare wagmi connector package.json | |
| working-directory: packages/connector-export | |
| run: node prepare-package.mjs | |
| env: | |
| INPUT_VERSION: ${{ github.event.inputs.version }} | |
| - name: Prepare web SDK package.json | |
| working-directory: packages/sdk-platforms/web | |
| run: node prepare-package.mjs | |
| env: | |
| INPUT_VERSION: ${{ github.event.inputs.version }} | |
| - name: Create .npmrc for NPM | |
| run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPMJS_NPM_MATTERLABS_AUTOMATION_TOKEN }}" > ~/.npmrc | |
| - name: Determine npm publish tag | |
| id: npm_tag | |
| run: | | |
| VERSION="${{ github.event.inputs.version }}" | |
| if [[ "$VERSION" =~ -([a-zA-Z0-9]+) ]]; then | |
| TAG="${BASH_REMATCH[1]}" | |
| else | |
| TAG="latest" | |
| fi | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| - name: Publish SDK to NPM | |
| working-directory: packages/sdk | |
| run: npm publish --access public --tag ${{ steps.npm_tag.outputs.tag }} | |
| - name: Publish wagmi connector to NPM | |
| working-directory: packages/connector-export | |
| run: npm publish --access public --tag ${{ steps.npm_tag.outputs.tag }} | |
| - name: Publish web SDK to NPM | |
| working-directory: packages/sdk-platforms/web | |
| run: npm publish --access public --tag ${{ steps.npm_tag.outputs.tag }} | |
| - name: Create .npmrc for GitHub Packages | |
| run: | | |
| echo "@matter-labs:registry=https://npm.pkg.github.com" > ~/.npmrc | |
| echo "@zksync-sso:registry=https://npm.pkg.github.com" >> ~/.npmrc | |
| echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> ~/.npmrc | |
| - name: Publish SDK to GitHub Packages | |
| working-directory: packages/sdk | |
| run: | | |
| # Update package name for GitHub Packages to be scoped to the organization | |
| npm pkg set name="@matter-labs/zksync-sso" | |
| npm publish --registry=https://npm.pkg.github.com --tag ${{ steps.npm_tag.outputs.tag }} | |
| - name: Publish wagmi connector to GitHub Packages | |
| working-directory: packages/connector-export | |
| run: | | |
| # Update package name for GitHub Packages to be scoped to the organization | |
| npm pkg set name="@matter-labs/zksync-sso-wagmi-connector" | |
| npm publish --registry=https://npm.pkg.github.com --tag ${{ steps.npm_tag.outputs.tag }} | |
| - name: Publish web SDK to GitHub Packages | |
| working-directory: packages/sdk-platforms/web | |
| run: | | |
| # Update package name for GitHub Packages to be scoped to the organization | |
| npm pkg set name="@matter-labs/zksync-sso-web-sdk" | |
| npm publish --registry=https://npm.pkg.github.com --tag ${{ steps.npm_tag.outputs.tag }} |