From 9227281d4ca4dafa2963b7722b53f1324e660802 Mon Sep 17 00:00:00 2001 From: paulfantom Date: Mon, 25 Jun 2018 10:57:55 +0200 Subject: [PATCH 1/4] add releaser script --- .travis/releaser.sh | 71 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100755 .travis/releaser.sh diff --git a/.travis/releaser.sh b/.travis/releaser.sh new file mode 100755 index 0000000..0c04ce8 --- /dev/null +++ b/.travis/releaser.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# +# Copyright (C) 2018 Pawel Krupa (@paulfantom) - All Rights Reserved +# Permission to copy and modify is granted under the MIT license +# +# Script to automatically do a couple of things: +# - generate a new tag according to semver (https://semver.org/) +# - generate CHANGELOG.md by using https://github.com/skywinder/github-changelog-generator +# - sync CHANGELOG with GitHub releases by using https://github.com/mattbrictson/chandler +# +# Tags are generated by searching for a keyword in last commit message. Keywords are: +# - [patch] or [fix] to bump patch number +# - [minor], [feature] or [feat] to bump minor number +# - [major] or [breaking change] to bump major number +# All keywords MUST be surrounded with square braces. +# +# Script uses git mechanisms for locking, so it can be used in parallel builds +# +# Requirements: +# - GH_TOKEN variable set with GitHub token. Access level: repo.public_repo +# - docker +# - git-semver python package (pip install git-semver) + +# Exit when latest commit is tagged +[[ $(git tag --points-at) ]] && exit 0 + +# Some basic variables +GIT_MAIL="cloudalchemybot@gmail.com" +GIT_USER="cloudalchemybot" +ORGANIZATION=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $1}') +PROJECT=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $2}') +GALAXY_URL="https://galaxy.ansible.com/${ORGANIZATION}/${PROJECT#ansible-}" + +# Git config +git config --global user.email "${GIT_MAIL}" +git config --global user.name "${GIT_USER}" +GIT_URL=$(git config --get remote.origin.url) +GIT_URL=${GIT_URL#*//} + +# Generate TAG +GIT_TAG=none +echo "Last commit message: $TRAVIS_COMMIT_MESSAGE" +case "${TRAVIS_COMMIT_MESSAGE}" in + *"[patch]"*|*"[fix]"* ) GIT_TAG=$(git semver --next-patch) ;; + *"[minor]"*|*"[feat]"*|*"[feature]"* ) GIT_TAG=$(git semver --next-minor) ;; + *"[major]"*|*"[breaking change]"* ) GIT_TAG=$(git semver --next-major) ;; + *) echo "Keyword not detected. Doing nothing" ;; +esac +if [ "$GIT_TAG" != "none" ]; then + echo "Assigning new tag: $GIT_TAG" + git tag "$GIT_TAG" -a -m "Automatic tag generation for travis build no. $TRAVIS_BUILD_NUMBER" + git push "https://${GH_TOKEN}:@${GIT_URL}" --tags || exit 0 +fi + +# Generate CHANGELOG.md +git checkout master +git pull +docker run -it --rm -v "$(pwd)":/usr/local/src/your-app ferrarimarco/github-changelog-generator \ + -u "${ORGANIZATION}" -p "${PROJECT}" --token "${GH_TOKEN}" \ + --release-url "${GALAXY_URL}" \ + --unreleased-label "**Next release**" --no-compare-link + +git add CHANGELOG.md +git commit -m '[ci skip] Automatic changelog update' + +git push "https://${GH_TOKEN}:@${GIT_URL}" || exit 0 + +# Sync changelog to github releases +if [ "$GIT_TAG" != "none" ]; then + docker run -e CHANDLER_GITHUB_API_TOKEN="${GH_TOKEN}" -v "$(pwd)":/chandler -ti whizark/chandler push "${GIT_TAG}" +fi From 2e09ff490db2aff782f2eb7c0507074df16f53e2 Mon Sep 17 00:00:00 2001 From: paulfantom Date: Mon, 25 Jun 2018 13:39:34 +0200 Subject: [PATCH 2/4] add auto-releaser to travis; add changelog --- .travis.yml | 11 +++++++++++ CHANGELOG.md | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 CHANGELOG.md diff --git a/.travis.yml b/.travis.yml index 253c237..983f7a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,5 +24,16 @@ install: script: - tox +# Update Changelog and create a release (only from master branch) +deploy: + provider: script + skip_cleanup: true + script: .travis/releaser.sh + on: + branch: master +branches: + only: + - master + notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..451c172 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,17 @@ +# Change Log + +## [**Next release**](https://galaxy.ansible.com/atosatto/minio) + +**Merged pull requests:** + +- major code cleanup [\#8](https://github.com/atosatto/ansible-minio/pull/8) ([paulfantom](https://github.com/paulfantom)) +- Run travis tests against 3 different ansible versions [\#7](https://github.com/atosatto/ansible-minio/pull/7) ([paulfantom](https://github.com/paulfantom)) +- Add a simple MAINTAINERS file [\#6](https://github.com/atosatto/ansible-minio/pull/6) ([atosatto](https://github.com/atosatto)) +- Rename client/server install flags. [\#5](https://github.com/atosatto/ansible-minio/pull/5) ([SuperQ](https://github.com/SuperQ)) +- Create data directories [\#4](https://github.com/atosatto/ansible-minio/pull/4) ([SuperQ](https://github.com/SuperQ)) + +## [v1.0.1](https://galaxy.ansible.com/atosatto/minio) (2017-01-03) +## [v1.0.0](https://galaxy.ansible.com/atosatto/minio) (2017-01-02) + + +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file From d8d97fc55ffde100de0e501be15cc13af765925b Mon Sep 17 00:00:00 2001 From: paulfantom Date: Mon, 25 Jun 2018 13:41:27 +0200 Subject: [PATCH 3/4] do not use cloudalchemybot --- .travis/releaser.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis/releaser.sh b/.travis/releaser.sh index 0c04ce8..c86c027 100755 --- a/.travis/releaser.sh +++ b/.travis/releaser.sh @@ -25,8 +25,8 @@ [[ $(git tag --points-at) ]] && exit 0 # Some basic variables -GIT_MAIL="cloudalchemybot@gmail.com" -GIT_USER="cloudalchemybot" +GIT_MAIL="andrea.tosy@gmail.com" +GIT_USER="atosatto" ORGANIZATION=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $1}') PROJECT=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $2}') GALAXY_URL="https://galaxy.ansible.com/${ORGANIZATION}/${PROJECT#ansible-}" From 9bcaad8ad805f05ea25dc971a2bc1407137a3670 Mon Sep 17 00:00:00 2001 From: paulfantom Date: Mon, 25 Jun 2018 13:43:22 +0200 Subject: [PATCH 4/4] add git-semver to travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 983f7a4..b0ada53 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ env: # Install tox install: - - pip install tox-travis + - pip install tox-travis git-semver # Execute tests script: