Skip to content

Commit f5f323d

Browse files
alexeagleIgorMinar
authored andcommitted
build: only stamp version info when releasing (angular#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 angular#27362
1 parent 35e02ad commit f5f323d

6 files changed

Lines changed: 22 additions & 12 deletions

File tree

.bazelrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ test --nolegacy_external_runfiles
3030

3131
###############################
3232
# Release support #
33+
# Turn on these settings with #
34+
# --config=release #
3335
###############################
3436

3537
# Releases should always be stamped with version control info
36-
build --workspace_status_command=./tools/bazel_stamp_vars.sh
38+
build:release --workspace_status_command=./tools/bazel_stamp_vars.sh
3739

3840
###############################
3941
# Output #

packages/bazel/package.bzl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ def rules_angular_dependencies():
1818

1919
#
2020
# Download Bazel toolchain dependencies as needed by build actions
21-
#
21+
# Use a SHA to get fix for needing symlink_prefix during npm publishing
22+
# TODO(alexeagle): updated to next tagged rules_typescript release
2223
_maybe(
2324
http_archive,
2425
name = "build_bazel_rules_nodejs",
25-
url = "https://github.com/bazelbuild/rules_nodejs/archive/0.16.2.zip",
26-
strip_prefix = "rules_nodejs-0.16.2",
26+
url = "https://github.com/bazelbuild/rules_nodejs/archive/ee218e2a98b9f09ba07cecac8496a5918c47bc5d.zip",
27+
strip_prefix = "rules_nodejs-ee218e2a98b9f09ba07cecac8496a5918c47bc5d",
2728
)
2829

2930
_maybe(

packages/bazel/src/esm5.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def flatten_esm5(ctx):
165165
ctx: the skylark rule execution context
166166
167167
Returns:
168-
list of flattened files
168+
depset of flattened files
169169
"""
170170
esm5_sources = []
171171
result = []
@@ -186,4 +186,4 @@ def flatten_esm5(ctx):
186186
template = f,
187187
substitutions = {},
188188
)
189-
return result
189+
return depset(result)

scripts/build-packages-dist.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ function buildTargetPackages() {
2929
echo " mode: ${desc}"
3030
echo "##################################"
3131

32-
echo "$targets" | xargs ${bazelBin} build --define=compile=$compileMode
32+
# Use --config=release so that snapshot builds get published with embedded version info
33+
echo "$targets" | xargs ${bazelBin} build --config=release --define=compile=$compileMode
3334

3435
[ -d "${basedir}/${destPath}" ] || mkdir -p $basedir/${destPath}
3536

scripts/release/publish-latest

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@
22

33
set -u -e -o pipefail
44

5-
# Use for BETA and RC releases
5+
# Use for production releases
66
# Query Bazel for npm_package and ng_package rules with tags=["release-with-framework"]
77
# Publish them to npm (tagged next)
88

99
# We need to resolve the Bazel binary in the node modules because running Bazel
1010
# through `yarn bazel` causes additional output that throws off the command stdout.
1111
BAZEL_BIN=$(yarn bin)/bazel
12+
# Build into a distinct output location so that artifacts from previous builds are not reused
13+
BAZEL_OUTPUT_BASE=$(mktemp -d -t angular-release-latest.XXXXXXX)
14+
BAZEL="$BAZEL_BIN --output_base=$BAZEL_OUTPUT_BASE"
1215

1316
# query for all npm packages to be released as part of the framework release
1417
NPM_PACKAGE_LABELS=`${BAZEL_BIN} query --output=label 'attr("tags", "\[.*release-with-framework.*\]", //packages/...) intersect kind(".*_package", //packages/...)'`
1518
# build all npm packages in parallel
16-
${BAZEL_BIN} build $NPM_PACKAGE_LABELS
19+
$BAZEL build --config=release $NPM_PACKAGE_LABELS
1720
# publish all packages in sequence to make it easier to spot any errors or warnings
1821
for packageLabel in $NPM_PACKAGE_LABELS; do
1922
echo "publishing $packageLabel"
20-
${BAZEL_BIN} run -- ${packageLabel}.publish --access public --tag latest
23+
$BAZEL run -- ${packageLabel}.publish --access public --tag latest
2124
done
2225

scripts/release/publish-next

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ set -u -e -o pipefail
99
# We need to resolve the Bazel binary in the node modules because running Bazel
1010
# through `yarn bazel` causes additional output that throws off the command stdout.
1111
BAZEL_BIN=$(yarn bin)/bazel
12+
# Build into a distinct output location so that artifacts from previous builds are not reused
13+
BAZEL_OUTPUT_BASE=$(mktemp -d -t angular-release-next.XXXXXXX)
14+
BAZEL="$BAZEL_BIN --output_base=$BAZEL_OUTPUT_BASE"
1215

1316
# query for all npm packages to be released as part of the framework release
1417
NPM_PACKAGE_LABELS=`${BAZEL_BIN} query --output=label 'attr("tags", "\[.*release-with-framework.*\]", //packages/...) intersect kind(".*_package", //packages/...)'`
1518
# build all npm packages in parallel
16-
${BAZEL_BIN} build $NPM_PACKAGE_LABELS
19+
$BAZEL build --config=release $NPM_PACKAGE_LABELS
1720
# publish all packages in sequence to make it easier to spot any errors or warnings
1821
for packageLabel in $NPM_PACKAGE_LABELS; do
1922
echo "publishing $packageLabel"
20-
${BAZEL_BIN} run -- ${packageLabel}.publish --access public --tag next
23+
$BAZEL run -- ${packageLabel}.publish --access public --tag next
2124
done

0 commit comments

Comments
 (0)