build(artifacts): sed should not update .git/ files (#8938)

* Adds more logging messages to the publish artifacts script (better debugging)
* Updates the `find` command for the version `sed` call to no longer match files inside of the `.git/` directory (might lead to a broken .git/ setup)
This commit is contained in:
Paul Gschwendtner
2017-12-15 00:31:38 +01:00
committed by Andrew Seguin
parent f95f832ab0
commit 898cded17a
+15 -1
View File
@@ -41,6 +41,8 @@ publishPackage() {
repoUrl="https://github.com/angular/${packageRepo}.git"
repoDir="tmp/${packageRepo}"
echo "Starting publish process of ${packageName} for ${commitTag}.."
if [[ ! ${COMMAND_ARGS} == *--no-build* ]]; then
# Create a release of the current repository.
$(npm bin)/gulp ${packageName}:build-release:clean
@@ -50,16 +52,24 @@ publishPackage() {
rm -rf ${repoDir}
mkdir -p ${repoDir}
echo "Starting cloning process of ${repoUrl} into ${repoDir}.."
# Clone the repository and only fetch the last commit to download less unused data.
git clone ${repoUrl} ${repoDir} --depth 1
echo "Successfully cloned ${repoUrl} into ${repoDir}."
# Copy the build files to the repository
rm -rf ${repoDir}/*
cp -r ${buildDir}/* ${repoDir}
echo "Removed everything from ${packageRepo} and added the new build output."
# Create the build commit and push the changes to the repository.
cd ${repoDir}
echo "Switched into the repository directory (${repoDir})."
if [[ $(git ls-remote origin "refs/tags/${commitTag}") ]]; then
echo "Skipping publish because tag is already published"
exit 0
@@ -68,7 +78,9 @@ publishPackage() {
# Replace the version in every file recursively with a more specific version that also includes
# the SHA of the current build job. Normally this "sed" call would just replace the version
# placeholder, but the version placeholders have been replaced by the release task already.
sed -i "s/${buildVersion}/${commitTag}/g" $(find . -type f)
sed -i "s/${buildVersion}/${commitTag}/g" $(find . -type f -not -path '*\/.*')
echo "Updated the build version in every file to include the SHA of the latest commit."
# Prepare Git for pushing the artifacts to the repository.
git config user.name "${commitAuthorName}"
@@ -77,6 +89,8 @@ publishPackage() {
echo "https://${MATERIAL2_BUILDS_TOKEN}:@github.com" > .git/credentials
echo "Git configuration has been updated to match the last commit author. Publishing now.."
git add -A
git commit --allow-empty -m "${commitMessage}"
git tag "${commitTag}"