Skip to content

Commit 826394b

Browse files
devversionmmalerba
authored andcommitted
build: skip artifact publish if tag already exists (#8720)
* No longer errors the deployment if the artifacts have been published already. (e.g. Job restart)
1 parent 03b7e84 commit 826394b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

scripts/deploy/publish-build-artifacts.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,16 @@ publishPackage() {
3636
commitAuthorName=$(git --no-pager show -s --format='%an' HEAD)
3737
commitAuthorEmail=$(git --no-pager show -s --format='%ae' HEAD)
3838
commitMessage=$(git log --oneline -n 1)
39+
commitTag="${buildVersion}-${commitSha}"
3940

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

44+
if [[ $(git rev-parse -q --verify "refs/tags/${commitTag}") ]]; then
45+
echo "Skipping publish because tag is already published"
46+
exit 0
47+
fi
48+
4349
if [[ ! ${COMMAND_ARGS} == *--no-build* ]]; then
4450
# Create a release of the current repository.
4551
$(npm bin)/gulp ${packageName}:build-release:clean
@@ -62,7 +68,7 @@ publishPackage() {
6268
# Replace the version in every file recursively with a more specific version that also includes
6369
# the SHA of the current build job. Normally this "sed" call would just replace the version
6470
# placeholder, but the version placeholders have been replaced by the release task already.
65-
sed -i "s/${buildVersion}/${buildVersion}-${commitSha}/g" $(find . -type f)
71+
sed -i "s/${buildVersion}/${commitTag}/g" $(find . -type f)
6672

6773
# Prepare Git for pushing the artifacts to the repository.
6874
git config user.name "${commitAuthorName}"
@@ -73,7 +79,7 @@ publishPackage() {
7379

7480
git add -A
7581
git commit --allow-empty -m "${commitMessage}"
76-
git tag "${buildVersion}-${commitSha}"
82+
git tag "${commitTag}"
7783
git push origin master --tags
7884

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

0 commit comments

Comments
 (0)