|
1 |
| -# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node |
2 |
| -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs |
| 1 | +name: Node.js CI/CD |
3 | 2 |
|
4 |
| -name: Node.js CI |
5 |
| - |
6 |
| -on: |
7 |
| - push: |
8 |
| - branches: [ "master" ] |
9 |
| - pull_request: |
10 |
| - branches: [ "master" ] |
| 3 | +on: [push, pull_request] |
11 | 4 |
|
12 | 5 | jobs:
|
13 |
| - build: |
14 |
| - |
| 6 | + test: |
| 7 | + name: Test |
15 | 8 | runs-on: ubuntu-latest
|
16 |
| - |
17 | 9 | strategy:
|
18 | 10 | matrix:
|
19 |
| - node-version: [14.x, 16.x, 18.x] |
20 |
| - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ |
| 11 | + node-version: [16, 18] |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v3 |
| 16 | + |
| 17 | + - name: Set up Node.js |
| 18 | + uses: actions/setup-node@v3 |
| 19 | + with: |
| 20 | + node-version: ${{ matrix.node-version }} |
| 21 | + |
| 22 | + - name: Cache npm |
| 23 | + uses: actions/cache@v3 |
| 24 | + with: |
| 25 | + path: ~/.npm |
| 26 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 27 | + restore-keys: | |
| 28 | + ${{ runner.os }}-build-${{ env.cache-name }}- |
| 29 | + ${{ runner.os }}-build- |
| 30 | + ${{ runner.os }}- |
| 31 | +
|
| 32 | + - name: Install dependencies |
| 33 | + run: npm ci |
| 34 | + |
| 35 | + - name: ESLint |
| 36 | + run: npx eslint . |
| 37 | + |
| 38 | + release: |
| 39 | + if: github.ref == 'refs/heads/master' |
| 40 | + name: create a version file |
| 41 | + runs-on: ubuntu-latest |
21 | 42 |
|
22 | 43 | steps:
|
23 |
| - - uses: actions/checkout@v3 |
24 |
| - - name: Use Node.js ${{ matrix.node-version }} |
25 |
| - uses: actions/setup-node@v3 |
26 |
| - with: |
27 |
| - node-version: ${{ matrix.node-version }} |
28 |
| - cache: 'npm' |
29 |
| - - run: npm ci |
30 |
| - - run: npm run build --if-present |
31 |
| - - run: npm test |
| 44 | + - name: Checkout code |
| 45 | + uses: actions/checkout@v3 |
| 46 | + |
| 47 | + - name: Set up Node.js |
| 48 | + uses: actions/setup-node@v3 |
| 49 | + with: |
| 50 | + node-version: 18 |
| 51 | + - uses: actions/cache@v3 |
| 52 | + with: |
| 53 | + path: ~/.npm |
| 54 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 55 | + restore-keys: | |
| 56 | + ${{ runner.os }}-build-${{ env.cache-name }}- |
| 57 | + ${{ runner.os }}-build- |
| 58 | + ${{ runner.os }}- |
| 59 | +
|
| 60 | + - name: Install dependencies |
| 61 | + run: npm ci |
| 62 | + |
| 63 | + - name: Semantic Release |
| 64 | + run: npx semantic-release |
| 65 | + env: |
| 66 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments