Skip to content

Commit 58d2aa3

Browse files
devversionmmalerba
authored andcommitted
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
1 parent 714c2a4 commit 58d2aa3

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ before_script:
5252
script:
5353
- ./scripts/ci/build-and-test.sh
5454

55+
after_success:
56+
- ./scripts/ci/after-success.sh
57+
5558
cache:
5659
directories:
5760
- node_modules

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"strip-ansi": "^3.0.0",
8888
"stylelint": "^7.5.0",
8989
"symlink-or-copy": "^1.0.1",
90+
"travis-after-modes": "0.0.5",
9091
"ts-node": "^0.7.3",
9192
"tslint": "^3.13.0",
9293
"typedoc": "^0.5.1",

scripts/ci/after-success.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
# Script which always runs when the current Travis mode succeeds.
4+
# Used to run the travis-after-modes script, which checks if all other modes finished.
5+
6+
# Go to the project root directory
7+
cd $(dirname $0)/../..
8+
9+
npmBin=$(npm bin)
10+
ciResult=$($npmBin/travis-after-modes)
11+
12+
if [ "$ciResult" = "PASSED" ] && [ -z "$TRAVIS_PULL_REQUEST" ]; then
13+
echo "All travis modes passed. Publishing the build artifacts..."
14+
./scripts/release/publish-build-artifacts.sh
15+
fi
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
# Script to publish the build artifacts to a GitHub repository.
4+
# Builds will be automatically published once new changes are made to the repository.
5+
6+
# Go to the project root directory
7+
cd $(dirname $0)/../..
8+
9+
buildDir="dist/@angular/material"
10+
buildVersion=$(sed -nE 's/^\s*"version": "(.*?)",$/\1/p' package.json)
11+
12+
commitSha=$(git rev-parse --short HEAD)
13+
commitAuthor=$(git --no-pager show -s --format='%an <%ae>' HEAD)
14+
commitMessage=$(git log --oneline | head -n1)
15+
16+
repoName="material-builds"
17+
repoUrl="http://github.com/DevVersion/material-builds.git"
18+
repoDir="tmp/$repoName"
19+
20+
# Create a release of the current repository.
21+
$(npm bin)/gulp build:release
22+
23+
# Prepare cloning the builds repository
24+
rm -rf $repoDir
25+
mkdir -p $repoDir
26+
27+
# Clone the repository
28+
git clone $repoUrl $repoDir
29+
30+
# Copy the build files to the repository
31+
rm -rf $repoDir/*
32+
cp -r $buildDir/* $repoDir
33+
34+
# Create the build commit and push the changes to the repository.
35+
cd $repoDir &&
36+
37+
# Setup the git repository authentication.
38+
git config credential.helper "store --file=.git/credentials" &&
39+
echo "$MATERIAL2_BUILDS_TOKEN" > .git/credentials
40+
41+
git add -A &&
42+
git commit -m "$commitMessage" --author "$commitAuthor" &&
43+
git tag "$buildVersion-$commitSha" &&
44+
git push origin master --tags
45+
46+
echo "Finished publishing build artifacts"

0 commit comments

Comments
 (0)