@@ -37,10 +37,13 @@ publishPackage() {
37
37
commitAuthorName=$( git --no-pager show -s --format=' %an' HEAD)
38
38
commitAuthorEmail=$( git --no-pager show -s --format=' %ae' HEAD)
39
39
commitMessage=$( git log --oneline -n 1)
40
+ commitTag=" ${buildVersion} -${commitSha} "
40
41
41
42
repoUrl=" https://github.com/angular/${packageRepo} .git"
42
43
repoDir=" tmp/${packageRepo} "
43
44
45
+ echo " Starting publish process of ${packageName} for ${commitTag} .."
46
+
44
47
if [[ ! ${COMMAND_ARGS} == * --no-build* ]]; then
45
48
# Create a release of the current repository.
46
49
$( npm bin) /gulp ${packageName} :build-release:clean
@@ -50,36 +53,53 @@ publishPackage() {
50
53
rm -rf ${repoDir}
51
54
mkdir -p ${repoDir}
52
55
56
+ echo " Starting cloning process of ${repoUrl} into ${repoDir} .."
57
+
53
58
# Clone the repository and only fetch the last commit to download less unused data.
54
59
git clone ${repoUrl} ${repoDir} --depth 1
55
60
61
+ echo " Successfully cloned ${repoUrl} into ${repoDir} ."
62
+
56
63
# Copy the build files to the repository
57
64
rm -rf ${repoDir} /*
58
65
cp -r ${buildDir} /* ${repoDir}
59
66
60
67
# Copy the npm README.md to the flex-layout-builds dir...
61
68
cp -f " scripts/release/README.md" ${repoDir}
62
69
70
+ echo " Removed everything from ${packageRepo} and added the new build output."
71
+
63
72
# Create the build commit and push the changes to the repository.
64
73
cd ${repoDir}
65
74
66
- # Replace the version in every file recursively with a more specific version that also includes
75
+ echo " Switched into the repository directory (${repoDir} )."
76
+
77
+ if [[ $( git ls-remote origin " refs/tags/${commitTag} " ) ]]; then
78
+ echo " Skipping publish because tag is already published"
79
+ exit 0
80
+ fi
81
+
82
+ # Replace the version in every file recursively with a more specific version that also includes
67
83
# the SHA of the current build job. Normally this "sed" call would just replace the version
68
84
# placeholder, but the version placeholders have been replaced by the release task already.
69
- sed -i " s/${buildVersion} /${buildVersion} - ${commitSha} /g" $( find . -type f)
85
+ sed -i " s/${buildVersion} /${commitTag} /g" $( find . -type f -not -path ' *\/.* ' )
70
86
71
87
cp -f " ${srcDir} /CHANGELOG.md" ./
72
88
89
+ echo " Updated the build version in every file to include the SHA of the latest commit."
90
+
73
91
# Prepare Git for pushing the artifacts to the repository.
74
92
git config user.name " ${commitAuthorName} "
75
93
git config user.email " ${commitAuthorEmail} "
76
94
git config credential.helper " store --file=.git/credentials"
77
95
78
- echo " https://${FLEX_LAYOUT_BUILDS_TOKEN} :@github.com" > .git/credentials
96
+ echo " https://${FLEX_LAYOUT_BUILDS_TOKEN} :@github.com" > .git/credentials
97
+
98
+ echo " Git configuration has been updated to match the last commit author. Publishing now.."
79
99
80
100
git add -A
81
101
git commit --allow-empty -m " ${commitMessage} "
82
- git tag " ${buildVersion} - ${commitSha }"
102
+ git tag " ${commitTag } "
83
103
git push origin master --tags
84
104
85
105
echo " Published package artifacts for ${packageName} #${commitSha} ."
0 commit comments