|
| 1 | +aliases: |
| 2 | + - &node_executor |
| 3 | + executor: |
| 4 | + name: node/node |
| 5 | + node-version: "10" |
| 6 | + |
| 7 | + - &release_filter |
| 8 | + branches: |
| 9 | + only: |
| 10 | + - master |
| 11 | + |
| 12 | + - &pull_request_filter |
| 13 | + branches: |
| 14 | + ignore: |
| 15 | + - master |
| 16 | + |
1 | 17 | version: 2.1
|
2 | 18 |
|
3 | 19 | orbs:
|
4 | 20 | ci: bigcommerce/internal@volatile
|
5 | 21 | node: bigcommerce/internal-node@volatile
|
| 22 | + checkout-js: |
| 23 | + commands: |
| 24 | + install_dependencies: |
| 25 | + steps: |
| 26 | + - restore_cache: |
| 27 | + keys: |
| 28 | + - checkout-js |
| 29 | + - run: |
| 30 | + name: "Install NPM dependencies" |
| 31 | + command: npm ci |
| 32 | + - save_cache: |
| 33 | + key: checkout-js |
| 34 | + paths: |
| 35 | + - ~/.npm |
6 | 36 |
|
7 | 37 | jobs:
|
| 38 | + test: |
| 39 | + <<: *node_executor |
| 40 | + steps: |
| 41 | + - ci/pre-setup |
| 42 | + - checkout-js/install_dependencies |
| 43 | + - run: |
| 44 | + name: "Run unit tests" |
| 45 | + command: npm run test -- --coverage --runInBand |
| 46 | + - store_artifacts: |
| 47 | + path: coverage |
| 48 | + destination: coverage |
| 49 | + |
8 | 50 | build:
|
9 |
| - executor: |
10 |
| - name: node/node |
11 |
| - node-version: "10" |
| 51 | + <<: *node_executor |
12 | 52 | steps:
|
13 | 53 | - ci/pre-setup
|
14 |
| - - restore_cache: |
15 |
| - keys: |
16 |
| - - checkout-js |
17 |
| - - run: npm ci |
18 |
| - - save_cache: |
19 |
| - key: checkout-js |
| 54 | + - checkout-js/install_dependencies |
| 55 | + - run: |
| 56 | + name: "Test build" |
| 57 | + command: npm run build |
| 58 | + - persist_to_workspace: |
| 59 | + root: . |
20 | 60 | paths:
|
21 |
| - - ~/.npm |
| 61 | + - dist |
| 62 | + |
| 63 | + release: |
| 64 | + <<: *node_executor |
| 65 | + steps: |
| 66 | + - ci/pre-setup |
| 67 | + - checkout-js/install_dependencies |
| 68 | + - run: |
| 69 | + name: "Configure Git user" |
| 70 | + command: | |
| 71 | + git config user.email $GIT_USER_EMAIL |
| 72 | + git config user.name $GIT_USER_NAME |
22 | 73 | - run:
|
23 |
| - name: 'Build' |
24 |
| - command: 'npm run build' |
| 74 | + name: "Remove old release files" |
| 75 | + command: rm -rf dist |
| 76 | + - attach_workspace: |
| 77 | + at: . |
25 | 78 | - run:
|
26 |
| - name: 'Unit Tests' |
27 |
| - command: 'npm run test -- --coverage --runInBand' |
28 |
| - when: always |
| 79 | + name: "Create and tag new release" |
| 80 | + command: npm run release:version |
| 81 | + - run: |
| 82 | + name: "Push commits and tag to GitHub" |
| 83 | + command: | |
| 84 | + git push --follow-tags origin $CIRCLE_BRANCH |
| 85 | + - run: |
| 86 | + name: "Export release version to file" |
| 87 | + command: | |
| 88 | + echo "export RELEASE_VERSION=$(git describe --abbrev=0)" > /tmp/release_version.txt |
| 89 | + echo "export RELEASE_REVISION=$(git rev-parse HEAD)" >> /tmp/release_version.txt |
| 90 | + - persist_to_workspace: |
| 91 | + root: /tmp |
| 92 | + paths: |
| 93 | + - release_version.txt |
| 94 | + |
| 95 | + upload_to_sentry: |
| 96 | + <<: *node_executor |
| 97 | + steps: |
| 98 | + - ci/pre-setup |
| 99 | + - run: |
| 100 | + name: "Install Sentry cli" |
| 101 | + command: curl -sL https://sentry.io/get-cli/ | bash |
| 102 | + - attach_workspace: |
| 103 | + at: /tmp |
| 104 | + - run: |
| 105 | + name: "Upload source maps to Sentry" |
| 106 | + command: | |
| 107 | + source /tmp/release_version.txt |
| 108 | + SENTRY_RELEASE=$SENTRY_PROJECT@$RELEASE_VERSION |
| 109 | + SENTRY_COMMIT=$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME@$RELEASE_REVISION |
| 110 | + sentry-cli releases --project $SENTRY_PROJECT --org $SENTRY_ORG new $SENTRY_RELEASE |
| 111 | + sentry-cli releases --project $SENTRY_PROJECT --org $SENTRY_ORG set-commits $SENTRY_RELEASE --commit $SENTRY_COMMIT |
| 112 | + sentry-cli releases --project $SENTRY_PROJECT --org $SENTRY_ORG files $SENTRY_RELEASE upload-sourcemaps dist |
| 113 | + sentry-cli releases --project $SENTRY_PROJECT --org $SENTRY_ORG finalize $SENTRY_RELEASE |
| 114 | +
|
| 115 | +workflows: |
| 116 | + version: 2 |
| 117 | + |
| 118 | + pull_request: |
| 119 | + jobs: |
| 120 | + - test: |
| 121 | + filters: |
| 122 | + <<: *pull_request_filter |
| 123 | + - build: |
| 124 | + filters: |
| 125 | + <<: *pull_request_filter |
| 126 | + |
| 127 | + release: |
| 128 | + jobs: |
| 129 | + - test: |
| 130 | + filters: |
| 131 | + <<: *release_filter |
| 132 | + - build: |
| 133 | + filters: |
| 134 | + <<: *release_filter |
| 135 | + - approve: |
| 136 | + filters: |
| 137 | + <<: *release_filter |
| 138 | + type: approval |
| 139 | + requires: |
| 140 | + - test |
| 141 | + - build |
| 142 | + - release: |
| 143 | + filters: |
| 144 | + <<: *release_filter |
| 145 | + requires: |
| 146 | + - approve |
| 147 | + - upload_to_sentry: |
| 148 | + filters: |
| 149 | + <<: *release_filter |
| 150 | + requires: |
| 151 | + - approve |
| 152 | + - release |
0 commit comments