|
| 1 | +version: 2.1 |
| 2 | + |
| 3 | +orbs: |
| 4 | + python: circleci/python@1 |
| 5 | + go: circleci/go@1 |
| 6 | + gcp-cli: circleci/gcp-cli@1 |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + executor: |
| 11 | + name: python/default |
| 12 | + steps: |
| 13 | + - attach_workspace: |
| 14 | + at: ~/ |
| 15 | + - checkout |
| 16 | + - run: pip install mkdocs |
| 17 | + - run: |
| 18 | + name: Building package |
| 19 | + command: make build |
| 20 | + - gcp-cli/install |
| 21 | + - gcp-cli/initialize |
| 22 | + - run: |
| 23 | + name: Building docker image |
| 24 | + command: make cloudbuild-test |
| 25 | + - persist_to_workspace: |
| 26 | + root: ~/ |
| 27 | + paths: |
| 28 | + - project |
| 29 | + |
| 30 | + publish-image: |
| 31 | + executor: |
| 32 | + name: gcp-cli/google |
| 33 | + steps: |
| 34 | + - attach_workspace: |
| 35 | + at: ~/ |
| 36 | + - gcp-cli/initialize |
| 37 | + - run: |
| 38 | + name: Publishing docker image |
| 39 | + command: IMAGE_SHA=${CIRCLE_SHA1} IMAGE_TAG=${CIRCLE_TAG:-latest} make cloudbuild |
| 40 | + |
| 41 | + release: |
| 42 | + executor: |
| 43 | + name: go/default |
| 44 | + tag: '1.15' |
| 45 | + steps: |
| 46 | + - attach_workspace: |
| 47 | + at: ~/ |
| 48 | + - run: |
| 49 | + name: Building release package |
| 50 | + command: make release |
| 51 | + environment: |
| 52 | + DIST_DIR: /tmp/dist |
| 53 | + - run: |
| 54 | + name: Installing github-release tool |
| 55 | + command: go get github.com/meterup/github-release |
| 56 | + - run: |
| 57 | + name: Creating github release |
| 58 | + command: | |
| 59 | + PRE_RELEASE=${CIRCLE_TAG/${CIRCLE_TAG%-rc[0-9]*}/} |
| 60 | + github-release delete -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -t ${CIRCLE_TAG} 2>/dev/null ||: |
| 61 | + ./scripts/release-notes.sh ${CIRCLE_TAG} | github-release release ${PRE_RELEASE:+-p} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -t ${CIRCLE_TAG} -d - |
| 62 | + for f in $(find /tmp/dist -type f); do github-release upload -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -t ${CIRCLE_TAG} -n $(basename ${f}) -f ${f} ; done |
| 63 | +
|
| 64 | + deploy: |
| 65 | + description: Patches target cluster configuration |
| 66 | + executor: |
| 67 | + name: go/default |
| 68 | + tag: '1.15' |
| 69 | + parameters: |
| 70 | + cluster: |
| 71 | + type: string |
| 72 | + committer_name: |
| 73 | + type: string |
| 74 | + default: TriggerMesh Bot |
| 75 | + committer_email: |
| 76 | + type: string |
| 77 | + |
| 78 | + steps: |
| 79 | + - attach_workspace: |
| 80 | + at: ~/ |
| 81 | + - add_ssh_keys |
| 82 | + - run: ssh-keyscan github.com >> ~/.ssh/known_hosts |
| 83 | + - run: |
| 84 | + name: Configuring git |
| 85 | + command: | |
| 86 | + git config --global user.name '<< parameters.committer_name >>' |
| 87 | + git config --global user.email '<< parameters.committer_email >>' |
| 88 | + - run: |
| 89 | + name: Cloning config repository |
| 90 | + command: git clone --single-branch [email protected]:triggermesh/config.git tmconfig |
| 91 | + - run: |
| 92 | + name: Updating overlays/<< parameters.cluster >>/sources manifests |
| 93 | + working_directory: tmconfig/ |
| 94 | + command: | |
| 95 | + sed -i overlays/<< parameters.cluster >>/docs/deployment.yaml -e "s|gcr.io/triggermesh/docs:.*|gcr.io/triggermesh/docs:"${CIRCLE_TAG:-${CIRCLE_SHA1}}"|g" |
| 96 | + git --no-pager diff |
| 97 | + - run: |
| 98 | + name: Committing overlays/<< parameters.cluster >>/docs updates |
| 99 | + working_directory: tmconfig/ |
| 100 | + command: | |
| 101 | + git add overlays |
| 102 | + git commit -m "Update overlays/<< parameters.cluster >>/docs deployment to '${CIRCLE_TAG:-${CIRCLE_SHA1}}'" |
| 103 | + git push origin master |
| 104 | +
|
| 105 | +workflows: |
| 106 | + build-test-and-publish: |
| 107 | + jobs: |
| 108 | + - build: |
| 109 | + context: production |
| 110 | + filters: |
| 111 | + tags: |
| 112 | + only: /^v([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/ |
| 113 | + - publish-image: |
| 114 | + context: production |
| 115 | + requires: |
| 116 | + - build |
| 117 | + filters: |
| 118 | + tags: |
| 119 | + only: /^v([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/ |
| 120 | + branches: |
| 121 | + only: master |
| 122 | + - deploy: |
| 123 | + name: update-production-config |
| 124 | + cluster: prod |
| 125 | + requires: |
| 126 | + - publish-image |
| 127 | + filters: |
| 128 | + tags: |
| 129 | + only: /^v([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/ |
| 130 | + branches: |
| 131 | + ignore: /.*/ |
| 132 | + - release: |
| 133 | + context: production |
| 134 | + requires: |
| 135 | + - publish-image |
| 136 | + filters: |
| 137 | + tags: |
| 138 | + only: /^v([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/ |
| 139 | + branches: |
| 140 | + ignore: /.*/ |
0 commit comments