Skip to content

Commit 274f1eb

Browse files
committed
change way releases work; update license year
1 parent 16310e6 commit 274f1eb

File tree

4 files changed

+73
-18
lines changed

4 files changed

+73
-18
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ script:
1414
deploy:
1515
provider: script
1616
skip_cleanup: true
17-
script: ./.travis/generatetag.sh
17+
script: ./.travis/releaser.sh
1818
on:
1919
branch: master
2020
branches:

.travis/generatetag.sh

-16
This file was deleted.

.travis/releaser.sh

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
#
3+
# Copyright (C) 2018 Pawel Krupa (@paulfantom) - All Rights Reserved
4+
# Permission to copy and modify is granted under the MIT license
5+
#
6+
# Script to automatically do a couple of things:
7+
# - generate a new tag according to semver (https://semver.org/)
8+
# - generate CHANGELOG.md by using https://github.com/skywinder/github-changelog-generator
9+
# - sync CHANGELOG with GitHub releases by using https://github.com/mattbrictson/chandler
10+
#
11+
# Tags are generated by searching for a keyword in last commit message. Keywords are:
12+
# - [patch] or [fix] to bump patch number
13+
# - [minor], [feature] or [feat] to bump minor number
14+
# - [major] or [breaking change] to bump major number
15+
# All keywords MUST be surrounded with square braces.
16+
#
17+
# Script uses git mechanisms for locking, so it can be used in parallel builds
18+
#
19+
# Requirements:
20+
# - GH_TOKEN variable set with GitHub token. Access level: repo.public_repo
21+
# - docker
22+
# - git-semver python package (pip install git-semver)
23+
24+
# Exit when latest commit is tagged
25+
[[ $(git tag --points-at) ]] && exit 0
26+
27+
# Some basic variables
28+
29+
GIT_USER="cloudalchemybot"
30+
ORGANIZATION=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $1}')
31+
PROJECT=$(echo "$TRAVIS_REPO_SLUG" | awk -F '/' '{print $2}')
32+
GALAXY_URL="https://galaxy.ansible.com/${ORGANIZATION}/${PROJECT#ansible-}"
33+
34+
# Git config
35+
git config --global user.email "${GIT_MAIL}"
36+
git config --global user.name "${GIT_USER}"
37+
GIT_URL=$(git config --get remote.origin.url)
38+
GIT_URL=${GIT_URL#*//}
39+
40+
# Generate TAG
41+
GIT_TAG=none
42+
echo "Last commit message: $TRAVIS_COMMIT_MESSAGE"
43+
case "${TRAVIS_COMMIT_MESSAGE}" in
44+
*"[patch]"*|*"[fix]"* ) GIT_TAG=$(git semver --next-patch) ;;
45+
*"[minor]"*|*"[feat]"*|*"[feature]"* ) GIT_TAG=$(git semver --next-minor) ;;
46+
*"[major]"*|*"[breaking change]"* ) GIT_TAG=$(git semver --next-major) ;;
47+
*) echo "Keyword not detected. Doing nothing" ;;
48+
esac
49+
if [ "$GIT_TAG" != "none" ]; then
50+
echo "Assigning new tag: $GIT_TAG"
51+
git tag "$GIT_TAG" -a -m "Automatic tag generation for travis build no. $TRAVIS_BUILD_NUMBER"
52+
git push "https://${GH_TOKEN}:@${GIT_URL}" --tags || exit 0
53+
fi
54+
55+
# Generate CHANGELOG.md
56+
git checkout master
57+
git pull
58+
docker run -it --rm -v "$(pwd)":/usr/local/src/your-app ferrarimarco/github-changelog-generator \
59+
-u "${ORGANIZATION}" -p "${PROJECT}" --token "${GH_TOKEN}" \
60+
--release-url "${GALAXY_URL}" \
61+
--unreleased-label "**Next release**" --no-compare-link
62+
63+
git add CHANGELOG.md
64+
git commit -m '[ci skip] Automatic changelog update'
65+
66+
git push "https://${GH_TOKEN}:@${GIT_URL}" || exit 0
67+
68+
# Sync changelog to github releases
69+
if [ "$GIT_TAG" != "none" ]; then
70+
docker run -e CHANDLER_GITHUB_API_TOKEN="${GH_TOKEN}" -v "$(pwd)":/chandler -ti whizark/chandler push "${GIT_TAG}"
71+
fi

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2017 Pawel Krupa and Roman Demachkovych
3+
Copyright (c) 2017-2018 Pawel Krupa and Roman Demachkovych
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)