|
| 1 | +stages: |
| 2 | + - build |
| 3 | + - deploy |
| 4 | + |
| 5 | +# To cache both npm modules and Cypress binary we use environment variables |
| 6 | +# to point at the folders we can list as paths in "cache" job settings |
| 7 | +variables: |
| 8 | + npm_config_cache: $CI_PROJECT_DIR/.npm |
| 9 | + |
| 10 | +# Shared Settings |
| 11 | +## Cache dependencies across jobs only pulling not uploading (upload to cache |
| 12 | +## happens in build stage) |
| 13 | +cache: |
| 14 | + key: $CI_COMMIT_REF_SLUG |
| 15 | + policy: pull # only pull cache, skip uploading |
| 16 | + paths: |
| 17 | + - .npm |
| 18 | + |
| 19 | +## Install dependencies for React App and Cloud Functions. Installing of |
| 20 | +## Cypress binary is skipped (done in E2E Testing Stage) |
| 21 | +## Script run before all stages unless otherwise overriden |
| 22 | +before_script: |
| 23 | + - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc |
| 24 | + - npm ci |
| 25 | + |
| 26 | +# Build Stage |
| 27 | +## Installs dependencies, builds app, and saves results for later (artifacts). |
| 28 | +Build Node 8: |
| 29 | + stage: build |
| 30 | + image: node:8 |
| 31 | + when: always |
| 32 | + except: |
| 33 | + variables: |
| 34 | + - $CI_COMMIT_MESSAGE =~ /skip-build/ |
| 35 | + # Override cache behavior set above since we want to both pull and push to |
| 36 | + # the cache (no "policy" provided since pull-push is default) |
| 37 | + cache: |
| 38 | + key: $CI_COMMIT_REF_SLUG |
| 39 | + paths: |
| 40 | + - .npm |
| 41 | + artifacts: |
| 42 | + name: $CI_JOB_STAGE-$CI_COMMIT_REF_SLUG |
| 43 | + expire_in: 2 weeks |
| 44 | + when: always |
| 45 | + paths: |
| 46 | + - lib |
| 47 | + - es |
| 48 | + script: |
| 49 | + - npm run lint |
| 50 | + - npm run build |
| 51 | + |
| 52 | +# Build Stage |
| 53 | +## Installs dependencies, builds app, and saves results for later (artifacts). |
| 54 | +Build Node 10: |
| 55 | + stage: build |
| 56 | + image: node:10 |
| 57 | + when: always |
| 58 | + except: |
| 59 | + variables: |
| 60 | + - $CI_COMMIT_MESSAGE =~ /skip-build/ |
| 61 | + # Override cache behavior set above since we want to both pull and push to |
| 62 | + # the cache (no "policy" provided since pull-push is default) |
| 63 | + cache: |
| 64 | + key: $CI_COMMIT_REF_SLUG |
| 65 | + paths: |
| 66 | + - .npm |
| 67 | + artifacts: |
| 68 | + name: $CI_JOB_STAGE-$CI_COMMIT_REF_SLUG |
| 69 | + expire_in: 2 weeks |
| 70 | + when: always |
| 71 | + paths: |
| 72 | + - lib |
| 73 | + - es |
| 74 | + script: |
| 75 | + - npm run lint |
| 76 | + - npm run build |
| 77 | + |
| 78 | +# Deploy Latest Stage |
| 79 | +## Deploy Library to latest tag |
| 80 | +Deploy Latest: |
| 81 | + stage: deploy |
| 82 | + image: node:10 |
| 83 | + when: on_success |
| 84 | + only: |
| 85 | + - master |
| 86 | + except: |
| 87 | + variables: |
| 88 | + - $CI_COMMIT_MESSAGE =~ /skip-deploy/ |
| 89 | + - $CI_COMMIT_MESSAGE =~ /skip-build/ |
| 90 | + dependencies: |
| 91 | + - Build Node 10 |
| 92 | + script: |
| 93 | + - npm publish |
| 94 | + |
| 95 | +# Deploy Next Stage |
| 96 | +## Deploy Library to next tag |
| 97 | +Deploy Next: |
| 98 | + stage: deploy |
| 99 | + image: node:10 |
| 100 | + when: on_success |
| 101 | + only: |
| 102 | + - next |
| 103 | + except: |
| 104 | + variables: |
| 105 | + - $CI_COMMIT_MESSAGE =~ /skip-deploy/ |
| 106 | + - $CI_COMMIT_MESSAGE =~ /skip-build/ |
| 107 | + dependencies: |
| 108 | + - Build Node 10 |
| 109 | + script: |
| 110 | + - npm publish --tag next |
0 commit comments