|
1 |
| -# .github/workflows/publish.yml |
| 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 |
| 3 | + |
| 4 | +name: Node.js CI |
| 5 | + |
2 | 6 | on:
|
3 | 7 | push:
|
4 |
| - branches: [ main ] |
5 |
| - paths: |
6 |
| - - 'package.json' |
| 8 | + branches: [ "main" ] |
| 9 | + pull_request: |
| 10 | + branches: [ "main" ] |
7 | 11 |
|
8 | 12 | jobs:
|
| 13 | + build: |
| 14 | + |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + node-version: [18.x] |
| 20 | + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ |
| 21 | + |
| 22 | + 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 | + - name: Install dependencies |
| 30 | + run: | |
| 31 | + if [ -e yarn.lock ]; then |
| 32 | + yarn install --frozen-lockfile |
| 33 | + elif [ -e package-lock.json ]; then |
| 34 | + npm ci |
| 35 | + else |
| 36 | + npm i |
| 37 | + fi |
| 38 | + - run: npm run build --if-present |
| 39 | + #- run: npm test |
| 40 | + |
9 | 41 | publish:
|
10 | 42 | runs-on: ubuntu-latest
|
| 43 | + if: ${{ github.ref == 'refs/heads/main' }} |
| 44 | + needs: [build] |
11 | 45 | steps:
|
12 |
| - - uses: actions/checkout@v1 |
13 |
| - - uses: actions/setup-node@v1 |
14 |
| - with: |
15 |
| - node-version: 14 |
16 |
| - - run: npm install |
17 |
| - - uses: JS-DevTools/npm-publish@v1 |
18 |
| - with: |
19 |
| - token: ${{ secrets.NPM_TOKEN }} |
| 46 | + - uses: actions/checkout@v3 |
| 47 | + - name: Use Node.js ${{ matrix.node-version }} |
| 48 | + uses: actions/setup-node@v3 |
| 49 | + with: |
| 50 | + node-version: ${{ matrix.node-version }} |
| 51 | + cache: 'npm' |
| 52 | + - run: | |
| 53 | + if [ -e yarn.lock ]; then |
| 54 | + yarn install --frozen-lockfile |
| 55 | + elif [ -e package-lock.json ]; then |
| 56 | + npm ci |
| 57 | + else |
| 58 | + npm i |
| 59 | + fi |
| 60 | + - run: npm run semantic-release |
| 61 | + env: |
| 62 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 63 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + |
0 commit comments