Skip to content

Commit

Permalink
build: only stamp version info when releasing (#27362)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alexeagle authored and IgorMinar committed Dec 1, 2018
1 parent 35e02ad commit f5f323d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
Expand Down
7 changes: 4 additions & 3 deletions packages/bazel/package.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions packages/bazel/src/esm5.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -186,4 +186,4 @@ def flatten_esm5(ctx):
template = f,
substitutions = {},
)
return result
return depset(result)
3 changes: 2 additions & 1 deletion scripts/build-packages-dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
9 changes: 6 additions & 3 deletions scripts/release/publish-latest
Original file line number Diff line number Diff line change
Expand Up @@ -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

7 changes: 5 additions & 2 deletions scripts/release/publish-next
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f5f323d

Please sign in to comment.