Skip to content

Commit c0c287c

Browse files
committed
ci: publish bazel rules snapshots
This commit integrates rules_angular, rules_browsers, and rules_sass into the repository's build and snapshot publishing workflow.
1 parent d0ecd24 commit c0c287c

6 files changed

Lines changed: 114 additions & 2 deletions

File tree

.github/workflows/publish-snapshots.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
with:
2929
bazelrc: .bazelrc
3030
- run: pnpm install --frozen-lockfile
31-
- run: pnpm bazel build //ng-dev:npm_package --config=release
31+
- run: bash ./tools/build-all.sh
3232
- name: Publish Snapshots
3333
env:
3434
GITHUB_TOKEN: ${{ secrets.SNAPSHOT_BUILDS_GITHUB_TOKEN }}

.ng-dev/release.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ export const release = {
55
name: '@angular/ng-dev',
66
snapshotRepo: 'dev-infra-private-ng-dev-builds',
77
},
8+
{
9+
name: 'rules_angular',
10+
snapshotRepo: 'rules_angular',
11+
},
12+
{
13+
name: 'rules_browsers',
14+
snapshotRepo: 'rules_browsers',
15+
},
16+
{
17+
name: 'rules_sass',
18+
snapshotRepo: 'rules_sass',
19+
},
820
],
921
buildPackages: async () => {
1022
// TODO: Create a standard build script instead of expecting the build to already be complete
@@ -13,6 +25,18 @@ export const release = {
1325
name: '@angular/ng-dev',
1426
outputPath: './dist/bin/ng-dev/npm_package',
1527
},
28+
{
29+
name: 'rules_angular',
30+
outputPath: './dist/rules/rules_angular',
31+
},
32+
{
33+
name: 'rules_browsers',
34+
outputPath: './dist/rules/rules_browsers',
35+
},
36+
{
37+
name: 'rules_sass',
38+
outputPath: './dist/rules/rules_sass',
39+
},
1640
];
1741
},
1842
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# rules_angular
2+
3+
> [!IMPORTANT]
4+
> The source code for this library is maintained in the [angular/dev-infra](https://github.com/angular/dev-infra/tree/main/bazel/rules/rules_angular) repository.
5+
> Please open any issues or pull requests in that repository.
6+
7+
## Usage
8+
9+
Add the dependency for `rules_angular` to your `MODULE.bazel` file.
10+
11+
```starlark
12+
bazel_dep(name = "rules_angular")
13+
14+
git_override(
15+
module_name = "rules_angular",
16+
remote = "https://github.com/angular/rules_angular.git",
17+
commit = "{SHA}",
18+
)
19+
```

bazel/rules/rules_browsers/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
# rules_browsers
22

3+
> [!IMPORTANT]
4+
> The source code for this library is maintained in the [angular/dev-infra](https://github.com/angular/dev-infra/tree/main/bazel/rules/rules_browsers) repository.
5+
> Please open any issues or pull requests in that repository.
6+
37
Use browsers in Bazel and run tests with them.
48

59
## Usage
610

711
Add the dependency for `rules_browsers` to your `MODULE.bazel` file.
812

913
```starlark
10-
bazel_dep(name = "rules_browsers", version = "0.4.0")
14+
bazel_dep(name = "rules_browsers")
15+
16+
git_override(
17+
module_name = "rules_browsers",
18+
remote = "https://github.com/angular/rules_browsers.git",
19+
commit = "{SHA}",
20+
)
1121
```
1222

1323
This allows you to use provided testing macros. You can also use the

bazel/rules/rules_sass/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# rules_sass
2+
3+
> [!IMPORTANT]
4+
> The source code for this library is maintained in the [angular/dev-infra](https://github.com/angular/dev-infra/tree/main/bazel/rules/rules_sass) repository.
5+
> Please open any issues or pull requests in that repository.
6+
7+
## Usage
8+
9+
Add the dependency for `rules_sass` to your `MODULE.bazel` file.
10+
11+
```starlark
12+
bazel_dep(name = "rules_sass")
13+
14+
git_override(
15+
module_name = "rules_sass",
16+
remote = "https://github.com/angular/rules_sass.git",
17+
commit = "{SHA}",
18+
)
19+
```

tools/build-all.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
# Bash script to build all packages and modules in the dev-infra repository.
4+
set -e
5+
6+
# Ensure the script runs from the repository root.
7+
cd "$(dirname "$0")/.."
8+
9+
# Build the ng-dev npm package using Bazel in release mode.
10+
echo "Building //ng-dev:npm_package..."
11+
pnpm bazel build //ng-dev:npm_package --config=release
12+
13+
# Package each rule module by creating a git archive and extracting it.
14+
# This ensures that only tracked files are included in the output.
15+
mkdir -p dist
16+
17+
# Create a temporary tree-ish that includes uncommitted changes.
18+
# If no changes exist, git stash create returns empty, so we fall back to HEAD.
19+
tree_ish=$(git stash create)
20+
if [ -z "$tree_ish" ]; then
21+
tree_ish="HEAD"
22+
fi
23+
24+
for rule_path in bazel/rules/rules_*; do
25+
if [ -d "$rule_path" ]; then
26+
rule_name=$(basename "$rule_path")
27+
target_dir="dist/rules/$rule_name"
28+
29+
echo "Packaging $rule_name into $target_dir..."
30+
31+
# Ensure target directory exists and is empty
32+
rm -rf "$target_dir"
33+
mkdir -p "$target_dir"
34+
35+
# Archive the content of the rule directory and extract it into dist.
36+
git archive "$tree_ish":"$rule_path" | tar -x -C "$target_dir"
37+
fi
38+
done
39+
40+
echo "Build all completed successfully."

0 commit comments

Comments
 (0)