|
1 | 1 | name: CI |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - branches: |
6 | | - - master |
7 | | - tags-ignore: |
8 | | - - "**" |
9 | | - pull_request: |
10 | | - branches: |
11 | | - - "**" |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + tags-ignore: |
| 8 | + - '**' |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - '**' |
12 | 12 |
|
13 | 13 | jobs: |
14 | | - build: |
15 | | - name: Build |
16 | | - runs-on: ubuntu-latest |
| 14 | + build: |
| 15 | + name: Build |
| 16 | + runs-on: ubuntu-latest |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + node-version: [16.x, 18.x, 20.x] |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + fetch-depth: 0 |
| 24 | + - name: Use Node.js ${{ matrix.node-version }} |
| 25 | + uses: actions/setup-node@v4 |
| 26 | + with: |
| 27 | + node-version: ${{ matrix.node-version }} |
| 28 | + cache: 'npm' |
| 29 | + - run: npm ci |
| 30 | + - if: github.event_name == 'pull_request' |
| 31 | + name: Lint commit messages |
| 32 | + run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose |
| 33 | + - run: npm run format:check |
| 34 | + - run: npm run lint |
| 35 | + - run: npm run build |
| 36 | + - run: npm run coverage |
| 37 | + - if: matrix.node-version == '20.x' |
| 38 | + uses: actions/upload-artifact@v4 |
| 39 | + with: |
| 40 | + name: Code coverage |
| 41 | + path: coverage/ |
| 42 | + - if: matrix.node-version == '20.x' |
| 43 | + run: npm run docs |
| 44 | + - if: matrix.node-version == '20.x' |
| 45 | + uses: actions/upload-artifact@v4 |
| 46 | + with: |
| 47 | + name: Documentation |
| 48 | + path: docs/ |
17 | 49 |
|
18 | | - strategy: |
19 | | - matrix: |
20 | | - node-version: [16.x, 18.x, 20.x] |
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 | | - - run: npm ci |
30 | | - - run: npm run format:check |
31 | | - - run: npm run lint |
32 | | - - run: npm run build |
33 | | - - run: npm run coverage |
34 | | - - if: matrix.node-version == '20.x' |
35 | | - uses: actions/upload-artifact@v3 |
36 | | - with: |
37 | | - name: Code coverage |
38 | | - path: coverage/ |
39 | | - - if: matrix.node-version == '20.x' |
40 | | - run: npm run docs |
41 | | - - if: matrix.node-version == '20.x' |
42 | | - uses: actions/upload-artifact@v3 |
43 | | - with: |
44 | | - name: Documentation |
45 | | - path: docs/ |
46 | | - - name: Deploy Docs |
47 | | - if: github.ref == 'refs/heads/master' && matrix.node-version == '20.x' |
48 | | - uses: peaceiris/actions-gh-pages@v3 |
49 | | - with: |
50 | | - github_token: ${{ secrets.GITHUB_TOKEN }} |
51 | | - publish_dir: ./docs |
| 50 | + publish: |
| 51 | + name: 'Publish' |
| 52 | + needs: build |
| 53 | + runs-on: ubuntu-latest |
| 54 | + environment: npm_publish |
| 55 | + if: github.ref == 'refs/heads/master' |
| 56 | + steps: |
| 57 | + - uses: actions/download-artifact@v4 |
| 58 | + with: |
| 59 | + name: Documentation |
| 60 | + path: docs/ |
| 61 | + - name: Deploy Docs |
| 62 | + uses: peaceiris/actions-gh-pages@v4 |
| 63 | + with: |
| 64 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + publish_dir: ./docs |
| 66 | + - uses: actions/checkout@v4 |
| 67 | + - uses: actions/setup-node@v4 |
| 68 | + with: |
| 69 | + node-version: 20.x |
| 70 | + cache: 'npm' |
| 71 | + - run: npm ci |
| 72 | + - name: Publish new version |
| 73 | + env: |
| 74 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 75 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 76 | + run: npx semantic-release |
0 commit comments