Skip to content

Commit

Permalink
build: add gh actions build
Browse files Browse the repository at this point in the history
  • Loading branch information
shuebner committed Nov 8, 2024
1 parent 6809352 commit 055c84d
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 1 deletion.
33 changes: 33 additions & 0 deletions .github/workflows/commit_gate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Commit Gate

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20' # Or any other version you need

- name: Install dependencies
run: npm ci --prefix src/

- name: Build
run: npm run build --prefix src/

- name: Install test dependencies
run: npm ci --prefix tests/

- name: Run tests
run: npm run test --prefix tests/
45 changes: 45 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Publish npm package

on:
push:
tags: v*

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
id-token: write

steps:
- name: Get version from tag
id: get_version
# "refs/tags/v" is 11 characters
run: |
versionNumber=${GITHUB_REF:11}
echo "::set-output name=version_number::$versionNumber"
- name: checkout code
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'

- name: Create npm package
run: |
cd src
npm version ${{ steps.get_version.outputs.version_number }}
npm ci
npm run build
npm pack
- name: Publish package
run: |
cd src
npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8 changes: 7 additions & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
"version": "0.0.1",
"type": "module",
"description": "Validates relations within one or multiple JSON files, such as key, keyref, uniqueness",
"main": "./built/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/shuebner/json_keyref.git"
},
"files": [
"built/"
],
"bin": {
"json-keyref": "./built/index.js"
},
Expand Down

0 comments on commit 055c84d

Please sign in to comment.