Skip to content

Commit be67144

Browse files
committed
chore(ci): port over Github Actions CI to v2 version
1 parent b71bfc9 commit be67144

File tree

3 files changed

+124
-57
lines changed

3 files changed

+124
-57
lines changed

.github/workflows/publish.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: NPM Package Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- next
8+
- alpha
9+
- v2
10+
11+
jobs:
12+
publish-npm:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
18+
- name: Check if version has been updated
19+
id: check
20+
uses: EndBug/version-check@v1
21+
22+
- name: Setup Node 10
23+
if: steps.check.outputs.changed == 'true'
24+
uses: actions/setup-node@v1
25+
with:
26+
node-version: 10
27+
registry-url: https://registry.npmjs.org/
28+
29+
# Setup dependency caching
30+
- uses: actions/cache@v1
31+
if: steps.check.outputs.changed == 'true'
32+
with:
33+
path: ~/.npm
34+
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
35+
36+
- name: Install Dependencies
37+
if: steps.check.outputs.changed == 'true'
38+
run: npm ci
39+
40+
- name: Check For Lint
41+
if: steps.check.outputs.changed == 'true'
42+
run: npm run lint
43+
44+
- name: Run Unit Tests + Coverage
45+
if: steps.check.outputs.changed == 'true'
46+
env:
47+
CODE_CLIMATE: ${{ secrets.CODE_CLIMATE }}
48+
run: npm run test:cov
49+
50+
- name: Publish
51+
if: steps.check.outputs.changed == 'true'
52+
env:
53+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
54+
GITHUB_REF: ${{ github.ref }}
55+
run: |
56+
gitBranch=${GITHUB_REF##*/}
57+
publishFlag=$(if [ "$GITHUB_REF" != 'refs/heads/master' ]; then eval echo '--tag $gitBranch'; else echo ''; fi;)
58+
echo "::set-env name=PACKAGE_VERSION::$(cat package.json | jq -r '.version')"
59+
npm publish $publishFlag
60+
61+
- name: Upload Coverage
62+
if: steps.check.outputs.changed == 'true'
63+
env:
64+
CODE_COV: ${{ secrets.CODE_COV }}
65+
# Upload to Code Cover. Curl used in place of codecov/codecov-action
66+
# due to long build time. See https://github.com/codecov/codecov-action/issues/21
67+
run: curl -s https://codecov.io/bash | bash -s -- -t $CODE_COV
68+
69+
- name: Create Release
70+
if: github.ref == 'refs/heads/master' && steps.check.outputs.changed == 'true'
71+
id: create_release
72+
uses: actions/create-release@latest
73+
env:
74+
GITHUB_TOKEN: ${{ github.token }}
75+
with:
76+
tag_name: v${{ env.PACKAGE_VERSION }}
77+
release_name: v${{ env.PACKAGE_VERSION }}
78+
draft: false
79+
prerelease: false

.github/workflows/verify.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Verify
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
build:
7+
name: Build
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
node-version: [10.x, 12.x, 14.x]
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
16+
- name: Use Node.js ${{ matrix.node-version }}
17+
uses: actions/setup-node@v1
18+
with:
19+
node-version: ${{ matrix.node-version }}
20+
21+
# Setup dependency caching
22+
- uses: actions/cache@v1
23+
with:
24+
path: ~/.npm
25+
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
26+
27+
- name: Install Dependencies
28+
run: npm ci
29+
30+
- name: Check For Lint
31+
run: npm run lint
32+
33+
- name: Run Unit Tests + Coverage
34+
run: npm run test:cov
35+
36+
- name: Run Build
37+
run: npm run build
38+
39+
- name: Upload Coverage
40+
if: matrix.node-version == '10.x'
41+
env:
42+
CODE_COV: ${{ secrets.CODE_COV }}
43+
# Upload to codecov.io. Curl used in place of codecov/codecov-action
44+
# due to long build time. See https://github.com/codecov/codecov-action/issues/21
45+
run: curl -s https://codecov.io/bash | bash -s -- -t $CODE_COV

.travis.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)