|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + |
| 9 | +env: |
| 10 | + DEFAULT_NODE_VERSION: 14 |
| 11 | + |
| 12 | +jobs: |
| 13 | + tests: |
| 14 | + name: Unit tests |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + node-version: [10.x, 12.x, 14.x, 15.x] |
| 20 | + webpack-version: [default, ^5.0.0] |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout |
| 24 | + uses: actions/checkout@v2 |
| 25 | + |
| 26 | + - name: Setup Node.js ${{ matrix.node-version }} |
| 27 | + uses: actions/setup-node@v2 |
| 28 | + with: |
| 29 | + node-version: ${{ matrix.node-version }} |
| 30 | + |
| 31 | + - name: Cache node_modules |
| 32 | + uses: actions/cache@v2 |
| 33 | + id: cache-nodemodules |
| 34 | + with: |
| 35 | + path: node_modules |
| 36 | + key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }} |
| 37 | + |
| 38 | + - name: Install dependencies |
| 39 | + if: ${{ steps.cache-nodemodules.outputs.cache-hit != 'true' }} |
| 40 | + run: yarn install --frozen-lockfile --non-interactive |
| 41 | + |
| 42 | + - name: Install webpack |
| 43 | + if: ${{ matrix.webpack-version != 'default' && steps.cache-nodemodules.outputs.cache-hit != 'true' }} |
| 44 | + run: yarn add --dev webpack@${{ matrix.webpack-version }} |
| 45 | + |
| 46 | + - name: Unit tests |
| 47 | + run: yarn test --ci |
| 48 | + |
| 49 | + lint: |
| 50 | + name: Lint |
| 51 | + runs-on: ubuntu-latest |
| 52 | + |
| 53 | + steps: |
| 54 | + - name: Checkout |
| 55 | + uses: actions/checkout@v2 |
| 56 | + |
| 57 | + - name: Setup Node.js |
| 58 | + uses: actions/setup-node@v2 |
| 59 | + with: |
| 60 | + node-version: ${{ env.DEFAULT_NODE_VERSION }} |
| 61 | + |
| 62 | + - name: Cache node_modules |
| 63 | + uses: actions/cache@v2 |
| 64 | + id: cache-nodemodules |
| 65 | + with: |
| 66 | + path: node_modules |
| 67 | + key: ${{ runner.os }}-${{ env.DEFAULT_NODE_VERSION }}-nodemodules-${{ hashFiles('**/yarn.lock') }} |
| 68 | + |
| 69 | + - name: Install dependencies |
| 70 | + if: ${{ steps.cache-nodemodules.outputs.cache-hit != 'true' }} |
| 71 | + run: yarn install --frozen-lockfile --non-interactive |
| 72 | + |
| 73 | + - name: Lint |
| 74 | + run: yarn lint |
| 75 | + |
| 76 | + release: |
| 77 | + needs: [tests, lint] |
| 78 | + if: ${{ github.ref == 'refs/heads/main' }} |
| 79 | + name: Release |
| 80 | + runs-on: ubuntu-latest |
| 81 | + |
| 82 | + steps: |
| 83 | + - name: Checkout |
| 84 | + uses: actions/checkout@v2 |
| 85 | + with: |
| 86 | + fetch-depth: 0 |
| 87 | + |
| 88 | + - name: Setup Node.js |
| 89 | + uses: actions/setup-node@v2 |
| 90 | + with: |
| 91 | + node-version: ${{ env.DEFAULT_NODE_VERSION }} |
| 92 | + |
| 93 | + - name: Release |
| 94 | + run: npx semantic-release --branches main |
| 95 | + env: |
| 96 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 97 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments