Skip to content

Commit

Permalink
build: Update publish script
Browse files Browse the repository at this point in the history
Update the publish script to invoke existing build command, then run the
script generated by Bazel npm_package target to publish to npm.
  • Loading branch information
Keen Yee Liau committed Feb 21, 2020
1 parent 01838b6 commit 6b4d116
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 35 deletions.
4 changes: 2 additions & 2 deletions docs/process/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ git push upstream && git push upstream --tags
- Publish
```sh
# For release with 'next' tag
./publish-next.sh
./publish.sh next
```

```sh
# For release with 'latest' tag
./publish.sh
./publish.sh latest
```

# Release Changelog
Expand Down
19 changes: 0 additions & 19 deletions publish-next.sh

This file was deleted.

29 changes: 16 additions & 13 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@

#!/usr/bin/env bash

set -u -e -o pipefail
source $(dirname $0)/scripts/package-builder.sh

readonly tag="$1"

# Use for BETA and RC releases
# Query Bazel for npm_package and ng_package rules
# Publish them to npm (tagged next)
if [[ $tag != 'latest' && $tag != 'next' ]]; then
echo "Invalid tag: ${tag}. Must be either 'latest' or 'next'"
exit 1
fi

# query for all npm packages to be released as part of the framework release
NPM_PACKAGE_LABELS=`bazel query --output=label 'attr("tags", "\[.*release.*\]", //modules/...) intersect kind(".*_package", //modules/...)'`
# build all npm packages in parallel
bazel build --config=release $NPM_PACKAGE_LABELS
# Build the npm packages
buildTargetPackages "dist/modules-dist" "legacy" "Production"

# 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 run --config=release -- ${packageLabel}.publish --access public --tag latest
# Publish all packages to NPM
for target in $(getAllPackages); do
echo "=============================================="
echo "Publishing ${target}"
echo "=============================================="
${bazel_bin} run --config=release "${target}.publish" -- \
--access public --tag "${tag}"
done
6 changes: 5 additions & 1 deletion scripts/package-builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ readonly base_dir=$(pwd)/..
readonly bazel_bin=$(yarn bin)/bazel
readonly bin=$(${bazel_bin} info bazel-bin)

function getAllPackages() {
${bazel_bin} query --output=label 'attr("tags", "\[.*release\]", //modules/...) intersect kind("pkg_npm|ng_package", //modules/...)'
}

function buildTargetPackages() {
# List of targets to build, e.g. core, common, compiler, etc.
targets=$(${bazel_bin} query --output=label 'attr("tags", "\[.*release\]", //modules/...) intersect kind("pkg_npm|ng_package", //modules/...)')
targets=$(getAllPackages)

# Path to the output directory into which we copy the npm packages.
dest_path="$1"
Expand Down

0 comments on commit 6b4d116

Please sign in to comment.