Reputation: 7371
I'm trying to configure automation release deployment to Github releases with Travis CI build. My .travis.yml
file looks like:
language: java
jdk: oraclejdk8
branches:
only:
- master
before_install: mvn package -DskipTests=true -DbuildNumber=$TRAVIS_BUILD_NUMBER
before_deploy:
- git config --local user.name "$USER_NAME"
- git config --local user.email "$USER_EMAIL"
- export GIT_TAG=1.0.$TRAVIS_BUILD_NUMBER
- git tag $GIT_TAG -a -m "Generated tag from TravisCI build $TRAVIS_BUILD_NUMBER"
- git push origin $GIT_TAG
deploy:
provider: releases
api_key: $GITHUB_TOKEN
file:
- target/tweetsched-dto-1.0.$TRAVIS_BUILD_NUMBER.jar
name: tweetsched-dto-1.0.$TRAVIS_BUILD_NUMBER
skip-cleanup: true
on:
tags: true
repo: Tweetsched/tweetsched-dto
branches:
only:
- master
notifications:
email:
on_success: never
on_failure: always
And what I want - PR is merged to Master branch Travis CI create a new tag in before_deploy
step and then create new release according to that tag. But when I test it I always get a message in Travis CI logs:
Skipping a deployment with the releases provider because this is not a tagged commit
There are no any messages about why it doesn't create tags. What am I doing wrong? And how correctly to configure Travis to release new versions of artifact on successful builds from Master branch?
Upvotes: 3
Views: 2215
Reputation: 7371
Finally I had solved the issue and final version of config looks like:
language: java
jdk: oraclejdk8
branches:
only:
- master
before_install: mvn package -DskipTests=true -DbuildNumber=$TRAVIS_BUILD_NUMBER
before_deploy:
- export TRAVIS_TAG="1.0.$TRAVIS_BUILD_NUMBER"
- echo "$TRAVIS_TAG" "$TRAVIS_COMMIT"
- git config --local user.name "$USER_NAME"
- git config --local user.email "$USER_EMAIL"
- git tag "$TRAVIS_TAG" "$TRAVIS_COMMIT"
deploy:
provider: releases
tag_name: $TRAVIS_TAG
target_commitish: $TRAVIS_COMMIT
name: $TRAVIS_TAG
overwrite: true
skip_cleanup: true
api_key: $GITHUB_TOKEN
file_glob: true
file:
- target/tweetsched-dto-1.0.$TRAVIS_BUILD_NUMBER.jar
on:
branch: master
repo: Tweetsched/tweetsched-dto
notifications:
email:
on_success: never
on_failure: always
Upvotes: 3
Reputation: 94397
For Travis to consider the tag you need to set $TRAVIS_TAG
env var. See https://docs.travis-ci.com/user/deployment/#conditional-releases-with-on
export TRAVIS_TAG=$GIT_TAG
Upvotes: 0