diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 2f11b60..017faf1 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -10,25 +10,73 @@ on: branches: [master] jobs: - build: - runs-on: ubuntu-latest + Test: + runs-on: '${{ matrix.os }}' strategy: matrix: node-version: [10.x, 12.x, 14.x] + os: [ubuntu-latest] steps: - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + - uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} + + - name: Get npm cache directory + id: npm-cache + run: | + echo "::set-output name=dir::$(npm config get cache)" + - uses: actions/cache@v1 + with: + path: ${{ steps.npm-cache.outputs.dir }} + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - run: npm ci - - run: npm run build + - run: npm run lint - run: npm test + - name: Release package if: github.ref == 'refs/heads/master' run: npm run release env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + Release: + runs-on: ubuntu-latest + needs: Test + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 12.x + - run: npm ci + - run: npm run build + - name: Semantic Release + uses: cycjimmy/semantic-release-action@v2 + with: + branches: | + [ + '+([0-9])?(.{+([0-9]),x}).x', + 'master', + 'next', + 'next-major', + { + name: 'beta', + prerelease: true + }, + { + name: 'alpha', + prerelease: true + } + ] + extra_plugins: | + '@semantic-release/changelog' + '@semantic-release/git' + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}