Skip to content

Commit

Permalink
ci: add release, commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
stas-nc committed Oct 25, 2024
1 parent e37521b commit 26b0127
Show file tree
Hide file tree
Showing 8 changed files with 23,193 additions and 10,681 deletions.
48 changes: 35 additions & 13 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,52 @@ name: Node.js CI

on:
push:
branches: [ master ]
branches: [master, "**"]
pull_request:
branches: [ master ]
branches: [master]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [18.x, 20.x]
ts-project: [src/tsconfig.json, src/tsconfig-es6.json]

env:
TS_NODE_PROJECT: ${{ matrix.ts-project }}

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm cache clean --force
- run: npm ci
- run: npm run build --if-present
- run: npm test
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm cache clean --force
- run: npm ci
- if: github.event_name == 'pull_request'
name: Lint commit messages
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
- run: npm run build --if-present
- run: npm test
publish:
name: "Publish"
needs: build
runs-on: ubuntu-latest
environment: npm_publish
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"
- run: npm ci
- name: Publish new version
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release --dry-run
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no -- commitlint --edit $1
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
npx lint-staged
npm test
6 changes: 6 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @type {import('@commitlint/types').UserConfig}
*/
module.exports = {
extends: ['@commitlint/config-conventional'],
};
6 changes: 6 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @type {import('lint-staged').Config}
*/
module.exports = {
'*.{js,ts}': 'eslint --fix',
};
Loading

0 comments on commit 26b0127

Please sign in to comment.