Skip to content

build: skip artifact publish if tag already exists #8720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2017
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
10 changes: 8 additions & 2 deletions scripts/deploy/publish-build-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@ publishPackage() {
commitAuthorName=$(git --no-pager show -s --format='%an' HEAD)
commitAuthorEmail=$(git --no-pager show -s --format='%ae' HEAD)
commitMessage=$(git log --oneline -n 1)
commitTag="${buildVersion}-${commitSha}"

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

if [[ $(git rev-parse -q --verify "refs/tags/${commitTag}") ]]; then
echo "Skipping publish because tag is already published"
exit 0
fi

if [[ ! ${COMMAND_ARGS} == *--no-build* ]]; then
# Create a release of the current repository.
$(npm bin)/gulp ${packageName}:build-release:clean
Expand All @@ -62,7 +68,7 @@ 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}/${buildVersion}-${commitSha}/g" $(find . -type f)
sed -i "s/${buildVersion}/${commitTag}/g" $(find . -type f)

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

git add -A
git commit --allow-empty -m "${commitMessage}"
git tag "${buildVersion}-${commitSha}"
git tag "${commitTag}"
git push origin master --tags

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