Skip to content

Commit fd2c950

Browse files
committed
Add a GitHub Actions workflow
1 parent c3ad6e8 commit fd2c950

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Main Workflow
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
release:
8+
types:
9+
- published
10+
11+
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version: 18
20+
21+
- name: Check if package-lock.json is up to date
22+
run: npx --yes package-lock-utd@1.x.x
23+
24+
- name: Install dependencies
25+
run: npm ci
26+
27+
- name: Run the linter
28+
run: npm run lint
29+
30+
build:
31+
needs: lint
32+
runs-on: ubuntu-latest
33+
34+
steps:
35+
- uses: actions/checkout@v3
36+
- uses: actions/setup-node@v3
37+
with:
38+
node-version: 18
39+
40+
- name: Install dependencies
41+
run: npm ci
42+
43+
- name: Build the project
44+
run: npm run lint
45+
46+
test:
47+
needs: build
48+
runs-on: ubuntu-latest
49+
50+
steps:
51+
- uses: actions/checkout@v3
52+
- uses: actions/setup-node@v3
53+
with:
54+
node-version: 18
55+
56+
- name: Install dependencies
57+
run: npm ci
58+
59+
- name: Run the tests
60+
run: npm run test
61+
62+
publish:
63+
if: github.event_name == 'release'
64+
needs: test
65+
66+
runs-on: ubuntu-latest
67+
68+
steps:
69+
- uses: actions/checkout@v3
70+
- uses: actions/setup-node@v3
71+
with:
72+
node-version: 18
73+
# For some reason, it is necessary to explicitly set a registry URL so that authentication works properly.
74+
registry-url: 'https://registry.npmjs.org'
75+
76+
- name: Install dependencies
77+
run: npm ci
78+
79+
- name: Publish the package
80+
run: npm publish
81+
env:
82+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)