Skip to content

Commit 09a60bb

Browse files
authored
build(bazel): add version stamping (#10687)
1 parent a6ffd18 commit 09a60bb

File tree

6 files changed

+125
-84
lines changed

6 files changed

+125
-84
lines changed

WORKSPACE

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ workspace(name = "angular_material")
33
# Add nodejs rules
44
http_archive(
55
name = "build_bazel_rules_nodejs",
6-
url = "https://github.com/bazelbuild/rules_nodejs/archive/0.6.0.zip",
7-
strip_prefix = "rules_nodejs-0.6.0",
8-
sha256 = "e8a2bb5ca51fbafb244bc507bcebcae33a63d969f47413b319a8dcce032845bf",
6+
url = "https://github.com/bazelbuild/rules_nodejs/archive/99166f8eb7fc628ca561acf9f9a51a1c26edadad.zip",
7+
strip_prefix = "rules_nodejs-99166f8eb7fc628ca561acf9f9a51a1c26edadad",
8+
sha256 = "338e8495e5d1fa16de7190106c5675372ff4a347f6004e203e84a168db96281e",
99
)
1010

1111
# NOTE: this rule installs nodejs, npm, and yarn, but does NOT install
@@ -28,9 +28,9 @@ sass_repositories()
2828
# Add TypeScript rules
2929
http_archive(
3030
name = "build_bazel_rules_typescript",
31-
url = "https://github.com/bazelbuild/rules_typescript/archive/df4a1a561d88e187438ac7791a5ac33995f2d317.zip",
32-
strip_prefix = "rules_typescript-df4a1a561d88e187438ac7791a5ac33995f2d317",
33-
sha256 = "51a84f156eeddf126e9370b5c193b4709eeb330448e2de5afcda40232e0b56bc",
31+
url = "https://github.com/bazelbuild/rules_typescript/archive/0.11.1.zip",
32+
strip_prefix = "rules_typescript-0.11.1",
33+
sha256 = "7406bea7954e1c906f075115dfa176551a881119f6820b126ea1eacb09f34a1a",
3434
)
3535

3636
# Setup TypeScript Bazel workspace

package-lock.json

Lines changed: 44 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
"node": ">= 5.4.1"
2727
},
2828
"dependencies": {
29-
"@angular/animations": "6.0.0-rc.1",
30-
"@angular/common": "6.0.0-rc.1",
31-
"@angular/compiler": "6.0.0-rc.1",
32-
"@angular/core": "6.0.0-rc.1",
33-
"@angular/forms": "6.0.0-rc.1",
34-
"@angular/platform-browser": "6.0.0-rc.1",
29+
"@angular/animations": "6.0.0-rc.3",
30+
"@angular/common": "6.0.0-rc.3",
31+
"@angular/compiler": "6.0.0-rc.3",
32+
"@angular/core": "6.0.0-rc.3",
33+
"@angular/forms": "6.0.0-rc.3",
34+
"@angular/platform-browser": "6.0.0-rc.3",
3535
"core-js": "^2.4.1",
3636
"rxjs": "6.0.0-rc.0",
3737
"systemjs": "0.19.43",
@@ -42,13 +42,13 @@
4242
"devDependencies": {
4343
"@angular-devkit/core": "^0.4.5",
4444
"@angular-devkit/schematics": "^0.4.5",
45-
"@angular/bazel": "6.0.0-rc.1",
46-
"@angular/compiler-cli": "6.0.0-rc.1",
47-
"@angular/http": "6.0.0-rc.1",
48-
"@angular/platform-browser-dynamic": "6.0.0-rc.1",
49-
"@angular/platform-server": "6.0.0-rc.1",
50-
"@angular/router": "6.0.0-rc.1",
51-
"@angular/upgrade": "6.0.0-rc.1",
45+
"@angular/bazel": "6.0.0-rc.3",
46+
"@angular/compiler-cli": "6.0.0-rc.3",
47+
"@angular/http": "6.0.0-rc.3",
48+
"@angular/platform-browser-dynamic": "6.0.0-rc.3",
49+
"@angular/platform-server": "6.0.0-rc.3",
50+
"@angular/router": "6.0.0-rc.3",
51+
"@angular/upgrade": "6.0.0-rc.3",
5252
"@bazel/ibazel": "0.3.1",
5353
"@google-cloud/storage": "^1.1.1",
5454
"@schematics/angular": "^0.4.5",

src/lib/BUILD.bazel

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,20 @@ sass_bundle(
3232
output_name = "_theming.scss",
3333
)
3434

35-
# TODO(jelbourn): uncomment when 6.0.0-rc.1 comes out
3635
# Creates the @angular/material package published to npm.
37-
#ng_package(
38-
# name = "npm_package",
39-
# srcs = [
40-
# "package.json",
41-
# ],
42-
# entry_point = "src/lib/public_api.js",
43-
# entry_point_name = "material",
44-
# globals = ROLLUP_GLOBALS,
45-
# data = [
46-
# ":theming_bundle",
47-
# "//src/lib/prebuilt-themes:indigo-pink",
48-
# "//src/lib/prebuilt-themes:deeppurple-amber",
49-
# "//src/lib/prebuilt-themes:pink-bluegrey",
50-
# "//src/lib/prebuilt-themes:purple-green",
51-
# ],
52-
# packages = ["//src/lib/schematics:npm_package"],
53-
# deps = MATERIAL_TARGETS
54-
#)
36+
ng_package(
37+
name = "npm_package",
38+
srcs = ["package.json"],
39+
entry_point = "src/lib/public_api.js",
40+
entry_point_name = "material",
41+
globals = ROLLUP_GLOBALS,
42+
data = [
43+
":theming_bundle",
44+
"//src/lib/prebuilt-themes:indigo-pink",
45+
"//src/lib/prebuilt-themes:deeppurple-amber",
46+
"//src/lib/prebuilt-themes:pink-bluegrey",
47+
"//src/lib/prebuilt-themes:purple-green",
48+
],
49+
packages = ["//src/lib/schematics:npm_package"],
50+
deps = MATERIAL_TARGETS,
51+
)

tools/bazel-stamp-vars.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
3+
# Generates the data used by the stamping feature in bazel.
4+
# This script is intended to be used as a Bazel workspace_status_command, which
5+
# prints out a set of key-value pairs.
6+
# See https://github.com/angular/angular/blob/master/docs/BAZEL.md for more explanation
7+
set -u -e -E -o pipefail
8+
9+
function onError {
10+
echo "Failed to execute: $0"
11+
echo ""
12+
}
13+
14+
# Setup crash trap
15+
trap 'onError' ERR
16+
17+
if [[ "$(git tag)" == "" ]]; then
18+
echo "No git tags found, can't stamp the build."
19+
echo "Either fetch the tags:"
20+
echo " git fetch [email protected]:angular/material2.git --tags"
21+
echo "or build without stamping by giving an empty workspace_status_command:"
22+
echo " bazel build --workspace_status_command= ..."
23+
echo ""
24+
fi
25+
26+
# Gets a human-readable name for HEAD, e.g. "6.0.0-rc.0-15-g846ddfa"
27+
git_version_raw=$(git describe --abbrev=7 --tags HEAD)
28+
29+
# Find out if there are any uncommitted local changes
30+
if [[ $(git status --untracked-files=no --porcelain) ]]; then
31+
local_changes_suffix=".with-local-changes";
32+
else
33+
local_changes_suffix="";
34+
fi
35+
36+
# Reformat `git describe` version string into a more semver-ish string
37+
# From: 5.2.0-rc.0-57-g757f886
38+
# To: 5.2.0-rc.0+57.sha-757f886
39+
# Or: 5.2.0-rc.0+57.sha-757f886.with-local-changes
40+
41+
semver_style_version="$(echo ${git_version_raw} | sed -E 's/-([0-9]+)-g/+\1.sha-/g')"
42+
version_stamp="${semver_style_version}${local_changes_suffix}"
43+
echo "BUILD_SCM_VERSION ${version_stamp}"

tools/bazel.rc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ test --test_output=errors
3636
build --experimental_ui
3737
test --experimental_ui
3838

39-
# Output to a more coventional location
40-
build --symlink_prefix=dist/bazel/
39+
# Configures script to do version stamping.
40+
# See https://docs.bazel.build/versions/master/user-manual.html#flag--workspace_status_command
41+
build --workspace_status_command=./tools/bazel-stamp-vars.sh
4142

4243
###############################
4344
# Typescript / Angular / Sass #

0 commit comments

Comments
 (0)