Skip to content

Commit

Permalink
chore: simpler aztec publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
kobyhallx committed Oct 10, 2023
1 parent 3eff03e commit 4dcde8f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 76 deletions.
42 changes: 39 additions & 3 deletions .github/workflows/publish-es-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
run: yarn publish:all --access public --tag ${{ inputs.npm-tag }}
47 changes: 0 additions & 47 deletions .github/workflows/publish-noir-wasm-aztec.yml

This file was deleted.

4 changes: 2 additions & 2 deletions compiler/wasm/buildPhaseCargoCommand.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 1 addition & 13 deletions compiler/wasm/installPhase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/
11 changes: 0 additions & 11 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 4dcde8f

Please sign in to comment.