Skip to content
Open
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
257 changes: 257 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
name: Publish

on:
workflow_dispatch:
inputs:
build_mode:
description: 'Build mode: standard = same SnarkVM on testnet+mainnet; split = testnet is ahead'
type: choice
options: [standard, split]
required: true
dry_run:
description: 'Dry run: skip npm publish, git tag, and GitHub release'
type: boolean
default: true

jobs:
# ── STANDARD MODE ─────────────────────────────────────────────────────────
# Used when testnet and mainnet are on the same SnarkVM version.
# Runs yarn build:all, tests, publishes all three packages, then tags.

build-standard:
name: Build (standard)
if: inputs.build_mode == 'standard'
runs-on: ubuntu-latest-m
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-yarn
- uses: ./.github/actions/setup-rust

- name: Build
run: yarn build:all

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build
path: |
sdk/dist/
wasm/dist/
create-leo-app/dist/

test-standard:
name: Test (standard)
if: inputs.build_mode == 'standard'
needs: build-standard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-yarn
- uses: ./.github/actions/use-build

- name: Test SDK
run: yarn test:sdk

Copilot AI Mar 10, 2026

Copy link

Choose a reason for hiding this comment

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

The publish workflow only runs yarn test:sdk and does not run WASM tests (yarn test:wasm). CI in .github/workflows/sdk.yml runs both, so releases could ship broken WASM outputs. Consider running yarn test (or at least adding yarn test:wasm) before publishing.

Suggested change
run: yarn test:sdk
run: yarn test:sdk && yarn test:wasm

Copilot uses AI. Check for mistakes.

publish-standard:
name: Publish (standard)
if: inputs.build_mode == 'standard'
needs: test-standard
runs-on: ubuntu-latest
environment: production
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v4
with:
registry-url: https://registry.npmjs.org

- uses: ./.github/actions/use-build

