Skip to content

Merge pull request #16 from almasen/dev #51

Merge pull request #16 from almasen/dev

Merge pull request #16 from almasen/dev #51

name: Test & publish
# Trigger on push
on:
push:
branches:
- master # master (rerun tests after merging a PR)
jobs:
# build and run tests
build:
runs-on: ubuntu-latest
# setup node, build, run tests and publish if new release
steps:
- name: Checkout GitHub repository
uses: actions/checkout@v2
- name: Set up Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: '14.x'
- name: Install npm packages
working-directory: ./
run: npm ci
- name: Build project
working-directory: ./
run: npm run build
- name: Run Lint
working-directory: ./
run: npm run lint
test:
needs: build
runs-on: ubuntu-latest
steps:
- name: checkout Github repository
uses: actions/checkout@v2
- name: set up Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: '14.x'
- name: npm install
working-directory: ./
run: npm ci
- name: npm test
run: npm test
working-directory: ./
- name: Create test coverage artifact
uses: actions/upload-artifact@v1
with:
name: coverage
path: ./coverage
coverage:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout GitHub repository
uses: actions/checkout@master
- name: Download coverage artifact
uses: actions/download-artifact@v1
with:
name: coverage
- name: Publish test coverage
uses: easingthemes/[email protected]
with:
SOURCE: "coverage"
SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY }}
REMOTE_HOST: ${{ secrets.SSH_HOST }}
REMOTE_USER: ${{ secrets.SSH_USER }}
TARGET: ${{ secrets.COVERAGE_DIR }}
publish:
needs: test
runs-on: ubuntu-latest
steps:
- name: checkout Github repository
uses: actions/checkout@v2
- name: set up Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: '14.x'
- name: Install npm packages
working-directory: ./
run: npm ci
- name: Build project
working-directory: ./
run: npm run build
# Publish to npm only if new version
- name: Publish to npm
id: publishnpm
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
- name: Print version number
run: echo ${{ steps.publishnpm.outputs.version }}
- if: steps.publishnpm.outputs.type != 'none'
name: Generate GitHub release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GH_RELEASE_TOKEN }}"
automatic_release_tag: "v${{ steps.publishnpm.outputs.version }}"
prerelease: false
files: |
CHANGELOG.md
LICENSE
README.md
lib/**/*
package.json