Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit fe877c9

Browse files
chore(publis): update ci publish artifacts script
1 parent 2f88bb8 commit fe877c9

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

scripts/deploy/publish-build-artifacts.sh

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@ publishPackage() {
3737
commitAuthorName=$(git --no-pager show -s --format='%an' HEAD)
3838
commitAuthorEmail=$(git --no-pager show -s --format='%ae' HEAD)
3939
commitMessage=$(git log --oneline -n 1)
40+
commitTag="${buildVersion}-${commitSha}"
4041

4142
repoUrl="https://github.com/angular/${packageRepo}.git"
4243
repoDir="tmp/${packageRepo}"
4344

45+
echo "Starting publish process of ${packageName} for ${commitTag}.."
46+
4447
if [[ ! ${COMMAND_ARGS} == *--no-build* ]]; then
4548
# Create a release of the current repository.
4649
$(npm bin)/gulp ${packageName}:build-release:clean
@@ -50,36 +53,53 @@ publishPackage() {
5053
rm -rf ${repoDir}
5154
mkdir -p ${repoDir}
5255

56+
echo "Starting cloning process of ${repoUrl} into ${repoDir}.."
57+
5358
# Clone the repository and only fetch the last commit to download less unused data.
5459
git clone ${repoUrl} ${repoDir} --depth 1
5560

61+
echo "Successfully cloned ${repoUrl} into ${repoDir}."
62+
5663
# Copy the build files to the repository
5764
rm -rf ${repoDir}/*
5865
cp -r ${buildDir}/* ${repoDir}
5966

6067
# Copy the npm README.md to the flex-layout-builds dir...
6168
cp -f "scripts/release/README.md" ${repoDir}
6269

70+
echo "Removed everything from ${packageRepo} and added the new build output."
71+
6372
# Create the build commit and push the changes to the repository.
6473
cd ${repoDir}
6574

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
6783
# the SHA of the current build job. Normally this "sed" call would just replace the version
6884
# 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 '*\/.*')
7086

7187
cp -f "${srcDir}/CHANGELOG.md" ./
7288

89+
echo "Updated the build version in every file to include the SHA of the latest commit."
90+
7391
# Prepare Git for pushing the artifacts to the repository.
7492
git config user.name "${commitAuthorName}"
7593
git config user.email "${commitAuthorEmail}"
7694
git config credential.helper "store --file=.git/credentials"
7795

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.."
7999

80100
git add -A
81101
git commit --allow-empty -m "${commitMessage}"
82-
git tag "${buildVersion}-${commitSha}"
102+
git tag "${commitTag}"
83103
git push origin master --tags
84104

85105
echo "Published package artifacts for ${packageName}#${commitSha}."

0 commit comments

Comments
 (0)