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:
parent
fc2c23ef4b
commit
5acfdee3ca
4
.bazelrc
4
.bazelrc
@ -30,10 +30,12 @@ test --nolegacy_external_runfiles
|
|||||||
|
|
||||||
###############################
|
###############################
|
||||||
# Release support #
|
# Release support #
|
||||||
|
# Turn on these settings with #
|
||||||
|
# --config=release #
|
||||||
###############################
|
###############################
|
||||||
|
|
||||||
# Releases should always be stamped with version control info
|
# 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 #
|
# Output #
|
||||||
|
@ -18,12 +18,13 @@ def rules_angular_dependencies():
|
|||||||
|
|
||||||
#
|
#
|
||||||
# Download Bazel toolchain dependencies as needed by build actions
|
# 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(
|
_maybe(
|
||||||
http_archive,
|
http_archive,
|
||||||
name = "build_bazel_rules_nodejs",
|
name = "build_bazel_rules_nodejs",
|
||||||
url = "https://github.com/bazelbuild/rules_nodejs/archive/0.16.2.zip",
|
url = "https://github.com/bazelbuild/rules_nodejs/archive/ee218e2a98b9f09ba07cecac8496a5918c47bc5d.zip",
|
||||||
strip_prefix = "rules_nodejs-0.16.2",
|
strip_prefix = "rules_nodejs-ee218e2a98b9f09ba07cecac8496a5918c47bc5d",
|
||||||
)
|
)
|
||||||
|
|
||||||
_maybe(
|
_maybe(
|
||||||
|
@ -165,7 +165,7 @@ def flatten_esm5(ctx):
|
|||||||
ctx: the skylark rule execution context
|
ctx: the skylark rule execution context
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list of flattened files
|
depset of flattened files
|
||||||
"""
|
"""
|
||||||
esm5_sources = []
|
esm5_sources = []
|
||||||
result = []
|
result = []
|
||||||
@ -186,4 +186,4 @@ def flatten_esm5(ctx):
|
|||||||
template = f,
|
template = f,
|
||||||
substitutions = {},
|
substitutions = {},
|
||||||
)
|
)
|
||||||
return result
|
return depset(result)
|
||||||
|
@ -29,7 +29,8 @@ function buildTargetPackages() {
|
|||||||
echo " mode: ${desc}"
|
echo " mode: ${desc}"
|
||||||
echo "##################################"
|
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}
|
[ -d "${basedir}/${destPath}" ] || mkdir -p $basedir/${destPath}
|
||||||
|
|
||||||
|
@ -2,21 +2,24 @@
|
|||||||
|
|
||||||
set -u -e -o pipefail
|
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"]
|
# Query Bazel for npm_package and ng_package rules with tags=["release-with-framework"]
|
||||||
# Publish them to npm (tagged next)
|
# Publish them to npm (tagged next)
|
||||||
|
|
||||||
# We need to resolve the Bazel binary in the node modules because running Bazel
|
# 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.
|
# through `yarn bazel` causes additional output that throws off the command stdout.
|
||||||
BAZEL_BIN=$(yarn bin)/bazel
|
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
|
# 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/...)'`
|
NPM_PACKAGE_LABELS=`${BAZEL_BIN} query --output=label 'attr("tags", "\[.*release-with-framework.*\]", //packages/...) intersect kind(".*_package", //packages/...)'`
|
||||||
# build all npm packages in parallel
|
# 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
|
# publish all packages in sequence to make it easier to spot any errors or warnings
|
||||||
for packageLabel in $NPM_PACKAGE_LABELS; do
|
for packageLabel in $NPM_PACKAGE_LABELS; do
|
||||||
echo "publishing $packageLabel"
|
echo "publishing $packageLabel"
|
||||||
${BAZEL_BIN} run -- ${packageLabel}.publish --access public --tag latest
|
$BAZEL run -- ${packageLabel}.publish --access public --tag latest
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -9,13 +9,16 @@ set -u -e -o pipefail
|
|||||||
# We need to resolve the Bazel binary in the node modules because running Bazel
|
# 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.
|
# through `yarn bazel` causes additional output that throws off the command stdout.
|
||||||
BAZEL_BIN=$(yarn bin)/bazel
|
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
|
# 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/...)'`
|
NPM_PACKAGE_LABELS=`${BAZEL_BIN} query --output=label 'attr("tags", "\[.*release-with-framework.*\]", //packages/...) intersect kind(".*_package", //packages/...)'`
|
||||||
# build all npm packages in parallel
|
# 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
|
# publish all packages in sequence to make it easier to spot any errors or warnings
|
||||||
for packageLabel in $NPM_PACKAGE_LABELS; do
|
for packageLabel in $NPM_PACKAGE_LABELS; do
|
||||||
echo "publishing $packageLabel"
|
echo "publishing $packageLabel"
|
||||||
${BAZEL_BIN} run -- ${packageLabel}.publish --access public --tag next
|
$BAZEL run -- ${packageLabel}.publish --access public --tag next
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user