From 6b4d116cce8d0ffb933e7922b6d5c7dea30ea7c0 Mon Sep 17 00:00:00 2001 From: Keen Yee Liau Date: Thu, 20 Feb 2020 13:24:35 -0800 Subject: [PATCH] build: Update publish script Update the publish script to invoke existing build command, then run the script generated by Bazel npm_package target to publish to npm. --- docs/process/release.md | 4 ++-- publish-next.sh | 19 ------------------- publish.sh | 29 ++++++++++++++++------------- scripts/package-builder.sh | 6 +++++- 4 files changed, 23 insertions(+), 35 deletions(-) delete mode 100755 publish-next.sh diff --git a/docs/process/release.md b/docs/process/release.md index a2ec3dc64..135ae25df 100644 --- a/docs/process/release.md +++ b/docs/process/release.md @@ -17,12 +17,12 @@ git push upstream && git push upstream --tags - Publish ```sh # For release with 'next' tag -./publish-next.sh +./publish.sh next ``` ```sh # For release with 'latest' tag -./publish.sh +./publish.sh latest ``` # Release Changelog diff --git a/publish-next.sh b/publish-next.sh deleted file mode 100755 index ebb3d9f84..000000000 --- a/publish-next.sh +++ /dev/null @@ -1,19 +0,0 @@ - -#!/usr/bin/env bash - -set -u -e -o pipefail - -# Use for BETA and RC releases -# Query Bazel for npm_package and ng_package rules -# Publish them to npm (tagged next) - -# query for all npm packages to be released as part of the framework release -NPM_PACKAGE_LABELS=`bazel query --output=label 'attr("tags", "\[.*release.*\]", //modules/...) intersect kind(".*_package", //modules/...)'` -# build all npm packages in parallel -bazel build --config=release $NPM_PACKAGE_LABELS - -# publish all packages in sequence to make it easier to spot any errors or warnings -for packageLabel in $NPM_PACKAGE_LABELS; do - echo "publishing $packageLabel" - bazel run --config=release -- ${packageLabel}.publish --access public --tag next -done diff --git a/publish.sh b/publish.sh index 42779fc67..d991acd80 100755 --- a/publish.sh +++ b/publish.sh @@ -1,19 +1,22 @@ - #!/usr/bin/env bash -set -u -e -o pipefail +source $(dirname $0)/scripts/package-builder.sh + +readonly tag="$1" -# Use for BETA and RC releases -# Query Bazel for npm_package and ng_package rules -# Publish them to npm (tagged next) +if [[ $tag != 'latest' && $tag != 'next' ]]; then + echo "Invalid tag: ${tag}. Must be either 'latest' or 'next'" + exit 1 +fi -# query for all npm packages to be released as part of the framework release -NPM_PACKAGE_LABELS=`bazel query --output=label 'attr("tags", "\[.*release.*\]", //modules/...) intersect kind(".*_package", //modules/...)'` -# build all npm packages in parallel -bazel build --config=release $NPM_PACKAGE_LABELS +# Build the npm packages +buildTargetPackages "dist/modules-dist" "legacy" "Production" -# publish all packages in sequence to make it easier to spot any errors or warnings -for packageLabel in $NPM_PACKAGE_LABELS; do - echo "publishing $packageLabel" - bazel run --config=release -- ${packageLabel}.publish --access public --tag latest +# Publish all packages to NPM +for target in $(getAllPackages); do + echo "==============================================" + echo "Publishing ${target}" + echo "==============================================" + ${bazel_bin} run --config=release "${target}.publish" -- \ + --access public --tag "${tag}" done diff --git a/scripts/package-builder.sh b/scripts/package-builder.sh index bed69b5ef..6925398d5 100644 --- a/scripts/package-builder.sh +++ b/scripts/package-builder.sh @@ -22,9 +22,13 @@ readonly base_dir=$(pwd)/.. readonly bazel_bin=$(yarn bin)/bazel readonly bin=$(${bazel_bin} info bazel-bin) +function getAllPackages() { + ${bazel_bin} query --output=label 'attr("tags", "\[.*release\]", //modules/...) intersect kind("pkg_npm|ng_package", //modules/...)' +} + function buildTargetPackages() { # List of targets to build, e.g. core, common, compiler, etc. - targets=$(${bazel_bin} query --output=label 'attr("tags", "\[.*release\]", //modules/...) intersect kind("pkg_npm|ng_package", //modules/...)') + targets=$(getAllPackages) # Path to the output directory into which we copy the npm packages. dest_path="$1"