Skip to content

Commit 055c84d

Browse files
committed
build: add gh actions build
1 parent 6809352 commit 055c84d

File tree

3 files changed

+85
-1
lines changed

3 files changed

+85
-1
lines changed

.github/workflows/commit_gate.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Commit Gate
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+
steps:
15+
- name: checkout code
16+
uses: actions/checkout@v3
17+
18+
- name: Set up Node.js
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: '20' # Or any other version you need
22+
23+
- name: Install dependencies
24+
run: npm ci --prefix src/
25+
26+
- name: Build
27+
run: npm run build --prefix src/
28+
29+
- name: Install test dependencies
30+
run: npm ci --prefix tests/
31+
32+
- name: Run tests
33+
run: npm run test --prefix tests/

.github/workflows/release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Publish npm package
2+
3+
on:
4+
push:
5+
tags: v*
6+
7+
jobs:
8+
build:
9+
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
id-token: write
14+
15+
steps:
16+
- name: Get version from tag
17+
id: get_version
18+
# "refs/tags/v" is 11 characters
19+
run: |
20+
versionNumber=${GITHUB_REF:11}
21+
echo "::set-output name=version_number::$versionNumber"
22+
23+
- name: checkout code
24+
uses: actions/checkout@v3
25+
26+
- name: Set up Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: '20'
30+
registry-url: 'https://registry.npmjs.org'
31+
32+
- name: Create npm package
33+
run: |
34+
cd src
35+
npm version ${{ steps.get_version.outputs.version_number }}
36+
npm ci
37+
npm run build
38+
npm pack
39+
40+
- name: Publish package
41+
run: |
42+
cd src
43+
npm publish --provenance --access public
44+
env:
45+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

src/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
"version": "0.0.1",
44
"type": "module",
55
"description": "Validates relations within one or multiple JSON files, such as key, keyref, uniqueness",
6-
"main": "./built/index.js",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/shuebner/json_keyref.git"
9+
},
10+
"files": [
11+
"built/"
12+
],
713
"bin": {
814
"json-keyref": "./built/index.js"
915
},

0 commit comments

Comments
 (0)