- name: Read version
id: version
run: |
VERSION=$(node -p "require('./wasm/package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT

Comment on lines +73 to +79

Copilot AI Mar 10, 2026

Copy link

Choose a reason for hiding this comment

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

Tagging is derived only from wasm/package.json’s version. If sdk / create-leo-app versions drift (or if sdk’s dependency range doesn’t match), the git tag and GitHub release will not correspond to what was actually published. Consider validating all three package versions match (and that sdk depends on the same version) before publishing/tagging, and fail the workflow if they differ.

Copilot uses AI. Check for mistakes.
- name: Publish @provablehq/wasm
if: ${{ !inputs.dry_run }}
working-directory: wasm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish @provablehq/sdk
if: ${{ !inputs.dry_run }}
working-directory: sdk
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish create-leo-app
if: ${{ !inputs.dry_run }}
working-directory: create-leo-app
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Tag and release
if: ${{ !inputs.dry_run }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag ${{ steps.version.outputs.tag }}
git push origin ${{ steps.version.outputs.tag }}
gh release create "${{ steps.version.outputs.tag }}" --generate-notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Dry run summary
if: ${{ inputs.dry_run }}
run: |
echo "## Dry run — nothing was published" >> $GITHUB_STEP_SUMMARY
echo "Would have published version **${{ steps.version.outputs.version }}**:" >> $GITHUB_STEP_SUMMARY
echo "- \`@provablehq/wasm\`" >> $GITHUB_STEP_SUMMARY
echo "- \`@provablehq/sdk\`" >> $GITHUB_STEP_SUMMARY
echo "- \`create-leo-app\`" >> $GITHUB_STEP_SUMMARY
echo "- Git tag: \`${{ steps.version.outputs.tag }}\`" >> $GITHUB_STEP_SUMMARY


# ── SPLIT MODE ────────────────────────────────────────────────────────────
# Used when the testnet SnarkVM version is ahead of mainnet.
# Builds testnet WASM from the testnet branch, mainnet WASM from mainnet,
# combines them, then builds the SDK and publishes.

build-testnet-wasm:
name: Build testnet WASM (split)
if: inputs.build_mode == 'split'
runs-on: ubuntu-latest-m
steps:
- uses: actions/checkout@v4
with:
ref: testnet
- uses: ./.github/actions/setup-yarn
- uses: ./.github/actions/setup-rust

- name: Build testnet WASM
run: yarn build:wasm

- name: Upload testnet WASM artifact
uses: actions/upload-artifact@v4
with:
name: testnet-wasm
path: wasm/dist/testnet/

build-split:
name: Build (split)
if: inputs.build_mode == 'split'
needs: build-testnet-wasm
runs-on: ubuntu-latest-m
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-yarn
- uses: ./.github/actions/setup-rust

- name: Build mainnet WASM
run: yarn build:wasm

- name: Download testnet WASM artifact
uses: actions/download-artifact@v4
with:
name: testnet-wasm
path: wasm/dist/testnet/

Comment on lines +158 to +166

Copilot AI Mar 10, 2026

Copy link

Choose a reason for hiding this comment

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

In split mode, yarn build:wasm on the mainnet branch generates wasm/dist/testnet (see wasm/build.js which always builds both networks). Downloading the testnet artifact into the same path without deleting it first risks leaving stale/incorrect files from the mainnet build. Remove wasm/dist/testnet before the download (or download to a temp dir and then move/replace).

Copilot uses AI. Check for mistakes.
- name: Build SDK and create-leo-app
run: yarn build:sdk && yarn build:create-leo-app

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build
path: |
sdk/dist/
wasm/dist/
create-leo-app/dist/

test-split:
name: Test (split)
if: inputs.build_mode == 'split'
needs: build-split
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-yarn
- uses: ./.github/actions/use-build

- name: Test SDK
run: yarn test:sdk
Comment on lines +189 to +190

Copilot AI Mar 10, 2026

Copy link

Choose a reason for hiding this comment

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

Same as standard mode: split-mode release tests only run yarn test:sdk and skip yarn test:wasm, even though the workflow builds and publishes the WASM package. Consider running yarn test (or yarn test:wasm) here before publishing.

Suggested change
- name: Test SDK
run: yarn test:sdk
- name: Test SDK and WASM
run: |
yarn test:sdk
yarn test:wasm

Copilot uses AI. Check for mistakes.

publish-split:
name: Publish (split)
if: inputs.build_mode == 'split'
needs: test-split
runs-on: ubuntu-latest
environment: production
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v4
with:
registry-url: https://registry.npmjs.org

- uses: ./.github/actions/use-build

- name: Read version
id: version
run: |
VERSION=$(node -p "require('./wasm/package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT

Comment on lines +210 to +216

Copilot AI Mar 10, 2026

Copy link

Choose a reason for hiding this comment

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

Same versioning concern in split mode: the workflow tags/releases based on wasm/package.json only. Add a consistency check across wasm, sdk, and create-leo-app versions (and sdk’s @provablehq/wasm dependency) to avoid publishing mismatched versions under a single tag.

Suggested change
- name: Read version
id: version
run: |
VERSION=$(node -p "require('./wasm/package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
- name: Read and validate versions
id: version
run: |
node <<'EOF' >> "$GITHUB_OUTPUT"
const fs = require('fs');
function readJson(path) {
return JSON.parse(fs.readFileSync(path, 'utf8'));
}
const wasmPkg = readJson('./wasm/package.json');
const sdkPkg = readJson('./sdk/package.json');
const claPkg = readJson('./create-leo-app/package.json');
const wasmVersion = wasmPkg.version;
const sdkVersion = sdkPkg.version;
const claVersion = claPkg.version;
const sdkDeps = Object.assign(
{},
sdkPkg.dependencies || {},
sdkPkg.devDependencies || {}
);
let sdkWasmDep = sdkDeps['@provablehq/wasm'];
function normalize(v) {
return (v || '').replace(/^[~^]/, '');
}
const normWasm = normalize(wasmVersion);
const normSdk = normalize(sdkVersion);
const normCla = normalize(claVersion);
const normSdkDep = normalize(sdkWasmDep);
let mismatches = [];
if (!normWasm) {
mismatches.push('Missing or empty wasm version');
}
if (normSdk && normSdk !== normWasm) {
mismatches.push(`sdk version (${sdkVersion}) != wasm version (${wasmVersion})`);
}
if (normCla && normCla !== normWasm) {
mismatches.push(`create-leo-app version (${claVersion}) != wasm version (${wasmVersion})`);
}
if (sdkWasmDep && normSdkDep !== normWasm) {
mismatches.push(`sdk dependency @provablehq/wasm (${sdkWasmDep}) != wasm version (${wasmVersion})`);
}
if (!sdkWasmDep) {
mismatches.push('sdk is missing @provablehq/wasm dependency');
}
if (mismatches.length > 0) {
console.error('Version mismatch detected in split publish:');
for (const msg of mismatches) {
console.error(' - ' + msg);
}
process.exit(1);
}
console.log(`version=${wasmVersion}`);
console.log(`tag=v${wasmVersion}`);
EOF

Copilot uses AI. Check for mistakes.
- name: Publish @provablehq/wasm
if: ${{ !inputs.dry_run }}
working-directory: wasm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish @provablehq/sdk
if: ${{ !inputs.dry_run }}
working-directory: sdk
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish create-leo-app
if: ${{ !inputs.dry_run }}
working-directory: create-leo-app
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Tag and release
if: ${{ !inputs.dry_run }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag ${{ steps.version.outputs.tag }}
git push origin ${{ steps.version.outputs.tag }}
gh release create "${{ steps.version.outputs.tag }}" --generate-notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Dry run summary
if: ${{ inputs.dry_run }}
run: |
echo "## Dry run — nothing was published" >> $GITHUB_STEP_SUMMARY
echo "Would have published version **${{ steps.version.outputs.version }}**:" >> $GITHUB_STEP_SUMMARY
echo "- \`@provablehq/wasm\`" >> $GITHUB_STEP_SUMMARY
echo "- \`@provablehq/sdk\`" >> $GITHUB_STEP_SUMMARY
echo "- \`create-leo-app\`" >> $GITHUB_STEP_SUMMARY
echo "- Git tag: \`${{ steps.version.outputs.tag }}\`" >> $GITHUB_STEP_SUMMARY
52 changes: 50 additions & 2 deletions PUBLISH.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
## Publish instructions
## Building the SDK for an npm release

Replace `$VERSION` with the desired new version (e.g. `0.7.0`):

### Building a standard release.
When building a release in which the underlying SnarkVM version is the same for both testnet and mainnet, this build
flow is used.

First, replace `$VERSION` with the desired new version on the mainnet branch (e.g. `0.9.18`), then use the following
commands.

```bash
yarn build:all
Expand All @@ -10,4 +16,46 @@ cd ../sdk && npm publish --access public
cd ../create-leo-app & npm publish --access public

Copilot AI Mar 10, 2026

Copy link

Choose a reason for hiding this comment

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

In bash, cd ../create-leo-app & npm publish ... runs the cd in the background (in a subshell) so the directory change won’t apply; npm publish will likely run from the wrong directory. Use && to ensure the publish runs in create-leo-app.

Copilot uses AI. Check for mistakes.
git tag vX.X.X
git push origin vX.X.X
gh release create "$(git describe --tags --abbrev=0)" --generate-notes
```

### Building a release in which the SnarkVM version is ahead of testnet.
The wasm package contains two JS binaries, one for testnet and one for mainnet. When the Aleo testnet and mainnet
networks are operating on the same SnarkVM binaries `yarn build:all` is the correct command to build the SDK's binaries.

However, in the case where the Aleo network releases a testnet version that is ahead of mainnet, the testnet version
must be built separately. The following build flow is used to publish the SDK. Once all needed changes are integrated
for Aleo testnet, this should be merged to the testnet branch of the SDK and the following build process should be
followed.

First, replace `$VERSION` with the desired new version on the mainnet and testnet branches (e.g. `0.9.18`), then use
the following commands.

```bash
## Create a tempdir to store the testnet wasm build.
mkdir tmp
## Switch to testnet.
git switch testnet
## Build the wasm version of testnet and store it in a tempdir.
yarn build:wasm
mv wasm/dist/testnet tmp/testnet
## Switch to mainnet.
git switch mainnet
## Build the wasm package.
yarn build:wasm
## Remove the testnet build.
rm -r wasm/dist/testnet
## Move the previously built testnet version into the wasm/dist folder and remove the tmp folder.
mv tmp/testnet wasm/dist/testnet
rmdir tmp
## Continue building the SDK and create-leo-app binaries.
yarn build:sdk && yarn build:create-leo-app
## Continue the previous NPM publishing flow.
npm login
cd wasm && npm publish --access public
cd ../sdk && npm publish --access public
cd ../create-leo-app & npm publish --access public

Copilot AI Mar 10, 2026

Copy link

Choose a reason for hiding this comment

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

Same issue here: cd ../create-leo-app & npm publish ... backgrounds the cd so npm publish may run from the wrong directory. Use && so the publish runs in create-leo-app.

Copilot uses AI. Check for mistakes.
git tag vX.X.X
git push origin vX.X.X
gh release create "$(git describe --tags --abbrev=0)" --generate-notes
```