Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion scripts/deploy/publish-build-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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}"
Expand All @@ -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}"
Expand Down