Skip to content

Instantly share code, notes, and snippets.

@fkirc
Last active June 27, 2022 10:26
Show Gist options
  • Save fkirc/a3a2c3df0baf4fba37a47ea01959cac6 to your computer and use it in GitHub Desktop.
Save fkirc/a3a2c3df0baf4fba37a47ea01959cac6 to your computer and use it in GitHub Desktop.
npm GitHub Action - Test automatically. Trigger releases manually.
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 }}
@fkirc
Copy link
Author

fkirc commented Sep 17, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment