Skip to content

Commit 9d6fd7f

Browse files
authored
Create main.yml
1 parent 52bac91 commit 9d6fd7f

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

.github/workflows/main.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: CI
5+
6+
on:
7+
push:
8+
branches:
9+
- "**"
10+
pull_request:
11+
branches:
12+
- "**"
13+
workflow_dispatch:
14+
15+
jobs:
16+
build:
17+
18+
runs-on: ubuntu-latest
19+
20+
strategy:
21+
matrix:
22+
node-version:
23+
- 12.x
24+
- 14.x
25+
- 16.x
26+
27+
steps:
28+
- uses: actions/checkout@v2
29+
- name: Use Node.js ${{ matrix.node-version }}
30+
uses: actions/setup-node@v1
31+
with:
32+
node-version: ${{ matrix.node-version }}
33+
- run: npm ci
34+
# lint throws erros because of authSession ts-ignore tags
35+
# - run: npm run lint --if-present
36+
- run: npm test
37+
- run: npm run build --if-present
38+
- name: Save build
39+
if: matrix.node-version == '14.x'
40+
uses: actions/upload-artifact@v2
41+
with:
42+
name: build
43+
path: |
44+
.
45+
!node_modules
46+
retention-days: 1
47+
npm-publish-build:
48+
needs: build
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/download-artifact@v2
52+
with:
53+
name: build
54+
- uses: actions/setup-node@v1
55+
with:
56+
node-version: 14.x
57+
- uses: rlespinasse/github-slug-action@v3.x
58+
- name: Append commit hash to package version
59+
run: 'sed -i -E "s/(\"version\": *\"[^\"]+)/\1-${GITHUB_SHA_SHORT}/" package.json'
60+
- name: Disable pre- and post-publish actions
61+
run: 'sed -i -E "s/\"((pre|post)publish)/\"ignore:\1/" package.json'
62+
- uses: JS-DevTools/npm-publish@v1
63+
with:
64+
token: ${{ secrets.NPM_TOKEN }}
65+
tag: ${{ env.GITHUB_REF_SLUG }}

0 commit comments

Comments
 (0)