name: CI on: push: branches: - '**' workflow_dispatch: inputs: release: description: 'Release' required: true default: 'true' new_version: description: 'New version' required: true default: 'one of | major | minor | patch | premajor | preminor | prepatch | prerelease' jobs: ci: runs-on: ubuntu-latest timeout-minutes: 30 steps: - uses: actions/setup-node@v1 with: node-version: 14.x - uses: actions/checkout@v2 - name: Cache dependencies uses: actions/cache@v2 with: # npm cache files are stored in `~/.npm` on Linux/macOS path: ~/.npm key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('**/package-lock.json') }} - run: npm cache verify - run: npm ci - run: npm run lint - run: npm run build - run: npm run test - name: Release if: ${{ github.event.inputs.release == 'true' }} run: | npm version ${{ github.event.inputs.new_version }} --git-tag-version=true npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" npm publish git push origin && git push origin --tags env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }}