build: only stamp version info when releasing (#27362)

Also build releases into a dedicated output_base so you can't
accidentally publish with outdated version stamp.

Bump the version of rules_nodejs so we don't need to create the
symlink_prefixes for the .publish command to work.

PR Close #27362
This commit is contained in:
Alex Eagle 2018-11-29 17:10:29 -08:00 committed by Igor Minar
parent 35e02ad5e0
commit f5f323dae0
6 changed files with 22 additions and 12 deletions

View File

@ -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 #

View File

@ -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(

View File

@ -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)

View File

@ -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}

View File

@ -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

View File

@ -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