|
2 | 2 | # |
3 | 3 | # Check https://circleci.com/docs/2.0/language-javascript/ for more details |
4 | 4 | # |
5 | | -aliases: |
6 | | - # Workflow filters |
7 | | - - &filter-not-release-or-master |
8 | | - tags: |
9 | | - ignore: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/ |
10 | | - branches: |
11 | | - ignore: |
12 | | - - master |
13 | | - - &filter-only-master |
14 | | - branches: |
15 | | - only: master |
16 | | - |
17 | 5 | version: 2 |
18 | 6 | jobs: |
19 | 7 | build: |
|
27 | 15 | - dependency-cache-{{ checksum "yarn.lock" }} |
28 | 16 | # fallback to using the latest cache if no exact match is found |
29 | 17 | - dependency-cache- |
| 18 | + - run: |
| 19 | + name: Setup Environment Variables |
| 20 | + command: | |
| 21 | + echo "export GIT_SHA1=$(echo ${CIRCLE_SHA1} | cut -c -7)" >> $BASH_ENV |
| 22 | + source $BASH_ENV |
30 | 23 | - run: |
31 | 24 | name: yarn install |
32 | 25 | command: 'yarn install --pure-lockfile --no-progress' |
|
35 | 28 | - node_modules |
36 | 29 | key: dependency-cache-{{ checksum "yarn.lock" }} |
37 | 30 | - run: yarn lint |
38 | | - - run: yarn build |
| 31 | + - run: yarn test |
| 32 | + - run: |
| 33 | + name: Create directories for Artifacts |
| 34 | + command: mkdir -p ~/artifacts/scalyr_plugin/target/ |
| 35 | + - run: |
| 36 | + name: Build artifacts |
| 37 | + command: | |
| 38 | + yarn build |
| 39 | + cp -rf dist/ ~/artifacts/scalyr_plugin/ |
| 40 | + echo Plugin git sha is ${GIT_SHA1} |
| 41 | + cd ~/artifacts/scalyr_plugin/ && tar -czvf scalyr_grafana_plugin_${GIT_SHA1}.tar.gz dist/ && mv scalyr_grafana_plugin_${GIT_SHA1}.tar.gz target/ |
| 42 | + - persist_to_workspace: |
| 43 | + root: ~/artifacts/scalyr_plugin/target/ |
| 44 | + paths: |
| 45 | + - scalyr_grafana_plugin_*.tar.gz |
| 46 | + - store_artifacts: |
| 47 | + path: ~/artifacts/scalyr_plugin/target/ |
| 48 | + destination: scalyr_grafana_plugin |
| 49 | + |
| 50 | + deploy-to-github-releases: |
| 51 | + docker: |
| 52 | + - image: circleci/golang:1.12 |
| 53 | + steps: |
| 54 | + - attach_workspace: |
| 55 | + at: ~/artifacts/scalyr_plugin/ |
| 56 | + - run: |
| 57 | + name: "Publish Release on GitHub" |
| 58 | + command: | |
| 59 | + go get github.com/tcnksm/ghr |
| 60 | + VERSION=${CIRCLE_TAG} |
| 61 | + echo Releasing version $VERSION |
| 62 | + ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} /home/circleci/artifacts/scalyr_plugin/ |
| 63 | +
|
| 64 | +workflows: |
| 65 | + version: 2 |
| 66 | + build-and-deploy: |
| 67 | + jobs: |
| 68 | + - build: |
| 69 | + filters: |
| 70 | + tags: |
| 71 | + only: /.*/ |
39 | 72 |
|
40 | | -# TODO: Ship dist/ folder to github releases and tag them |
| 73 | + - deploy-to-github-releases: |
| 74 | + requires: |
| 75 | + - build |
| 76 | + filters: |
| 77 | + branches: |
| 78 | + ignore: /.*/ |
| 79 | + tags: |
| 80 | + # See https://discuss.circleci.com/t/filter-job-by-tag-not-working-regexp-possibly-unsupported/28484 |
| 81 | + only: /^(\d|[1-9]\d*)\.(\d|[1-9]\d*)\.(\d|[1-9]\d*)(-(0|[1-9A-Za-z-][0-9A-Za-z-]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(\.(0|[1-9A-Za-z-][0-9A-Za-z-]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/ |
0 commit comments