chore: create build artifacts for each commit (#2082)

* chore: create build artifacts for each commit

* Switch to new npm package

* Update version to latest

* Publish the builds after all modes succeeded.

* Address comments

* Change snake_case to camelCase
This commit is contained in:
Paul Gschwendtner
2016-12-09 22:57:28 +01:00
committed by mmalerba
parent 714c2a48df
commit 58d2aa3f9c
4 changed files with 65 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
#!/bin/bash
# Script which always runs when the current Travis mode succeeds.
# Used to run the travis-after-modes script, which checks if all other modes finished.
# Go to the project root directory
cd $(dirname $0)/../..
npmBin=$(npm bin)
ciResult=$($npmBin/travis-after-modes)
if [ "$ciResult" = "PASSED" ] && [ -z "$TRAVIS_PULL_REQUEST" ]; then
echo "All travis modes passed. Publishing the build artifacts..."
./scripts/release/publish-build-artifacts.sh
fi
+46
View File
@@ -0,0 +1,46 @@
#!/bin/bash
# Script to publish the build artifacts to a GitHub repository.
# Builds will be automatically published once new changes are made to the repository.
# Go to the project root directory
cd $(dirname $0)/../..
buildDir="dist/@angular/material"
buildVersion=$(sed -nE 's/^\s*"version": "(.*?)",$/\1/p' package.json)
commitSha=$(git rev-parse --short HEAD)
commitAuthor=$(git --no-pager show -s --format='%an <%ae>' HEAD)
commitMessage=$(git log --oneline | head -n1)
repoName="material-builds"
repoUrl="http://github.com/DevVersion/material-builds.git"
repoDir="tmp/$repoName"
# Create a release of the current repository.
$(npm bin)/gulp build:release
# Prepare cloning the builds repository
rm -rf $repoDir
mkdir -p $repoDir
# Clone the repository
git clone $repoUrl $repoDir
# Copy the build files to the repository
rm -rf $repoDir/*
cp -r $buildDir/* $repoDir
# Create the build commit and push the changes to the repository.
cd $repoDir &&
# Setup the git repository authentication.
git config credential.helper "store --file=.git/credentials" &&
echo "$MATERIAL2_BUILDS_TOKEN" > .git/credentials
git add -A &&
git commit -m "$commitMessage" --author "$commitAuthor" &&
git tag "$buildVersion-$commitSha" &&
git push origin master --tags
echo "Finished publishing build artifacts"