-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.travis.yml
65 lines (57 loc) · 2.64 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
language: java
if: tag is blank
services:
- 'docker'
before_install:
- echo GET CONFIG FROM DOCKERFILE
- export IMAGE_NAME=$(grep imagename= Dockerfile | sed -e 's/.*imagename="\(.*\)".*/\1/')
- export TEST_COMMAND=$(grep test.command= Dockerfile | sed -e 's/.*test.command="\(.*\)".*/\1/')
- export TEST_COMMAND_VERIFY=$(grep test.command.verify= Dockerfile | sed -e 's/.*test.command.verify="\(.*\)".*/\1/')
- export IMAGE_VERSION=$(grep version= Dockerfile | sed -e 's/.*version="\(.*\)".*/\1/')
- export IMAGE="$ORGANISATION_NAME/$IMAGE_NAME"
- echo IMAGE_NAME=$IMAGE_NAME
- echo IMAGE_VERSION=$IMAGE_VERSION
- echo TEST_COMMAND=$TEST_COMMAND
- echo TEST_COMMAND_VERIFY=$TEST_COMMAND_VERIFY
- export CURRENT_VERSION=$(git describe --tag --always --long | sed -e 's/\(.*\)-\(.*\)-.*/\1.\2/')
- declare -a CURRENT_VERSION_ARRAY="(${CURRENT_VERSION//./ })"; export SEMVER_MAJOR=${CURRENT_VERSION_ARRAY[0]}; export SEMVER_MINOR=${CURRENT_VERSION_ARRAY[1]}; export SEMVER_PATCH=${CURRENT_VERSION_ARRAY[2]}; export SEMVER_BUILD=${CURRENT_VERSION_ARRAY[-1]}
- export SEMVER_BUILD=$(( ${SEMVER_PATCH} + ${SEMVER_BUILD} ))
- echo SEMVER_MAJOR:${SEMVER_MAJOR}
- echo SEMVER_MINOR:${SEMVER_MINOR}
- echo SEMVER_BUILD:${SEMVER_BUILD}
- export SEMVER=${SEMVER_MAJOR}.${SEMVER_MINOR}.${SEMVER_BUILD}
- echo SEMVER:$SEMVER
- if [[ ${SEMVER_MAJOR} == "" ]]; then travis_terminate 1; fi
- export TRAVIS_TAG=$SEMVER
- echo TRAVIS_TAG:$TRAVIS_TAG
#build and test
install:
- docker build --pull -t $IMAGE:$IMAGE_VERSION .
- export CONTAINER_COMMAND="docker run $IMAGE:$IMAGE_VERSION $TEST_COMMAND"
- echo CONTAINER_COMMAND=$CONTAINER_COMMAND
- export CONTAINER_OUTPUT=$(eval $CONTAINER_COMMAND)
- echo CONTAINER_OUTPUT=$CONTAINER_OUTPUT
- if [[ ! ${CONTAINER_OUTPUT} =~ ${TEST_COMMAND_VERIFY} ]]; then travis_terminate 1; fi
- docker images
#test
script:
- echo "LOGIN TO HUB.DOCKER"
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- echo "PUSH HUB.DOCKER"
- docker push $IMAGE:$IMAGE_VERSION
- if [[ $TRAVIS_BRANCH == "master" ]]; then docker tag $IMAGE:$IMAGE_VERSION $IMAGE:latest && docker push $IMAGE:latest; fi
- echo "UPDATE README IN HUB.DOCKER"
- if [[ $TRAVIS_BRANCH == "master" ]]; then docker run --rm -v $(pwd):/data/ aemdesign/dockerhub-description "$DOCKER_USERNAME" "$DOCKER_PASSWORD" "$IMAGE"; fi
## Get the project version
before_deploy:
- if [[ $TRAVIS_BRANCH == "master" ]]; then git tag $TRAVIS_TAG; fi
## Create release in GitHub
deploy:
provider: releases
tag_name: $TRAVIS_TAG
name: $TRAVIS_TAG
target_commitish: $TRAVIS_COMMIT
api_key: $GITHUB_TOKEN
skip_cleanup: true
on:
branch: master