Skip to content

Commit 83a3aaa

Browse files
committed
Added Github actions workflows
1 parent aaa938e commit 83a3aaa

File tree

7 files changed

+87
-26
lines changed

7 files changed

+87
-26
lines changed

.github/workflows/build.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
node-version: [16.x, 18.x, 20.x]
17+
18+
steps:
19+
- uses: actions/checkout@v3
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
- run: npm ci
25+
- run: npm run build --if-present
26+
- run: npm test

.github/workflows/publish-package.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: "Publish package"
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout project
13+
uses: actions/checkout@v3
14+
15+
- name: Setup Node
16+
uses: actions/setup-node@v3
17+
with:
18+
node-version: 18
19+
20+
- name: Install node_modules
21+
run: npm ci
22+
23+
- name: Run tests
24+
run: npm test
25+
26+
publish-gpr:
27+
needs: build
28+
runs-on: ubuntu-latest
29+
permissions:
30+
packages: write
31+
contents: read
32+
steps:
33+
- name: Checkout project
34+
uses: actions/checkout@v3
35+
36+
- name: Setup Node
37+
uses: actions/setup-node@v3
38+
with:
39+
node-version: 18
40+
registry-url: https://npm.pkg.github.com/
41+
42+
- name: Set NPM package version to match tag
43+
env:
44+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
45+
run: |
46+
npm ci
47+
PACKAGE_VERSION=$(echo "${GITHUB_REF_NAME}" | sed "s/^v//g")
48+
echo "NPM Package version: ${PACKAGE_VERSION}"
49+
npm version ${PACKAGE_VERSION} --no-git-tag-version
50+
npm publish

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@garrypas:registry=https://npm.pkg.github.com

gp-validator-1.0.0.tgz

-5.75 KB
Binary file not shown.

package-lock.json

Lines changed: 8 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "gp-validator",
2+
"name": "@garrypas/gp-validator",
33
"version": "1.0.0",
44
"description": "A compact validation library",
55
"main": "./src/index.js",
@@ -22,8 +22,5 @@
2222
"devDependencies": {
2323
"@types/jest": "^29.5.2",
2424
"jest": "^29.5.0"
25-
},
26-
"dependencies": {
27-
"gp-validator": "file:gp-validator-1.0.0.tgz"
2825
}
2926
}

src/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ type Validator = {
1818
}): void;
1919
};
2020

21-
declare module 'gp-validator' {
21+
declare module '@garrypas/gp-validator' {
2222
export const create: () => Validator;
2323
}

0 commit comments

Comments
 (0)