Skip to content

Commit

Permalink
Merge pull request #83 from zalando-stups/58-auto-versions-with-travis
Browse files Browse the repository at this point in the history
#58 switching to a more manual way, but without pitfalls
  • Loading branch information
Adeynack authored Dec 21, 2017
2 parents 092969b + 060366d commit 99ba43b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 30 deletions.
23 changes: 4 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ docker_tag ?= zalando-stups/skrop

CURRENT_VERSION = $(shell git describe --tags --always --dirty)
VERSION ?= $(CURRENT_VERSION)
NEXT_MAJOR = $(shell go run packaging/version/version.go major $(CURRENT_VERSION))
NEXT_MINOR = $(shell go run packaging/version/version.go minor $(CURRENT_VERSION))
NEXT_PATCH = $(shell go run packaging/version/version.go patch $(CURRENT_VERSION))
COMMIT_HASH = $(shell git rev-parse --short HEAD)

Expand Down Expand Up @@ -43,36 +41,23 @@ tag:
push-tags:
git push --tags https://$(GITHUB_AUTH)@github.com/zalando-stups/skrop

release-major:
echo Incrementing major version
make VERSION=$(NEXT_MAJOR) tag push-tags

release-minor:
echo Incrementing minor version
make VERSION=$(NEXT_MINOR) tag push-tags

release-patch:
echo Incrementing patch version
echo "Incrementing patch version"
make VERSION=$(NEXT_PATCH) tag push-tags

ci-user:
git config --global user.email "[email protected]"
git config --global user.name "Travis CI"

ci-release-major: ci-user init-deps release-major
ci-release-minor: ci-user init-deps release-minor
ci-release-patch: ci-user init-deps release-patch

ci-test:
./.travis/test.sh

ci-trigger: ci-test
ifeq ($(TRAVIS_BRANCH)_$(TRAVIS_PULL_REQUEST)_$(findstring major-release,$(TRAVIS_COMMIT_MESSAGE)), master_false_major-release)
make ci-release-major
else ifeq ($(TRAVIS_BRANCH)_$(TRAVIS_PULL_REQUEST)_$(findstring minor-release,$(TRAVIS_COMMIT_MESSAGE)), master_false_minor-release)
make ci-release-minor
else ifeq ($(TRAVIS_BRANCH)_$(TRAVIS_PULL_REQUEST), master_false)
ifeq ($(TRAVIS_BRANCH)_$(TRAVIS_PULL_REQUEST), master_false)
echo "Merge to 'master'. Tagging patch version up."
make ci-release-patch
else
echo Not a merge to 'master'. Not versionning this merge.
echo "Not a merge to 'master'. Not versionning this merge."
endif
48 changes: 37 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,43 @@ env:
- secure: "someBASE64value"
```
### Versioning
This project uses [semantic versioning](https://semver.org/). The version is bumped up automatically at
every merge to master (by [_Travis CI_](/.travis.yml)).
To control which part of the version is bumped up, the commit message of the merge commit (including the first line
of the commit message of all commits it consist of) has to include a special part.
- `major-release`: the first digit (the major version) will be incremented. Example: from `3.23.291` to `4.0.0`.
- `minor-release`: the second digit (the minor version) will be incremented. Example: from `3.23.291` to `3.24.0`.
- anything else not including one of the text above will result in the third digit (the patch version) to be incremented.
Example: `3.23.291` to `3.23.292`.
## Versioning
This project uses [semantic versioning](https://semver.org/).
The patch-version (3rd digit) is bumped up automatically at every merge to master (by [_Travis CI_](/.travis.yml)).
### Increment the patch version
This is done automatically by _Travis CI_. Nothing special to do here. Example: merging when latest tag is `v3.23.291`
will automaticall tag a version `v3.23.292`.

### Increment the minor version
Since _Travis CI_ only automatically increases the patch-version, we need to manually pre-tag with the new version we
want.

Scenario:
- actual version is `v3.23.291`
- tag one of the commit on your branch with the new version you want.
- it is **important** that the patch version be `-1`, since it will be incremented automatically by _Travis CI_.
- `git tag v3.24.-1 && git push --tags`
- open the pull request.
- after merge, _Travis CI_ will tag automatically the right final version `v3.24.0`.
- delete the temporary manual tag
- `git tag -d v3.24.-1 && git push --tags`

### Increment the major version
Since _Travis CI_ only automatically increases the patch-version, we need to manually pre-tag with the new version we
want.

Scenario:
- actual version is `v3.23.291`
- tag one of the commit on your branch with the new version you want.
- it is **important** that the patch version be `-1`, since it will be incremented automatically by _Travis CI_.
- `git tag v4.0.-1 && git push --tags`
- open the pull request.
- after merge, _Travis CI_ will tag automatically the right final version `v4.0.0`.
- delete the temporary manual tag
- `git tag -d v4.0.-1 && git push --tags`


## License
Expand Down

0 comments on commit 99ba43b

Please sign in to comment.