Skip to content

Commit d045b3a

Browse files
committed
ci: add publish step
1 parent 1569e08 commit d045b3a

File tree

2 files changed

+73
-46
lines changed

2 files changed

+73
-46
lines changed

.github/workflows/ci.yaml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# /.github/workflows/ci.yaml
2+
# GitHub actions workflow
3+
4+
name: CI
5+
6+
on: [push, pull_request]
7+
8+
jobs:
9+
lint:
10+
name: Lint
11+
strategy:
12+
matrix:
13+
node-version: [lts/*]
14+
os: [ubuntu-latest]
15+
runs-on: ${{ matrix.os }}
16+
steps:
17+
- name: Checkout the repository
18+
uses: actions/checkout@v3
19+
- name: Use Node ${{ matrix.node-version }}
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
- name: Lint code
24+
run: |
25+
npm ci
26+
npm run lint
27+
test-library:
28+
name: Test (Library)
29+
strategy:
30+
matrix:
31+
node-version: [lts/gallium, lts/*, latest]
32+
os: [ubuntu-latest, windows-latest, macos-latest]
33+
runs-on: ${{ matrix.os }}
34+
steps:
35+
- name: Checkout the repository
36+
uses: actions/checkout@v3
37+
- name: Use Node ${{ matrix.node-version }}
38+
uses: actions/setup-node@v3
39+
with:
40+
node-version: ${{ matrix.node-version }}
41+
- name: Run tests
42+
run: |
43+
npm ci
44+
npm run test:lib
45+
publish:
46+
name: Publish
47+
needs: [lint, test-library]
48+
if: startsWith(github.ref, 'refs/tags/v')
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Checkout the repository
52+
uses: actions/checkout@v3
53+
- uses: actions/setup-node@v3
54+
with:
55+
node-version: lts/*
56+
registry-url: https://registry.npmjs.org/
57+
- name: Install dependencies
58+
run: npm ci
59+
- name: Publish to npm
60+
run: npm publish
61+
env:
62+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
63+
- name: Build package to upload to GitHub releases
64+
run: |
65+
npm pack
66+
mv rratelimit-header-parser-*.tgz ratelimit-header-parser.tgz
67+
- name: Create a Github release
68+
uses: softprops/action-gh-release@v1
69+
with:
70+
files: ratelimit-header-parser.tgz
71+
body:
72+
You can view the changelog
73+
[here](https://github.com/express-rate-limit/ratelimit-header-parser/blob/main/changelog.md).

.github/workflows/ci.yml

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

0 commit comments

Comments
 (0)