Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Dec 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 19 additions & 2 deletions DEVELOPER.md
@@ -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)
Expand Down Expand Up @@ -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]
```
42 changes: 32 additions & 10 deletions scripts/publish/publish-build-artifacts.sh
Expand Up @@ -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
Expand Down Expand Up @@ -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 && \
Expand 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})"
Expand All @@ -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`
Expand All @@ -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