Skip to content

Commit

Permalink
feat(prod): add production build trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrilPatrice committed Jun 26, 2017
1 parent f5c5398 commit cdca66b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
3 changes: 1 addition & 2 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ workflows:
description: |-
inputs:
- push: false


- PROD: true
# ----------------------------------------------------------------
# --- workflows to Share this step into a Step Library
share-this-step:
Expand Down
38 changes: 21 additions & 17 deletions step.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,41 @@ set -x

THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
TAG_SED_RULES="tag.sed"
if [ -n "$TAG_SED_RULES" ]; then
if [ ! -e "$TAG_SED_RULES" ]; then
TAG_SED_RULES="${THIS_SCRIPT_DIR}/tag.sed"
fi
if [ -n "${RELEASE_TAG}" ]; then
BITRISE_GIT_TAG=$RELEASE_TAG
tag_message="chore(version): new release"
else
BITRISE_GIT_TAG=$(echo $(git describe --tags --abbrev=0 ) | sed -f $TAG_SED_RULES )
BITRISE_GIT_TAG=$(echo $(git describe --tags --abbrev=0 ) | sed -f $TAG_SED_RULES )
tag_message="chore(version): bump version"
fi

envman add --key BITRISE_GIT_TAG --value $BITRISE_GIT_TAG
git commit --allow-empty -m "${tag_message}"

git tag -a $BITRISE_GIT_TAG -m "${tag_message}"
if [ -n "${PROD}" ]; then
suffix="-prod"
fi

git tag -a "${BITRISE_GIT_TAG}${suffix}" -m "${tag_message}"
if [ -n "${push}" -a "${push}" == "true" -o "${push}" == "false" ]
then

if [ "${push}" == "true" ]; then
git push --follow-tags origin $BITRISE_GIT_BRANCH
fi
if (( $? )); then
echo "Failure" >&2
exit 1
else
echo "Success, new tags are :"
echo "$(git log --tags --simplify-by-decoration --pretty="format:%ci %d" | head -5)"
# code block that is dependent on success of previous command
fi
exit 0
else
echo "push variable is required and could only be set to true or false"
if [ "${push}" == "true" ]; then
git push --follow-tags origin $BITRISE_GIT_BRANCH
fi
if (( $? )); then
echo "Failure" >&2
exit 1
else
echo "Success, new tags are :"
echo "$(git log --tags --simplify-by-decoration --pretty="format:%ci %d" | head -5)"
# code block that is dependent on success of previous command
fi
exit 0
else
echo "push variable is required and could only be set to true or false"
exit 1
fi
10 changes: 10 additions & 0 deletions step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ inputs:
is_required: false
is_dont_change_value: true
value_options: []
- PROD: $PROD
opts:
title: "production build trigger"
summary: set for production build.
description: |
append -prod to tag.
is_expand: true
is_required: false
is_dont_change_value: true
value_options: []
- push: "true"
opts:
title: "push the tag"
Expand Down

0 comments on commit cdca66b

Please sign in to comment.