diff --git a/.github/workflows/publish-es-packages.yml b/.github/workflows/publish-es-packages.yml index 7eec3939f8d..e0cd3643d2b 100644 --- a/.github/workflows/publish-es-packages.yml +++ b/.github/workflows/publish-es-packages.yml @@ -2,13 +2,23 @@ name: Publish Noir ES Packages on: workflow_dispatch: - + inputs: + noir-ref: + description: The noir reference to checkout + required: false + npm-tag: + description: Repository Tag to publish under + required: false + default: 'nightly' + jobs: build-noir_wasm: runs-on: ubuntu-latest steps: - name: Checkout sources uses: actions/checkout@v4 + with: + ref: ${{ inputs.noir-ref || 'master' }} - name: Setup Nix uses: ./.github/actions/nix @@ -17,6 +27,11 @@ jobs: nix-cache-name: ${{ vars.NIX_CACHE_NAME }} cachix-auth-token: ${{ secrets.CACHIXAUTHTOKEN }} + - name: Enable aztec features + if: ${{ inputs.npm-tag == 'aztec' }} + run: | + echo "\ndefault = [\"aztec\"]" >> compiler/noirc_frontend/Cargo.toml + - name: Build wasm package run: | nix build -L .#noir_wasm @@ -26,6 +41,8 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v4 + with: + ref: ${{ inputs.noir-ref || 'master' }} - name: Setup Nix uses: ./.github/actions/nix @@ -43,6 +60,8 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v4 + with: + ref: ${{ inputs.noir-ref || 'master' }} - name: Setup Nix uses: ./.github/actions/nix @@ -61,6 +80,8 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v4 + with: + ref: ${{ inputs.noir-ref || 'master' }} - name: Setup Nix uses: ./.github/actions/nix @@ -72,11 +93,26 @@ jobs: - name: Install Yarn dependencies run: yarn install + - name: Enable aztec features + if: ${{ inputs.npm-tag == 'aztec' }} + run: | + echo "\ndefault = [\"aztec\"]" >> compiler/noirc_frontend/Cargo.toml + - name: Build ES Packages run: yarn prepare:publish + - name: Prepare nightly version + if: ${{ inputs.npm-tag == 'nightly' }} + run: | + sudo apt-get install jq + yarn nightly:version + + - name: Update Version as specific + run: | + jq '.version = .version + "-${{ inputs.npm-tag }}"' package.json > package-tmp.json && mv package-tmp.json package.json + - name: Authenticate with npm run: "echo npmAuthToken: ${{ secrets.NPM_TOKEN }} > ~/.yarnrc.yml" - + - name: Publish ES Packages - run: yarn publish:all --access public \ No newline at end of file + run: yarn publish:all --access public --tag ${{ inputs.npm-tag }} \ No newline at end of file diff --git a/.github/workflows/publish-noir-wasm-aztec.yml b/.github/workflows/publish-noir-wasm-aztec.yml deleted file mode 100644 index cae345113d0..00000000000 --- a/.github/workflows/publish-noir-wasm-aztec.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Publish Noir Wasm - -on: - workflow_dispatch: - -jobs: - publish-noir-wasm: - runs-on: ubuntu-22.04 - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - uses: actions/cache@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - - uses: cachix/install-nix-action@v22 - with: - nix_path: nixpkgs=channel:nixos-23.05 - - - name: Build with Nix - run: nix build .#noir_wasm_aztec - - - name: Discover Build Output Path - run: echo "BUILD_OUTPUT_PATH=$(readlink -f ./result/noir_wasm)" >> $GITHUB_ENV - - - name: Copy Build Output to Temporary Directory - run: | - mkdir temp_publish_dir - cp -r ${{ env.BUILD_OUTPUT_PATH }}/* temp_publish_dir/ - touch temp_publish_dir/yarn.lock - - - name: Authenticate with npm - run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc - - - name: Publish to NPM - working-directory: ./temp_publish_dir - run: yarn npm publish --tag aztec - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/compiler/wasm/buildPhaseCargoCommand.sh b/compiler/wasm/buildPhaseCargoCommand.sh index c0942da972a..2ab0f1eb3cb 100755 --- a/compiler/wasm/buildPhaseCargoCommand.sh +++ b/compiler/wasm/buildPhaseCargoCommand.sh @@ -32,8 +32,8 @@ NODE_WASM=${NODE_DIR}/${pname}_bg.wasm BROWSER_WASM=${BROWSER_DIR}/${pname}_bg.wasm # Build the new wasm package -run_or_fail cargo build --lib --release --target $TARGET --package ${pname} --features ${features:-''} +run_or_fail cargo build --lib --release --target $TARGET --package ${pname} ${cargoExtraArgs} run_or_fail wasm-bindgen $WASM_BINARY --out-dir $NODE_DIR --typescript --target nodejs run_or_fail wasm-bindgen $WASM_BINARY --out-dir $BROWSER_DIR --typescript --target web run_if_available wasm-opt $NODE_WASM -o $NODE_WASM -O -run_if_available wasm-opt $BROWSER_WASM -o $BROWSER_WASM -O +run_if_available wasm-opt $BROWSER_WASM -o $BROWSER_WASM -O \ No newline at end of file diff --git a/compiler/wasm/installPhase.sh b/compiler/wasm/installPhase.sh index b952d7d553e..e5be98a3339 100755 --- a/compiler/wasm/installPhase.sh +++ b/compiler/wasm/installPhase.sh @@ -3,20 +3,8 @@ export self_path=$(dirname "$(readlink -f "$0")") export out_path=$out/noir_wasm -SEMVER_SUFFIX="" - -# e.g. v1.0.0-alpha -if [[ -n "${SEMVER_PRE_RELEASE}" ]]; then - SEMVER_SUFFIX="$SEMVER_SUFFIX-$SEMVER_PRE_RELEASE" -fi - -# e.g. v1.0.0-alpha+sha.abcdef -if [[ -n "${SEMVER_BUILD_META}" ]]; then - SEMVER_SUFFIX="$SEMVER_SUFFIX+$SEMVER_BUILD_META" -fi - mkdir -p $out_path cp $self_path/README.md $out_path/ -jq --arg semver_suffix "$SEMVER_SUFFIX" '.version = .version + $semver_suffix' $self_path/package.json > $out_path/package.json +cp $self_path/package.json $out_path/ cp -r $self_path/nodejs $out_path/ cp -r $self_path/web $out_path/ diff --git a/flake.nix b/flake.nix index 5818eacdab1..c9225dedbde 100644 --- a/flake.nix +++ b/flake.nix @@ -159,16 +159,6 @@ doCheck = false; }); - # this will be nicer once Configurable Derivations exist - # https://github.com/NixOS/nix/pull/6583 - noir_wasm_aztec = noir_wasm.overrideAttrs (finalAttrs: prevAttrs: { - name = "noir_wasm_aztec"; - features = "noirc_frontend/aztec"; - # build metadata is ignored by npm - # to ensure aztec and non-aztec builds don't get mixed up, use a pre-release tag - SEMVER_PRE_RELEASE = "aztec"; - }); - noirc_abi_wasm = craneLib.buildPackage (wasmConfig // rec { pname = "noirc_abi_wasm"; @@ -249,7 +239,6 @@ # We also export individual packages to enable `nix build .#nargo -L`, etc. inherit nargo; inherit noir_wasm; - inherit noir_wasm_aztec; inherit noirc_abi_wasm; inherit acvm_js;