Skip to content

Commit c20cc83

Browse files
committed
#171 added automatic release versioning
1 parent ae96fe8 commit c20cc83

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

.travis.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,7 @@ before_deploy:
4040
- if ! [ "$BEFORE_DEPLOY_RUN" ]; then
4141
export BEFORE_DEPLOY_RUN=1;
4242

43-
git config --local user.name 'bugy';
44-
git config --local user.email '[email protected]';
45-
git tag -f 'dev';
46-
git remote add gh https://${OWNER}:${GITHUB_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git;
47-
git push -f gh dev;
48-
git remote remove gh;
43+
tools/add_git_tag.sh
4944

5045
fi
5146
deploy:

tools/add_git_tag.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
3+
if [ -z "$TRAVIS_BRANCH" ] || [ -z "$OWNER" ] || [ -z "$GITHUB_TOKEN" ] || [ -z "$TRAVIS_REPO_SLUG" ]; then
4+
echo 'Some environment variables are not set'
5+
exit -1
6+
fi
7+
8+
if [ "$TRAVIS_BRANCH" == "master" ]; then
9+
export NEW_GIT_TAG='dev'
10+
11+
elif [ "$TRAVIS_BRANCH" == "stable" ]; then
12+
last_tag=`git describe --abbrev=0 --tags`
13+
npm_tag=`grep -Po '"version": "\d+.\d+.\d+"' web-src/package.json | grep -Po '\d+.\d+.\d+'`
14+
minor_npm_version=${npm_tag%.*}
15+
if [ ${last_tag%.*} == "$minor_npm_version" ]; then
16+
patch_npm_version=${npm_tag##*.}
17+
next_patch_version=$((patch_npm_version + 1))
18+
export NEW_GIT_TAG="$minor_npm_version.$next_patch_version"
19+
else
20+
export NEW_GIT_TAG="$npm_tag"
21+
fi
22+
fi
23+
24+
set -e
25+
26+
if [ -z "$NEW_GIT_TAG" ]; then
27+
echo 'Skipping tagging of branch' "$TRAVIS_BRANCH"
28+
29+
else
30+
git config --local user.name 'bugy';
31+
git config --local user.email '[email protected]';
32+
git tag -f "$NEW_GIT_TAG";
33+
git remote add gh https://${OWNER}:${GITHUB_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git;
34+
git push -f gh "$NEW_GIT_TAG";
35+
git remote remove gh;
36+
fi

tools/deploy_docker.sh

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ docker login -u "$DOCKER_USER" -p "$DOCKER_PASSWORD"
1717

1818
if [ "$TRAVIS_BRANCH" == "stable" ]; then
1919
docker tag "$IMAGE_NAME":"$COMMIT" "$IMAGE_NAME":latest
20+
21+
if [ ! -z "$NEW_GIT_TAG" ]; then
22+
docker tag "$IMAGE_NAME":"$COMMIT" "$IMAGE_NAME":"$NEW_GIT_TAG"
23+
fi
24+
2025
elif [ "$TRAVIS_BRANCH" == "master" ]; then
2126
docker tag "$IMAGE_NAME":"$COMMIT" "$IMAGE_NAME":dev
2227
else

0 commit comments

Comments
 (0)