version: 2.1 executors: docker-publisher: environment: IMAGE_NAME: bukuserver/bukuserver docker: - image: circleci/buildpack-deps:stretch test-template: &test-template working_directory: ~/Buku environment: CI_FORCE_TEST: 1 steps: - run: command: | apt update && apt install -y --no-install-recommends git pip install --upgrade setuptools flake8 pylint - checkout - run: command: | pip install -e .[tests] pip install -r requirements.txt python3 -m flake8 echo buku | xargs pylint --rcfile tests/.pylintrc find . -iname "*.py" ! -path "./api/*" | xargs pylint --rcfile tests/.pylintrc python3 -m pytest ./tests/test_*.py --cov buku -vv --durations=0 jobs: py35: docker: - image: python:3.5-slim <<: *test-template py36: docker: - image: python:3.6-slim <<: *test-template py37: docker: - image: python:3.7-slim <<: *test-template py38: docker: - image: python:3.8-slim <<: *test-template package-and-publish: machine: true working_directory: ~/Buku steps: - checkout - run: name: "package with packagecore" command: | # Use latest installed python3 from pyenv export PYENV_VERSION="$(pyenv versions | grep -Po '\b3\.\d+\.\d+' | tail -1)" pip install packagecore packagecore -o ./dist/ ${CIRCLE_TAG#v} - run: name: "publish to GitHub" command: | go get github.com/tcnksm/ghr ghr -t ${GITHUB_API_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -replace ${CIRCLE_TAG} ./dist/ build-docker-image: executor: docker-publisher steps: - checkout - setup_remote_docker - run: name: Build Docker image command: docker build -t $IMAGE_NAME:latest . - run: name: Archive Docker image command: docker save -o image.tar $IMAGE_NAME - persist_to_workspace: root: . paths: - ./image.tar publish-on-docker-hub: executor: docker-publisher steps: - attach_workspace: at: /tmp/workspace - setup_remote_docker - run: name: Load archived Docker image command: docker load -i /tmp/workspace/image.tar - run: name: Publish Docker Image to Docker Hub command: | echo "${DOCKERHUB_PASS}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin docker push ${IMAGE_NAME}:latest workflows: version: 2.1 test: jobs: &all-tests - py35 - py36 - py37 - py38 nightly: triggers: - schedule: cron: "0 0 * * 6" filters: branches: only: - master jobs: *all-tests publish-github-release: jobs: - package-and-publish: filters: tags: only: /^v.*/ branches: ignore: /.*/ publish-docker-image: jobs: - build-docker-image: filters: tags: only: /^v.*/ branches: ignore: /.*/ - publish-on-docker-hub: requires: - build-docker-image filters: tags: only: /^v.*/ branches: ignore: /.*/