Skip to content

Commit

Permalink
[dsch] adding github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
DScheglov committed Jul 12, 2023
1 parent a84e29a commit 4a6d2d1
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Run Tests

on: [push, pull_request]

jobs:
test:
name: Test on Node ${{ matrix.node }} on ubuntu-latest with Mongoose@${{ matrix.mongoose }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node: [14, 16, 18]
mongoose: [5, 6, 7]

steps:
- name: Clone repo
uses: actions/checkout@v2

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

- name: Install dependencies
run: |
npm install
npm install mongoose@${{ matrix.mongoose }}
- name: Lint
run: npm run lint

- name: Test with Coverage
run: npm run test

- name: Publish on Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: node-${{ matrix.node }}
parallel: true

report-coverage:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true

publish:
needs: report-coverage
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Clone repo
uses: actions/checkout@v2

- name: Set Node.js version
uses: actions/setup-node@v1
with:
node-version: 16

- name: Check Version
run: ./version.sh

- name: Publish to npm
run: |
cp .npmrc.config .npmrc
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 2 additions & 0 deletions .npmrc.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
registry=https://registry.npmjs.org
6 changes: 6 additions & 0 deletions version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PACKAGE_NAME=$(npm pkg get name | tr -d '"')
PACKAGE_VERSION=$(npm pkg get version | tr -d '"')
PACKAGE=$PACKAGE_NAME@$PACKAGE_VERSION

PUBLISHED_VERSION=$(npm view $PACKAGE version || echo "")
if [[ -n $PUBLISHED_VERSION ]]; then echo "The version is already published"; exit 1; fi

0 comments on commit 4a6d2d1

Please sign in to comment.