Skip to content

Merge pull request #54 from nubiia-dev/development #20

Merge pull request #54 from nubiia-dev/development

Merge pull request #54 from nubiia-dev/development #20

Workflow file for this run

name: Publish
on:
push:
tags:
- 'v*'
jobs:
publish:
name: Validate + Publish to npm
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
scope: '@nubiia'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Typecheck
run: npm run typecheck
- name: Build
run: npm run build
- name: Test with coverage
run: npm run test:coverage
- name: Check coverage threshold (85%)
run: |
COVERAGE=$(cat coverage/coverage-summary.json 2>/dev/null | node -e "
const data = require('fs').readFileSync('/dev/stdin', 'utf8');
const json = JSON.parse(data);
const pct = json.total.lines.pct;
console.log(pct);
" 2>/dev/null || echo "0")
echo "Line coverage: ${COVERAGE}%"
node -e "
const pct = parseFloat('${COVERAGE}');
if (isNaN(pct) || pct < 85) {
console.error('Coverage ' + pct + '% is below 85% threshold');
process.exit(1);
}
console.log('Coverage ' + pct + '% meets 85% threshold');
"
- name: Security audit
run: npm audit --audit-level=high
- name: Publish to npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}