diff --git a/.github/workflows/noir-js.yml b/.github/workflows/noir-js.yml index accdc720942..e8b210feb06 100644 --- a/.github/workflows/noir-js.yml +++ b/.github/workflows/noir-js.yml @@ -14,11 +14,39 @@ jobs: - name: Install dependencies run: yarn install --immutable + - name: Install jq + run: sudo apt-get install jq + + - name: Install cargo and wasm-bindgen + run: | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + source $HOME/.cargo/env + cargo install -f wasm-bindgen-cli --version 0.2.86 + + - name: Install toml2json + run: | + source $HOME/.cargo/env + cargo install toml2json + + - name: Install wasm-opt + run: | + npm i wasm-opt -g + + - name: Install wasm32-unknown-unknwown target + run: | + rustup target add wasm32-unknown-unknown + + - name: Build noirc_abi + run: yarn workspace @noir-lang/noirc_abi build + - name: Build noir_js run: yarn workspace @noir-lang/noir_js build + - name: Authenticate with npm + run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc + - name: Publish to NPM working-directory: ./tooling/noir_js - run: npm publish + run: npm publish --access public env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} \ No newline at end of file + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b3cecf25144..1be360068da 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -80,6 +80,19 @@ jobs: token: ${{ secrets.NOIR_REPO_TOKEN }} inputs: '{ "noir-ref": "${{ needs.release-please.outputs.tag-name }}" }' + publish-noir-js: + name: Publish noir_js package + needs: [release-please] + if: ${{ needs.release-please.outputs.tag-name }} + runs-on: ubuntu-latest + steps: + - name: Dispatch to noir_wasm + uses: benc-uk/workflow-dispatch@v1 + with: + workflow: noir-js.yml + ref: master + token: ${{ secrets.NOIR_REPO_TOKEN }} + dispatch-publish-abi-wasm: name: Dispatch to publish-abi_wasm workflow needs: [release-please] diff --git a/.gitignore b/.gitignore index a4111fad7c0..e36a7458e7b 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,9 @@ compiler/source-resolver/node_modules compiler/source-resolver/lib compiler/source-resolver/lib-node +# Noir.js +tooling/noir_js/lib + # Nix stuff **/outputs result diff --git a/release-please-config.json b/release-please-config.json index e06379f5ae7..01df7d1a7a5 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -22,6 +22,11 @@ "type": "json", "path": "tooling/noirc_abi_wasm/package.json", "jsonpath": "$.version" + }, + { + "type": "json", + "path": "tooling/noir_js/package.json", + "jsonpath": "$.version" } ] } diff --git a/tooling/noir_js/package.json b/tooling/noir_js/package.json index 5303b0aacbd..5eeccc3c790 100644 --- a/tooling/noir_js/package.json +++ b/tooling/noir_js/package.json @@ -9,5 +9,17 @@ "dependencies": { "@noir-lang/acvm_js": "0.26.1", "@noir-lang/noirc_abi": "workspace:*" + }, + "files": [ + "lib", + "package.json" + ], + "main": "lib/index.js", + "types": "lib/index.d.ts", + "scripts": { + "build": "tsc" + }, + "devDependencies": { + "typescript": "^5.2.2" } } diff --git a/tooling/noir_js/index.ts b/tooling/noir_js/src/index.ts similarity index 100% rename from tooling/noir_js/index.ts rename to tooling/noir_js/src/index.ts diff --git a/tooling/noir_js/tsconfig.json b/tooling/noir_js/tsconfig.json new file mode 100644 index 00000000000..45c1f060a57 --- /dev/null +++ b/tooling/noir_js/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "target": "esnext", + "declaration": true, + "emitDeclarationOnly": false, + "module": "ESNext", + "moduleResolution": "node", + "outDir": "./lib", + "esModuleInterop": true, + "strict": true + }, + "include": ["src/**/*.ts"], + "exclude": ["node_modules"] +} diff --git a/tooling/noirc_abi_wasm/build.sh b/tooling/noirc_abi_wasm/build.sh index 22acdd06cba..8157e42c6de 100755 --- a/tooling/noirc_abi_wasm/build.sh +++ b/tooling/noirc_abi_wasm/build.sh @@ -38,7 +38,7 @@ rm -rf $self_path/result >/dev/null 2>&1 if [ -v out ]; then echo "Will install package to $out (defined outside installPhase.sh script)" else - out="$self_path/outputs/out" + export out="$self_path/outputs/out" echo "Will install package to $out" fi diff --git a/yarn.lock b/yarn.lock index abc84a8a5a7..29a07f2d1e5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -415,6 +415,7 @@ __metadata: dependencies: "@noir-lang/acvm_js": 0.26.1 "@noir-lang/noirc_abi": "workspace:*" + typescript: ^5.2.2 languageName: unknown linkType: soft @@ -7085,7 +7086,7 @@ __metadata: languageName: node linkType: hard -"typescript@npm:^5.0.4": +"typescript@npm:^5.0.4, typescript@npm:^5.2.2": version: 5.2.2 resolution: "typescript@npm:5.2.2" bin: @@ -7105,7 +7106,7 @@ __metadata: languageName: node linkType: hard -"typescript@patch:typescript@^5.0.4#~builtin": +"typescript@patch:typescript@^5.0.4#~builtin, typescript@patch:typescript@^5.2.2#~builtin": version: 5.2.2 resolution: "typescript@patch:typescript@npm%3A5.2.2#~builtin::version=5.2.2&hash=f3b441" bin: