Skip to content

Commit

Permalink
Merge pull request #71 from LCMApps/add-github-action-for-npm-releases
Browse files Browse the repository at this point in the history
Add Github action for NPM releses
  • Loading branch information
oleh-poberezhets committed Jan 22, 2020
2 parents 2cfe8b0 + 01e2391 commit 6aaf682
Show file tree
Hide file tree
Showing 4 changed files with 295 additions and 119 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/npm_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: NPM Release

on:
release:
types: [published, edited]

jobs:
check:
name: Check version and tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Get package version
shell: bash
id: package_version
run: |
ver=$(jq .version package.json | sed -e "s/^\"//" -e "s/\"//")
echo "::set-output name=version::$ver"
- name: Compare package version and release tag
if: steps.package_version.outputs.version != github.event.release.tag_name
env:
TAG: "${{ github.event.release.tag_name }}"
PKG_VER: ${{ steps.package_version.outputs.version }}
run: |
echo "Mismatch NPM version $PKG_VER and git tag $TAG"
exit 1
build:
name: Lint and test
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
- run: yarn install --frozen-lock-file
- run: yarn lint
- run: yarn test

publish-npm:
name: Publish to NPM
needs: [check, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: yarn install --frozen-lock-file
- run: yarn publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH}}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
npm-debug.log
.idea
.idea
coverage
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Consul Service Registrator

[![NPM version](https://img.shields.io/npm/v/consul-service-registrator.svg)](https://www.npmjs.com/package/consul-service-registrator)
[![Release Status](https://github.com/LCMApps/consul-service-registrator/workflows/NPM%20Release/badge.svg)](https://github.com/LCMApps/consul-service-registrator/releases)
[![Build Status](https://travis-ci.org/LCMApps/consul-service-registrator.svg?branch=master)](https://travis-ci.org/LCMApps/consul-service-registrator)
[![Coverage Status](https://coveralls.io/repos/github/LCMApps/consul-service-registrator/badge.svg?branch=master)](https://coveralls.io/github/LCMApps/consul-service-registrator?branch=master)

Expand Down
Loading

0 comments on commit 6aaf682

Please sign in to comment.