Skip to content

Commit

Permalink
add gh actions build
Browse files Browse the repository at this point in the history
  • Loading branch information
shuebner committed Oct 20, 2024
1 parent 1fae1a9 commit b69e394
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
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/
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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 pack
- name: Publish package
run: |
cd src
npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.1",
"type": "module",
"description": "Validates relations within one or multiple JSON files, such as key, keyref, uniqueness",
"repository": "https://github.com/shuebner/json_keyref",
"main": "./built/index.js",
"bin": {
"json-keyref": "built/index.js"
Expand Down

0 comments on commit b69e394

Please sign in to comment.