My build is a Java/Maven build. I would like to achieve the following:
- tagged commits are deployed to the corresponding GitHub release as a draft. Those are supposedly releases or release candidates
- untagged commits are deployed to a GitHub release named after the Maven project version. Those are supposedly snapshots and may be overridden many times
Here’s what I have come up with:
before_deploy: - if [[ -z "$TRAVIS_TAG" ]]; then export TRAVIS_TAG=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout); git tag -f $TRAVIS_TAG; fi deploy: provider: releases draft: false overwrite: true api_key: secure: ... skip_cleanup: true file: ...
It seems to work but I’m not quite happy yet:
- tagging the untagged commit triggers a double build… is there a way to avoid that? Also, since the second build is a tagged build I was expecting it to trigger a deploy again, but it doesn’t, it says “Skipping a deployment with the releases provider because this branch is not permitted: 1.0-SNAPSHOT”
- I would like my “real” tagged commits to be deployed as draft releases, because they might need to be edited before being published. On the other hand, snapshots can be published right away. How can I use the same provider but configure it differently depending if I’m deploying a snapshot or not? I tried to duplicate the Github releases provider and add conditions like
condition: "$TRAVIS_TAG" =~ -SNAPSHOT$but Travis complained that it could not parse the file…
Any help appreciated!