11#! /bin/bash
22set -e
33
4- # Check for required variables are defined
5- test -v GITAUTH_USER || (echo " Missing GITAUTH_USER variable" && exit 1)
6- test -v GITAUTH_PASS || (echo " Missing GITAUTH_PASS variable" && exit 1)
7-
8- # Check gitlab variables are set
9- test -v GITLAB_USER_EMAIL || (echo " Missing GITLAB_USER_EMAIL variable" && exit 1)
10- test -v GITLAB_USER_NAME || (echo " Missing GITLAB_USER_NAME variable" && exit 1)
11- test -v CI_REPOSITORY_URL || (echo " Missing CI_REPOSITORY_URL variable" && exit 1)
12-
13- # Setup git details
14- echo " Setting git author $GITLAB_USER_NAME <$GITLAB_USER_EMAIL >"
15- git config --global user.email " $GITLAB_USER_EMAIL "
16- git config --global user.name " $GITLAB_USER_NAME "
17-
18- # Fetch tags
19- echo " Fetching tags"
20- git fetch --tags --prune
21- # Check for existing tags
22- if [ " $( git ls-remote --tags | wc -l) " == " 0" ] ; then
23- # Default version
24- PREV_VERSION=' 0.0.0'
25- COMPARE_TO=$( git log --pretty=format:%H | tail -1)
26- INC=' MAJOR'
27- else
28- # Lookup latest version
29- PREV_VERSION=$( latesttag)
30- COMPARE_TO=$PREV_VERSION
31- echo " Analysing for next semver version compared to '$PREV_VERSION '"
32- INC=$( php-autosemver $COMPARE_TO )
33- fi
34-
35- echo " Next inc is '$INC '"
36-
37- echo " Calculating next version from '$PREV_VERSION '"
38- VERSION=$( composer-version --inc $PREV_VERSION $INC )
39-
40- echo " "
41- echo " Current version: $PREV_VERSION "
42- echo " Increment: $INC "
43- echo " New version: $VERSION "
44-
45- echo " "
46- echo " Creating Git tag '$VERSION '"
47- git tag $VERSION
48-
49- # Show graph
50- git log --all --decorate --oneline --graph -10
51-
52- # Update remote URL so we can push, then push the tag
53- echo " Adding auth to $CI_REPOSITORY_URL "
54- NEW_URL=$( addauth $CI_REPOSITORY_URL $GITAUTH_USER $GITAUTH_PASS )
55-
56- echo " Updating remote"
57- ORIGINAL_REMOTE=$( git remote get-url origin)
58- git remote set-url origin $NEW_URL
59-
60- echo " Pushing tag $VERSION "
61- git push origin $VERSION
62-
63- echo " Resetting remote"
64- git remote set-url origin $ORIGINAL_REMOTE
4+ VERSION=$( next-version)
5+ echo " VERSION=${VERSION} "
6+ echo " Tagging"
7+ git-tag ${VERSION}
0 commit comments