Last active
June 27, 2022 10:26
-
-
Save fkirc/a3a2c3df0baf4fba37a47ea01959cac6 to your computer and use it in GitHub Desktop.
npm GitHub Action - Test automatically. Trigger releases manually.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <newversion> | 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 }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wget -O - https://gist.githubusercontent.com/fkirc/a3a2c3df0baf4fba37a47ea01959cac6/raw > .github/workflows/ci.yml