Skip to content

Commit

Permalink
Merge pull request #50 from codenaz/chore/integrate-github-actions-wo…
Browse files Browse the repository at this point in the history
…rkflow

Chore/integrate GitHub actions workflow
  • Loading branch information
codenaz authored Mar 5, 2023
2 parents da7538f + 15a9b98 commit 34f1cf1
Show file tree
Hide file tree
Showing 13 changed files with 27,654 additions and 17,078 deletions.
12 changes: 12 additions & 0 deletions .github/actions/run-tests/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "Run tests"
description: "Runs the tests"
runs:
using: "composite"
steps:
- name: Install deps
run: npm install
shell: bash

- name: Test
run: npm run test
shell: bash
27 changes: 27 additions & 0 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Create release

on:
push:
branches:
- master

jobs:
create-release:
runs-on: ubuntu-20.04
outputs:
release_created: ${{ steps.release.outputs.release_created }}
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
package-name: react-hooks-paginator
default-branch: master
changelog-path: CHANGELOG.md

deploy:
uses: ./.github/workflows/publish.yaml
needs: create-release
if: ${{ needs.create-release.outputs.release_created }}
secrets:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
60 changes: 60 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Publish to npm

on:
workflow_dispatch: {}
workflow_call:
inputs:
version:
required: true
type: string

env:
FORCE_COLOR: 1

jobs:
test:
name: Test
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 15.x, 16.x]

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

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Run tests
uses: ./.github/actions/run-tests

build-publish:
if: github.ref == 'refs/heads/master'

name: Publish
runs-on: ubuntu-latest
needs: test

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

- uses: actions/setup-node@v3
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'

- name: Install deps
run: npm ci

- name: Build project
run: npm run build

- name: Publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test

on:
pull_request:
types: [opened, labeled, synchronize]

env:
FORCE_COLOR: 1

jobs:
test:
name: Test
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x, 19.x]

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

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Run tests
uses: ./.github/actions/run-tests
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx commitlint --edit $1
Empty file added CHANGELOG.md
Empty file.
10 changes: 10 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [
2,
'always',
['chore', 'docs', 'feat', 'fix', 'style', 'test', 'release-as']
]
}
};
Loading

0 comments on commit 34f1cf1

Please sign in to comment.