Skip to content

Commit

Permalink
feat(tag): initial checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrilPatrice committed Aug 10, 2016
0 parents commit 65f3d21
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.bitrise*
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 Bitrise

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Tag Generator
to be combinated with changelog-generator
67 changes: 67 additions & 0 deletions bitrise.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
format_version: 1.1.0
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git

workflows:
test:
steps:
- change-workdir:
title: Switch working dir to test / _tmp dir
description: |-
To prevent step testing issues, like referencing relative
files with just './some-file' in the step's code, which would
work for testing the step from this directory directly
but would break if the step is included in another `bitrise.yml`.
run_if: true
inputs:
- path: ./_tmp
- is_create_path: true
- path::./:
title: Step Test
description: |-
inputs:
- push: false


# ----------------------------------------------------------------
# --- workflows to Share this step into a Step Library
share-this-step:
envs:
# if you want to share this step into a StepLib
- MY_STEPLIB_REPO_FORK_GIT_URL:
- STEP_ID_IN_STEPLIB:
- STEP_GIT_VERION_TAG_TO_SHARE:
- STEP_GIT_CLONE_URL:
description: |-
If this is the first time you try to share a Step you should
first call: $ bitrise share
This will print you a guide, and information about how Step sharing
works. Please read it at least once!
As noted in the Step sharing guide you'll have to fork the
StepLib you want to share this step into. Once you're done with forking
the repository you should set your own fork's git clone URL
in the `.bitrise.secrets.yml` file, or here in the `envs` section,
as the value of the `MY_STEPLIB_REPO_FORK_GIT_URL` environment.
You're now ready to share this Step, just make sure that
the `STEP_ID_IN_STEPLIB` and `STEP_GIT_VERION_TAG_TO_SHARE`
environments are set to the desired values!
To share this Step into a StepLib you can just run: $ bitrise run share-this-step
Once it finishes the only thing left is to actually create a Pull Request,
the way described in the guide printed at the end of the process.
steps:
- script:
inputs:
- content: |-
#!/bin/bash
set -e
set -x
bitrise share start -c ${MY_STEPLIB_REPO_FORK_GIT_URL}
bitrise share create --stepid ${STEP_ID_IN_STEPLIB} --tag ${STEP_GIT_VERION_TAG_TO_SHARE} --git ${STEP_GIT_CLONE_URL}
bitrise share finish
46 changes: 46 additions & 0 deletions step.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
# fail if any commands fails
set -e
set -x

if [ -n "${RELEASE_TAG}" ]; then
BITRISE_GIT_TAG=$RELEASE_TAG
tag_message="chore(version): new release"
BITRISE_GIT_BRANCH="feat/create_${BITRISE_GIT_TAG}"

else
BITRISE_GIT_TAG=$(echo $(git describe --tags --abbrev=0 ) | sed "s/v[0-9\.]*\.[0-9]*[0-9]/&@/g
:a
{s/0@/1/g;s/1@/2/g;s/2@/3/g;s/3@/4/g;s/4@/5/g;s/5@/6/g;s/6@/7/g;s/7@/8/g;s/8@/9/g;s/9@/@0/g;t a
}
s/@/1/g")
tag_message="chore(version): bump version"
BITRISE_GIT_BRANCH="feat/bump_${BITRISE_GIT_TAG}"

fi

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

git tag -a $BITRISE_GIT_TAG -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 tag)"
# 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
50 changes: 50 additions & 0 deletions step.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
title: "Tag generator"
summary: create a branch and tag ;)
description: |-
website: https://github.com/...
source_code_url: https://github.com/...
support_url: https://github.com/.../issues
host_os_tags:
- osx-10.10
project_type_tags:
- ios
type_tags:
- script
is_always_run: false
is_skippable: false
dependencies:
- manager: brew
name: git
run_if: ""
inputs:
- RELEASE_TAG: $RELEASE_TAG
opts:
title: "major version tag"
summary: set the major version.
description: |
set a major version tag
is_expand: true
is_required: false
is_dont_change_value: true
value_options: []
- push: "true"
opts:
title: "push the tag"
summary: ""
description: |
push the branch
is_expand: false
is_required: true
is_dont_change_value: true
value_options: []
outputs:
- BITRISE_GIT_TAG:
opts:
title: "last tag"
summary: the current tag.
description: |
the provided tag or the last one incremented v(V.M.m+1).
is_expand: false
is_required: true
is_dont_change_value: true

0 comments on commit 65f3d21

Please sign in to comment.