|
| 1 | +name: Lint, Test, Build and optionally Publish |
| 2 | + |
| 3 | +on: |
| 4 | + # push only for branches (ignore tags) |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - '**' |
| 8 | + tags-ignore: |
| 9 | + - '**' |
| 10 | + # pull request only for branches (ignore tags) |
| 11 | + pull_request: |
| 12 | + branches: |
| 13 | + - '**' |
| 14 | + tags-ignore: |
| 15 | + - '**' |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v2.2.0 |
| 22 | + - name: Install Node v12 |
| 23 | + uses: actions/setup-node@v2-beta |
| 24 | + with: |
| 25 | + node-version: 12 |
| 26 | + - uses: actions/cache@v2 |
| 27 | + with: |
| 28 | + path: ~/.npm |
| 29 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 30 | + restore-keys: | |
| 31 | + ${{ runner.os }}-node- |
| 32 | + - name: install |
| 33 | + run: npm ci |
| 34 | + - name: lint, test, and build |
| 35 | + run: | |
| 36 | + npm run lint:ci |
| 37 | + npm run test:ci |
| 38 | + npm run build |
| 39 | + env: |
| 40 | + CI: true |
| 41 | + # report coverage only for non PR |
| 42 | + - name: coveralls |
| 43 | + if: ${{ startsWith(github.ref, 'refs/pull/') == false }} |
| 44 | + uses: coverallsapp/github-action@master |
| 45 | + with: |
| 46 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + |
| 48 | + # publish to latest if on master branch |
| 49 | + - name: release master |
| 50 | + if: ${{ github.ref == 'master' }} |
| 51 | + run: | |
| 52 | + npm run docs:build |
| 53 | + npx semantic-release |
| 54 | + npm run docs:deploy |
| 55 | + env: |
| 56 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 58 | + |
| 59 | + # publish pre-release if non master branch and allowed by .releaserc.yml configuration (only for non-PR branches) |
| 60 | + - name: release non-master version |
| 61 | + if: ${{ github.ref != 'master' && startsWith(github.ref, 'refs/pull/') == false }} |
| 62 | + run: npx semantic-release |
| 63 | + env: |
| 64 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments