diff --git a/.bazelrc b/.bazelrc index 713d691080..c87a7fa67a 100644 --- a/.bazelrc +++ b/.bazelrc @@ -30,10 +30,12 @@ test --nolegacy_external_runfiles ############################### # Release support # +# Turn on these settings with # +# --config=release # ############################### # Releases should always be stamped with version control info -build --workspace_status_command=./tools/bazel_stamp_vars.sh +build:release --workspace_status_command=./tools/bazel_stamp_vars.sh ############################### # Output # diff --git a/packages/bazel/package.bzl b/packages/bazel/package.bzl index 1d043ec8e0..e956f0d058 100644 --- a/packages/bazel/package.bzl +++ b/packages/bazel/package.bzl @@ -18,12 +18,13 @@ def rules_angular_dependencies(): # # Download Bazel toolchain dependencies as needed by build actions - # + # Use a SHA to get fix for needing symlink_prefix during npm publishing + # TODO(alexeagle): updated to next tagged rules_typescript release _maybe( http_archive, name = "build_bazel_rules_nodejs", - url = "https://github.com/bazelbuild/rules_nodejs/archive/0.16.2.zip", - strip_prefix = "rules_nodejs-0.16.2", + url = "https://github.com/bazelbuild/rules_nodejs/archive/ee218e2a98b9f09ba07cecac8496a5918c47bc5d.zip", + strip_prefix = "rules_nodejs-ee218e2a98b9f09ba07cecac8496a5918c47bc5d", ) _maybe( diff --git a/packages/bazel/src/esm5.bzl b/packages/bazel/src/esm5.bzl index adc31a309d..52e278bbc7 100644 --- a/packages/bazel/src/esm5.bzl +++ b/packages/bazel/src/esm5.bzl @@ -165,7 +165,7 @@ def flatten_esm5(ctx): ctx: the skylark rule execution context Returns: - list of flattened files + depset of flattened files """ esm5_sources = [] result = [] @@ -186,4 +186,4 @@ def flatten_esm5(ctx): template = f, substitutions = {}, ) - return result + return depset(result) diff --git a/scripts/build-packages-dist.sh b/scripts/build-packages-dist.sh index e9da5efbee..89ecc1b946 100755 --- a/scripts/build-packages-dist.sh +++ b/scripts/build-packages-dist.sh @@ -29,7 +29,8 @@ function buildTargetPackages() { echo " mode: ${desc}" echo "##################################" - echo "$targets" | xargs ${bazelBin} build --define=compile=$compileMode + # Use --config=release so that snapshot builds get published with embedded version info + echo "$targets" | xargs ${bazelBin} build --config=release --define=compile=$compileMode [ -d "${basedir}/${destPath}" ] || mkdir -p $basedir/${destPath} diff --git a/scripts/release/publish-latest b/scripts/release/publish-latest index 4f507d8dc1..f3b46e804a 100755 --- a/scripts/release/publish-latest +++ b/scripts/release/publish-latest @@ -2,21 +2,24 @@ set -u -e -o pipefail -# Use for BETA and RC releases +# Use for production releases # Query Bazel for npm_package and ng_package rules with tags=["release-with-framework"] # Publish them to npm (tagged next) # We need to resolve the Bazel binary in the node modules because running Bazel # through `yarn bazel` causes additional output that throws off the command stdout. BAZEL_BIN=$(yarn bin)/bazel +# Build into a distinct output location so that artifacts from previous builds are not reused +BAZEL_OUTPUT_BASE=$(mktemp -d -t angular-release-latest.XXXXXXX) +BAZEL="$BAZEL_BIN --output_base=$BAZEL_OUTPUT_BASE" # query for all npm packages to be released as part of the framework release NPM_PACKAGE_LABELS=`${BAZEL_BIN} query --output=label 'attr("tags", "\[.*release-with-framework.*\]", //packages/...) intersect kind(".*_package", //packages/...)'` # build all npm packages in parallel -${BAZEL_BIN} build $NPM_PACKAGE_LABELS +$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_BIN} run -- ${packageLabel}.publish --access public --tag latest + $BAZEL run -- ${packageLabel}.publish --access public --tag latest done diff --git a/scripts/release/publish-next b/scripts/release/publish-next index ddcf703f2f..321bbc6403 100755 --- a/scripts/release/publish-next +++ b/scripts/release/publish-next @@ -9,13 +9,16 @@ set -u -e -o pipefail # We need to resolve the Bazel binary in the node modules because running Bazel # through `yarn bazel` causes additional output that throws off the command stdout. BAZEL_BIN=$(yarn bin)/bazel +# Build into a distinct output location so that artifacts from previous builds are not reused +BAZEL_OUTPUT_BASE=$(mktemp -d -t angular-release-next.XXXXXXX) +BAZEL="$BAZEL_BIN --output_base=$BAZEL_OUTPUT_BASE" # query for all npm packages to be released as part of the framework release NPM_PACKAGE_LABELS=`${BAZEL_BIN} query --output=label 'attr("tags", "\[.*release-with-framework.*\]", //packages/...) intersect kind(".*_package", //packages/...)'` # build all npm packages in parallel -${BAZEL_BIN} build $NPM_PACKAGE_LABELS +$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_BIN} run -- ${packageLabel}.publish --access public --tag next + $BAZEL run -- ${packageLabel}.publish --access public --tag next done