Skip to content

Commit ab57e5f

Browse files
authored
Merge pull request #139 from mapbox/skip-publish-on-tag
Attempt to skip publish if commit represents a tag
2 parents 92fac68 + 9f8fa37 commit ab57e5f

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

scripts/publish.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ function is_pr_merge() {
2525
fi
2626
}
2727

28+
# Detect if this commit represents a tag. This is useful
29+
# to detect if we are on a travis job that is running due to
30+
# "git tags --push". In this case we don't want to publish even
31+
# if [publish binary] is present since that should refer only to the
32+
# previously job that ran for that commit and not the tag made
33+
function is_tag_commit() {
34+
export COMMIT_MATCHES_KNOWN_TAG=$(git describe --exact-match $(git rev-parse HEAD) 2> /dev/null)
35+
if [[ ${COMMIT_MATCHES_KNOWN_TAG} ]]; then
36+
echo true
37+
fi
38+
}
39+
2840
# `publish` is used to publish binaries to s3 via commit messages if:
2941
# - the commit message includes [publish binary]
3042
# - the commit message includes [republish binary]
@@ -37,8 +49,10 @@ function publish() {
3749

3850
if [[ $(is_pr_merge) ]]; then
3951
echo "Skipping publishing because this is a PR merge commit"
52+
elif [[ $(is_tag_commit) ]]; then
53+
echo "Skipping publishing because this is a tag"
4054
else
41-
echo "Commit message: ${COMMIT_MESSAGE}"
55+
echo "Commit message was: '${COMMIT_MESSAGE}'"
4256

4357
if [[ ${COMMIT_MESSAGE} =~ "[publish binary]" ]]; then
4458
echo "Publishing"
@@ -75,4 +89,4 @@ case $i in
7589
esac
7690
done
7791

78-
publish $@
92+
publish $@

0 commit comments

Comments
 (0)