Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: publish tarballs for all Angular packages as build artifacts on P…
…R builds (#33321) Previously, when one wanted to try out the changes from a PR before it was merged, they had to check out the PR locally and build the Angular packages themselves (which is time-consuming and wasteful given that the packages have already been built on CI). This commit persists all Angular packages on each build as `.tgz` files, which can be used to install dependencies on an project (supported by both [npm][1] and [yarn][2]). In addition to individual `.tgz` files for each package, a `.tgz` file including all packages is also stored, which can be used to test the packages locally by overwriting the ones in the `node_modules/` directory of a project. CircleCI [build artifacts][3] an be used for longer-term storage of the outputs of a build and are designed to be useful around the time of the build, which suits our needs. [1]: https://docs.npmjs.com/cli/install.html [2]: https://yarnpkg.com/lang/en/docs/cli/add [3]: https://circleci.com/docs/2.0/artifacts PR Close #33321
- Loading branch information
1 parent
22e4838
commit efbbae5
Showing
3 changed files
with
114 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu -o pipefail | ||
|
||
readonly prNumber="$1" | ||
readonly prLastSha="${2:0:7}" | ||
readonly inputDir="$PROJECT_ROOT/$3" | ||
readonly outputDir="$PROJECT_ROOT/$4" | ||
readonly fileSuffix="-pr$prNumber-$prLastSha.tgz" | ||
|
||
echo "Creating compressed archives for packages in '$inputDir'." | ||
|
||
# Create or clean-up the output directory. | ||
echo " Preparing output directory: $outputDir" | ||
rm -rf "$outputDir" | ||
mkdir -p "$outputDir" | ||
|
||
# Create a compressed archive containing all packages. | ||
# (This is useful for copying all packages into `node_modules/` (without changing `package.json`).) | ||
outputFileName=all$fileSuffix | ||
echo " Creating archive with all packages --> '$outputFileName'..." | ||
tar --create --gzip --directory "$inputDir" --file "$outputDir/$outputFileName" --transform s/^\./packages/ . | ||
|
||
# Create a compressed archive for each package. | ||
# (This is useful for referencing the path/URL to the resulting archive in `package.json`.) | ||
for dir in $inputDir/* | ||
do | ||
packageName=`basename "$dir"` | ||
outputFileName="$packageName$fileSuffix" | ||
outputFilePath="$outputDir/$outputFileName" | ||
|
||
echo " Processing package '$packageName' --> '$outputFileName'..." | ||
|
||
tar --create --gzip --directory "$dir" --file "$outputFilePath" --transform s/^\./package/ . | ||
done | ||
|
||
echo "Done creating compressed archives." |