@@ -19,37 +19,67 @@ if [[ ! ${*} == *--no-build* ]]; then
19
19
$( npm bin) /gulp docs
20
20
fi
21
21
22
- # Path to the directory that contains the generated docs output .
23
- docsDistPath= " ./dist/docs "
22
+ # Path to the project directory .
23
+ projectPath= " $( pwd ) "
24
24
25
- # Path to the release output of the @angular/material-examples package .
26
- examplesPackagePath= " . /dist/releases/material-examples "
25
+ # Path to the directory that contains the generated docs output .
26
+ docsDistPath= " ${projectPath} /dist/docs "
27
27
28
28
# Path to the cloned docs-content repository.
29
- docsContentPath=./tmp/material2-docs-content
29
+ docsContentPath=" ${projectPath} /tmp/material2-docs-content"
30
+
31
+ # Path to the release output of the @angular/material-examples package.
32
+ examplesPackagePath=" ${projectPath} /dist/releases/material-examples"
30
33
31
34
# Git clone URL for the material2-docs-content repository.
32
35
docsContentRepoUrl=" https://github.com/angular/material2-docs-content"
33
36
34
37
# Current version of Angular Material from the package.json file
35
38
buildVersion=$( node -pe " require('./package.json').version" )
36
39
40
+ # Name of the branch that is currently being deployed.
41
+ branchName=${TRAVIS_BRANCH:- ' master' }
42
+
37
43
# Additional information about the last commit for docs-content commits.
38
44
commitSha=$( git rev-parse --short HEAD)
39
45
commitAuthorName=$( git --no-pager show -s --format=' %an' HEAD)
40
46
commitAuthorEmail=$( git --no-pager show -s --format=' %ae' HEAD)
41
47
commitMessage=$( git log --oneline -n 1)
42
48
commitTag=" ${buildVersion} -${commitSha} "
43
49
50
+ buildVersionName=" ${buildVersion} -${commitSha} "
51
+ buildTagName=" ${branchName} -${commitSha} "
52
+ buildCommitMessage=" ${branchName} - ${commitMessage} "
53
+
54
+ echo " Starting deployment of the docs-content for ${buildVersionName} in ${branchName} "
55
+
44
56
# Remove the docs-content repository if the directory exists
45
57
rm -Rf ${docsContentPath}
46
58
47
59
# Clone the docs-content repository.
48
60
git clone ${docsContentRepoUrl} ${docsContentPath} --depth 1
49
61
62
+ echo " Successfully cloned docs-content repository."
63
+
64
+ # Go into the repository directory.
65
+ cd ${docsContentPath}
66
+
67
+ echo " Switched into the repository directory."
68
+
69
+ if [[ $( git ls-remote --heads origin ${branchName} ) ]]; then
70
+ git checkout ${branchName}
71
+ echo " Switched to ${branchName} branch."
72
+ else
73
+ echo " Branch ${branchName} does not exist on the docs-content repo yet. Creating ${branchName} .."
74
+ git checkout -b ${branchName}
75
+ echo " Branch created and checked out."
76
+ fi
77
+
50
78
# Remove everything inside of the docs-content repository.
51
79
rm -Rf ${docsContentPath} /*
52
80
81
+ echo " Removed everything from the docs-content repository. Copying all files into repository.."
82
+
53
83
# Create all folders that need to exist in the docs-content repository.
54
84
mkdir ${docsContentPath} /{overview,guides,api,examples,stackblitz,examples-package}
55
85
@@ -62,7 +92,7 @@ cp -r ${docsDistPath}/stackblitz/* ${docsContentPath}/stackblitz
62
92
cp -r ${examplesPackagePath} /* ${docsContentPath} /examples-package
63
93
64
94
# Copy the license file to the docs-content repository.
65
- cp . /LICENSE ${docsContentPath}
95
+ cp ${projectPath} /LICENSE ${docsContentPath}
66
96
67
97
# Copy all immediate children of the markdown output the guides/ directory.
68
98
for guidePath in $( find ${docsDistPath} /markdown/ -maxdepth 1 -type f) ; do
@@ -74,8 +104,12 @@ for overviewPath in $(find ${docsDistPath}/markdown/ -mindepth 2 -type f); do
74
104
cp ${overviewPath} ${docsContentPath} /overview
75
105
done
76
106
77
- # Go into the repository directory.
78
- cd ${docsContentPath}
107
+ echo " Successfully copied all content into the docs-content repository."
108
+
109
+ if [[ $( git ls-remote origin " refs/tags/${buildTagName} " ) ]]; then
110
+ echo " Skipping publish of docs-content because tag is already published. Exiting.."
111
+ exit 0
112
+ fi
79
113
80
114
# Setup the Git configuration
81
115
git config user.name " $commitAuthorName "
@@ -84,7 +118,11 @@ git config credential.helper "store --file=.git/credentials"
84
118
85
119
echo " https://${MATERIAL2_DOCS_CONTENT_TOKEN} :@github.com" > .git/credentials
86
120
121
+ echo " Credentials for docs-content repository are now set up. Publishing.."
122
+
87
123
git add -A
88
- git commit --allow-empty -m " ${commitMessage } "
89
- git tag " ${commitTag } "
124
+ git commit --allow-empty -m " ${buildCommitMessage } "
125
+ git tag " ${buildTagName } "
90
126
git push origin master --tags
127
+
128
+ echo " Published docs-content for ${buildVersionName} into ${branchName} successfully"
0 commit comments