-
Notifications
You must be signed in to change notification settings - Fork 4
68 lines (65 loc) · 1.92 KB
/
ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm install
- name: Run lint
run: npm run lint
- name: Run tests
run: npm run test
release:
needs: tests
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.NIO_BOT_TOKEN }}
- uses: actions/setup-node@v2
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm install
- name: Bump version
uses: TriPSs/conventional-changelog-action@v3
id: version
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
git-user-name: 'GitHub Actions'
git-user-email: '[email protected]'
version-file: package.json,package-lock.json
preset: conventionalcommits
output-file: false
- name: Set new commit hash
run: echo "SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Create release
uses: actions/create-release@v1
if: steps.version.outputs.skipped == 'false'
env:
GITHUB_TOKEN: ${{ secrets.NIO_BOT_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.tag }}
release_name: ${{ steps.version.outputs.tag }}
body: ${{ steps.version.outputs.clean_changelog }}
commitish: ${{ env.SHA }}
- name: Publish to NPM
if: steps.version.outputs.skipped == 'false'
env:
NPM_TOKEN: ${{ secrets.NIO_NPM_TOKEN }}
run: |
npm config set //registry.npmjs.org/:_authToken '${NPM_TOKEN}'
npm publish