From d08cbd56b37f3236c787e23c6b01bef111f270ab Mon Sep 17 00:00:00 2001 From: Samir Musali Date: Tue, 21 Jan 2020 13:29:51 -0500 Subject: [PATCH] update circleci config for autodeployment --- .circleci/config.yml | 82 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 17 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f895176..63d25a3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,11 @@ -version: 2 +version: 2.1 +tagged_build_filters: &tagged_build_filters + branches: + ignore: /.*/ + tags: + only: /v[0-9]+\.[0-9]+\.[0-9]+/ jobs: - publish: + build: docker: - image: circleci/python:3 steps: @@ -8,27 +13,70 @@ jobs: - run: name: Check Tagged Push command: | - TAG_VERSION=$(git tag -l --sort=-v:refname | head -n 1 | cut -d'-' -f2) PKG_VERSION=$(cat logdna/VERSION) - if [[ "${TAG_VERSION}" != "${PKG_VERSION}" ]]; then + if [[ "${CIRCLE_TAG}" != "v${PKG_VERSION}" ]]; then echo "There is mismatch:" - echo " TAG_VERSION: ${TAG_VERSION}" - echo " PKG_VERSION: ${PKG_VERSION}" + echo " TAG_VERSION: ${CIRCLE_TAG}" + echo " PKG_VERSION: v${PKG_VERSION}" exit 1 fi + - run: python setup.py sdist + - persist_to_workspace: + root: . + paths: + - ./dist/logdna-*.tar.gz + release: + docker: + - image: circleci/golang:1.12 + steps: + - attach_workspace: + at: . + - run: go get -u github.com/tcnksm/ghr - run: - name: Publish + name: Create a Release command: | - sudo pip install twine - python setup.py sdist - twine upload dist/*.tar.gz + ghr \ + -n "LogDNA Python Logger ${CIRCLE_TAG}" \ + -t ${GITHUB_TOKEN} \ + -u ${CIRCLE_PROJECT_USERNAME} \ + -r ${CIRCLE_PROJECT_REPONAME} \ + -draft ${CIRCLE_TAG} ${CIRCLE_WORKING_DIRECTORY}/dist + - persist_to_workspace: + root: . + paths: + - ./dist/logdna-*.tar.gz + approve: + machine: true + steps: + - attach_workspace: + at: . + - persist_to_workspace: + root: . + paths: + - ./dist/logdna-*.tar.gz + publish: + docker: + - image: circleci/python:3 + steps: + - attach_workspace: + at: . + - run: sudo pip install twine + - run: twine upload dist/logdna-*.tar.gz workflows: - version: 2 - update_package: + update: jobs: + - build: + filters: *tagged_build_filters + - release: + requires: + - build + filters: *tagged_build_filters + - approve: + type: approval + requires: + - release + filters: *tagged_build_filters - publish: - filters: - tags: - only: /[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?/ - branches: - ignore: /.*/ + requires: + - approve + filters: *tagged_build_filters