Skip to content
Snippets Groups Projects
Unverified Commit ef454787 authored by Paweł Krupa's avatar Paweł Krupa Committed by GitHub
Browse files

Merge pull request #191 from cloudalchemy/superq/circle_release

parents 0d349aa8 6a00190a
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,15 @@ executors:
- image: cimg/python:3.9
jobs:
lint:
executor: python
steps:
- checkout
- run: pip install ansible-lint yamllint flake8
- run: ansible-lint
- run: yamllint .
- run: flake8
test:
executor: python
parameters:
......@@ -32,18 +41,90 @@ jobs:
else
echo 'Not running latest on PR'
fi
release:
executor: python
environment:
GIT_MAIL: cloudalchemybot@gmail.com
GIT_USER: cloudalchemybot
GIT_COMMIT_DESC: git log --format=%B -n 1 ${CIRCLE_SHA1}
steps:
- checkout
- setup_remote_docker
- run: pip install git-semver
- run: git config --global user.email "${GIT_MAIL}"
- run: git config --global user.name "${GIT_USER}"
- run: |
GIT_TAG=none
echo "Last commit message: ${GIT_COMMIT_DESC}"
case "${GIT_COMMIT_DESC}" in
*"[patch]"*|*"[fix]"*|*"[bugfix]"* ) 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" && circleci-agent step halt ;;
esac
echo "GIT_TAG=${GIT_TAG}" >> $BASH_ENV
- run: |
docker run -it --rm \
-v "${CIRCLE_WORKING_DIRECTORY}:/role" \
-w "/role" \
ferrarimarco/github-changelog-generator:1.15.2 \
--user "${CIRCLE_PROJECT_USERNAME}" \
--project "${CIRCLE_PROJECT_REPONAME}" \
--token "${GH_TOKEN}" \
--release-url "https://galaxy.ansible.com/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME#ansible-}" \
--unreleased-label "**Next release**" --no-compare-link \
--future-release "${GIT_TAG}"
- run: git add CHANGELOG.md
- run: git commit -m "[ci skip] Automatic changelog update"
- run: git push "https://${GH_TOKEN}:@${GIT_URL}" || circleci-agent step halt
- run: |
ghr \
-t ${GH_TOKEN} \
-u ${CIRCLE_PROJECT_USERNAME} \
-r ${CIRCLE_PROJECT_REPONAME} \
-n ${GIT_TAG} \
-b "$(sed -n -e '/## \[0.22.0\]/,/## \[/ p' CHANGELOG.md | sed -e '$ d')" \
${GIT_TAG}
galaxy:
executor: python
steps:
- checkout
- run: pip install ansible
- run: ansible-galaxy role import --token "${GALAXY_TOKEN}" "${CIRCLE_PROJECT_USERNAME}" "${CIRCLE_PROJECT_REPONAME}"
workflows:
version: 2
molecule:
jobs:
- lint:
filters:
tags:
only: /.*/
- test:
matrix:
parameters:
ansible:
- "2.9"
- "2.10"
ansible:
- "2.9"
- "2.10"
filters:
tags:
only: /.*/
- release:
context: release
requires:
- lint
- test
filters:
branches:
only: master
tags:
ignore: /.*/
- galaxy:
context: galaxy
requires:
- lint
- test
- release
filters:
branches:
only: master
---
_extends: auto-maintenance
---
os: linux
dist: xenial
language: python
python:
- 3.7
cache: pip
services:
- docker
env:
- ANSIBLE=2.7
- ANSIBLE=2.8
- ANSIBLE=2.9
install:
- pip3 install tox-travis git-semver
script:
- ./.travis/test.sh
deploy:
provider: script
cleanup: true
script: .travis/releaser.sh
on:
branch: master
branches:
only:
- master
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
#!/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]"*|*"[bugfix]"* ) 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:1.14.3 \
-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
#!/bin/bash
set -euo pipefail
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
tox -- molecule test --all --destroy always
else
tox -- molecule test -s default --destroy always
if [ -d "./molecule/alternative" ]; then
tox -- molecule test -s alternative --destroy never
fi
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment