Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger deployment on tag push not working #8518

Closed
ArtFlag opened this issue Sep 29, 2017 · 5 comments
Closed

Trigger deployment on tag push not working #8518

ArtFlag opened this issue Sep 29, 2017 · 5 comments

Comments

@ArtFlag
Copy link

ArtFlag commented Sep 29, 2017

Hi,

I'm trying to understand how to use the deploy section to release my software on GitHub.

I've spent hours figuring out why Travis won't trigger when I push a tag in order to deploy, or why pushing some commits then a tag still shows "Skipping a deployment with the releases provider because this is not a tagged commit"

Here is what I do:

  1. git commit some stuff
  2. git tag -a v1.0 -m "v1"
  3. git push (to master)
  4. git push --tags (to master too)

The build starts, tells me there is no tag (but Github shows my tag, so there is a tag).

.travis.yml:
language: python
branches:
  only:
  - master
python:
- '2.7'
before_install:
- if [ -z "$TRAVIS_TAG" ]; then exit 0; fi
- wget https://raw.githubusercontent.com/creationix/nvm/v0.31.0/nvm.sh -O ~/.nvm/nvm.sh
- source ~/.nvm/nvm.sh
- nvm install 5
- node --version
install:
- pip install -U pip
- pip install -r requirements.txt
- npm install -g grunt-cli
- npm install -g yarn
- npm install -g bower
- yarn add global ruby
- bower install
- gem install sass
script:
- grunt release
deploy:
  skip_cleanup: true
  provider: releases
  api_key:
    secure: ANIqYltOl+jdI
  file: $TRAVIS_BUILD_DIR/theme.tar.gz
  on:
    repo: repo/theme
    tags: true

What am I doing wrong?

I also tried pushing a tag only, it does not trigger the build.

I've noodled quite a bit with my tags (deleting them on the remote and locally, etc), not sure if that has any impact.

One extra question: if I have to push some commits and then push my tags, how does Travis know to stop the first build and start when the tags are pushed? I'm not sure I understand how to use this properly.

Thanks for any pointers.

(My repo is private, let me know if you need extra info on the commits)

@ArtFlag
Copy link
Author

ArtFlag commented Oct 2, 2017

Ok, long story short: RTFM.

A build can be triggered via simple tag push.
In this case, the branch name is the tag name.
Therefore Branch.only.master will never work.

Solution: add a regexp to the branch.only array that matches the tags you want to build.

language: python
branches:
  only:
  - master
  - /^v.*$/
python:
- '2.7'
before_install:
- if [ -z "$TRAVIS_TAG" ]; then exit 0; fi
- wget https://raw.githubusercontent.com/creationix/nvm/v0.31.0/nvm.sh -O ~/.nvm/nvm.sh
- source ~/.nvm/nvm.sh
- nvm install 5
- node --version
install:
- pip install -U pip
- pip install -r requirements.txt
- npm install -g grunt-cli
- npm install -g yarn
- npm install -g bower
- yarn add global ruby
- bower install
- gem install sass
script:
- grunt release
deploy:
  skip_cleanup: true
  provider: releases
  api_key:
    secure: ANIqYltOl
  file: $TRAVIS_BUILD_DIR/theme.tar.gz
  on:
    repo: repo/theme
    tags: true

@ArtFlag ArtFlag closed this as completed Oct 2, 2017
@zpydee
Copy link

zpydee commented Nov 2, 2017

@ArtFlag thanks for your comment, however the FMs ain't so obvious.

@ArtFlag
Copy link
Author

ArtFlag commented Nov 2, 2017

I know, it took me a while to go through different pages and patch the pieces together to realise my mistake.
I hope this issue will help others in the same situation.
I also updated the docs to talk about the branches.only property in the releases page.

There's a few gotchas here and there with Travis, but it's still worth the pain 😉

@madcowswe
Copy link

Thanks for noting the solution, indeed it wasn't obvious. Cheers!

@zpydee
Copy link

zpydee commented Mar 28, 2018

@ArtFlag to be honest, moving to gitlab solved this and so many other problems for me. ihmo, its far superior as a product.

mxcl added a commit to mxcl/PromiseKit that referenced this issue Oct 10, 2018
Attempts deploy based on: 

travis-ci/travis-ci#8518
corinadev added a commit to victronenergy/venus-html5-app that referenced this issue Nov 12, 2018
sylhare added a commit to sylhare/Type-on-Strap that referenced this issue Apr 27, 2019
root670 referenced this issue in root670/CheatDevicePS2 May 18, 2019
eneelo pushed a commit to dnvgl/qats that referenced this issue Jun 26, 2019
fordnox added a commit to boxbilling/boxbilling that referenced this issue Nov 1, 2020
j3ko added a commit to j3ko/commit-composer that referenced this issue Nov 13, 2020
j3ko added a commit to j3ko/commit-composer that referenced this issue Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants