.github/workflows/publish.yml
name: publish
# Trigger the publish on tag pushes
# You can also use
# release:
# types: [published]
# But this requires you to manual make a new release from Github
on:
push:
tags:
- v*.*.*
jobs:
# Run ESLint over the code base
lint:
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 10
- name: Install Yarn
run: npm i -g yarn
- name: Install Packages
run: yarn install
- name: Run Linter
run: yarn run lint:ci
# Run all of the unit tests
test:
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 10
- name: Install Yarn
run: npm i -g yarn
- name: Install Packages
run: yarn install
- name: Run Unit Tests
run: yarn run coverage
- name: Upload coverage to CodeClimate
run: |
export GIT_BRANCH="${GITHUB_REF/refs\/heads\//}"
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter format-coverage -t lcov coverage/lcov.info
./cc-test-reporter upload-coverage
env:
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
# If `lint` and `test` pass, publish to Github Pkg Reg
publish-gpr:
needs: [test, lint]
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 10
registry-url: https://npm.pkg.github.com/
scope: '@belsrc'
- name: Install Yarn
run: npm i -g yarn
- name: Install Packages
run: yarn install
- name: Run Build
run: yarn run build
- name: Publish Package @ Github
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
# If `build` passes, publish to NPM Pkg Reg
publish-npm:
needs: [test, lint]
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 10
registry-url: https://registry.npmjs.org/
scope: '@belsrc'
- name: Install Yarn
run: npm i -g yarn
- name: Install Packages
run: yarn install
- name: Run Build
run: yarn run build
- name: Publish Package @ NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Create Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}