feature(DEVELOPER.md): add easy way to publish personal snapshot builds (#13469)

This commit is contained in:
Alex Eagle 2016-12-15 11:19:21 -08:00 committed by Chuck Jazdzewski
parent 33910ddfc9
commit 01d1624884
2 changed files with 51 additions and 12 deletions

View File

@ -1,6 +1,6 @@
# Building and Testing Angular 2 for JS
# Building and Testing Angular
This document describes how to set up your development environment to build and test Angular 2 JS version.
This document describes how to set up your development environment to build and test Angular.
It also explains the basic mechanics of using `git`, `node`, and `npm`.
* [Prerequisite Software](#prerequisite-software)
@ -137,4 +137,21 @@ You can automatically format your code by running:
$ gulp format
```
## Publishing your own personal snapshot build
You may find that your un-merged change needs some validation from external participants.
Rather than requiring them to pull your Pull Request and build Angular locally, you can
publish the `*-builds` snapshots just like our Travis build does.
First time, you need to create the github repositories:
``` shell
$ export TOKEN=[get one from https://github.com/settings/tokens]
$ CREATE_REPOS=1 ./scripts/publish/publish-build-artifacts.sh [github username]
```
For subsequent snapshots, just run
``` shell
$ ./scripts/publish/publish-build-artifacts.sh [github username]
```

View File

@ -9,7 +9,12 @@ function publishRepo {
BUILD_REPO="${COMPONENT}-builds"
REPO_DIR="tmp/${BUILD_REPO}"
echo "Pushing build artifacts to angular/${BUILD_REPO}"
if [ -n "$CREATE_REPOS" ]; then
curl -u "$ORG:$TOKEN" https://api.github.com/user/repos \
-d '{"name":"'$BUILD_REPO'", "auto_init": true}'
fi
echo "Pushing build artifacts to ${ORG}/${BUILD_REPO}"
# create local repo folder and clone build repo into it
rm -rf $REPO_DIR
@ -37,14 +42,18 @@ function publishRepo {
for UMD_FILE in ${UMD_FILES}; do
sed -i "s/\\\$\\\$ANGULAR_VERSION\\\$\\\$/${BUILD_VER}/g" ${UMD_FILE}
done
(
cd $REPO_DIR && \
git config credential.helper "store --file=.git/credentials" && \
echo "https://${GITHUB_TOKEN_ANGULAR}:@github.com" > .git/credentials
)
fi
echo `date` > $REPO_DIR/BUILD_INFO
echo $SHA >> $REPO_DIR/BUILD_INFO
(
cd $REPO_DIR && \
git config credential.helper "store --file=.git/credentials" && \
echo "https://${GITHUB_TOKEN_ANGULAR}:@github.com" > .git/credentials && \
git config user.name "${COMMITTER_USER_NAME}" && \
git config user.email "${COMMITTER_USER_EMAIL}" && \
git add --all && \
@ -55,9 +64,7 @@ function publishRepo {
}
# Publish all individual packages from packages-dist.
if [[ "$TRAVIS_REPO_SLUG" == "angular/angular" && \
"$TRAVIS_PULL_REQUEST" == "false" && \
"$CI_MODE" == "e2e" ]]; then
function publishPackages {
for dir in dist/packages-dist/*/ dist/tools/@angular/tsc-wrapped
do
COMPONENT="$(basename ${dir})"
@ -66,10 +73,13 @@ if [[ "$TRAVIS_REPO_SLUG" == "angular/angular" && \
COMPONENT="${COMPONENT//_/-}"
JS_BUILD_ARTIFACTS_DIR="${dir}"
REPO_URL="https://github.com/angular/${COMPONENT}-builds.git"
# Use the below URL for testing when using SSH authentication
# REPO_URL="git@github.com:angular/${COMPONENT}-builds.git"
if [[ "$1" -eq "ssh" ]]; then
REPO_URL="git@github.com:${ORG}/${COMPONENT}-builds.git"
elif [[ "$1" -eq "http" ]]; then
REPO_URL="https://github.com/${ORG}/${COMPONENT}-builds.git"
else
die "Don't have a way to publish to scheme $1"
fi
SHA=`git rev-parse HEAD`
SHORT_SHA=`git rev-parse --short HEAD`
COMMIT_MSG=`git log --oneline | head -n1`
@ -80,6 +90,18 @@ if [[ "$TRAVIS_REPO_SLUG" == "angular/angular" && \
done
echo "Finished publishing build artifacts"
}
# See DEVELOPER.md for help
if [ $# -gt 0 ]; then
ORG=$1
publishPackages "ssh"
elif [[ \
"$TRAVIS_REPO_SLUG" == "angular/angular" && \
"$TRAVIS_PULL_REQUEST" == "false" && \
"$CI_MODE" == "e2e" ]]; then
ORG="angular"
publishPackages "http"
else
echo "Not building the upstream/master branch, build artifacts won't be published."
fi