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

build: publish build artifacts to branches #13529

Merged
merged 1 commit into from
Dec 20, 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
3 changes: 3 additions & 0 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,6 @@ For subsequent snapshots, just run
``` shell
$ ./scripts/publish/publish-build-artifacts.sh [github username]
```

The script will publish the build snapshot to a branch with the same name as your current branch,
and create it if it doesn't exist.
19 changes: 12 additions & 7 deletions scripts/publish/publish-build-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,20 @@ function publishRepo {
cd $REPO_DIR && \
git init && \
git remote add origin $REPO_URL && \
git fetch origin master --depth=1 && \
git checkout origin/master && \
git checkout -b master
# use the remote branch if it exists
if git ls-remote --exit-code origin ${BRANCH}; then
git fetch origin ${BRANCH} --depth=1 && \
git checkout origin/${BRANCH}
fi
git checkout -b "${BRANCH}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't this fail if the branch already exists?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worse, it will replace the branch if it exists instead of adding to it. Will fix.

)

# copy over build artifacts into the repo directory
rm -rf $REPO_DIR/*
cp -R $ARTIFACTS_DIR/* $REPO_DIR/

# Replace $$ANGULAR_VESION$$ with the build version.
BUILD_VER="2.0.0-${SHORT_SHA}"
# Replace $$ANGULAR_VERSION$$ with the build version.
BUILD_VER="${LATEST_TAG}+${SHORT_SHA}"
if [[ ${TRAVIS} ]]; then
find $REPO_DIR/ -type f -name package.json -print0 | xargs -0 sed -i "s/\\\$\\\$ANGULAR_VERSION\\\$\\\$/${BUILD_VER}/g"

Expand All @@ -59,7 +62,7 @@ function publishRepo {
git add --all && \
git commit -m "${COMMIT_MSG}" && \
git tag "${BUILD_VER}" && \
git push origin master --tags --force
git push origin "${BRANCH}" --tags --force
)
}

Expand All @@ -85,6 +88,7 @@ function publishPackages {
COMMIT_MSG=`git log --oneline | head -n1`
COMMITTER_USER_NAME=`git --no-pager show -s --format='%cN' HEAD`
COMMITTER_USER_EMAIL=`git --no-pager show -s --format='%cE' HEAD`
LATEST_TAG=`git describe --tags --abbrev=0`

publishRepo "${COMPONENT}" "${JS_BUILD_ARTIFACTS_DIR}"
done
Expand All @@ -93,6 +97,7 @@ function publishPackages {
}

# See DEVELOPER.md for help
BRANCH=`git rev-parse --abbrev-ref HEAD`
if [ $# -gt 0 ]; then
ORG=$1
publishPackages "ssh"
Expand All @@ -103,5 +108,5 @@ elif [[ \
ORG="angular"
publishPackages "http"
else
echo "Not building the upstream/master branch, build artifacts won't be published."
echo "Not building the upstream/${BRANCH} branch, build artifacts won't be published."
fi