    version: 2.1
    executors:
      docker-publisher:
        environment:
          IMAGE_NAME: opengisch/qfield-sdk
        docker:
          - image: circleci/buildpack-deps:stretch
    jobs:
      build:
        executor: docker-publisher
        steps:
          - checkout
          - setup_remote_docker
          - run:
              name: Build Docker image
              command: |
                docker build -t $IMAGE_NAME:$CIRCLE_TAG .
          - run:
              name: Archive Docker image
              command: docker save -o image.tar $IMAGE_NAME
          - persist_to_workspace:
              root: .
              paths:
                - ./image.tar
      publish-latest:
        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:$CIRCLE_TAG
                docker push $IMAGE_NAME:latest
    workflows:
      version: 2
      build-master:
        jobs:
          - build:
              filters:
                branches:
                  only: circleci
          - publish-latest:
              requires:
                - build
              filters:
                branches:
                  ignore: /.*/

    version: 2.1
    executors:
      docker-publisher:
        environment:
          IMAGE_NAME: opengisch/qfield-sdk
        docker:
          - image: circleci/buildpack-deps:stretch
    jobs:
      build:
        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-latest:
        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
                docker tag $IMAGE_NAME:latest $IMAGE_NAME:$CIRCLE_TAG
                docker push $IMAGE_NAME:$CIRCLE_TAG
    workflows:
      version: 2
      build:
        jobs:
          - build:
              filters:
                branches:
                  only: circleci
          - publish-latest:
              requires:
                - build
              filters:
                branches:
                  ignore: /.*/

Fix docker tag for non git tag builds
Fix docker tag for non git tag builds
