This repository has been archived by the owner on Sep 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
84 lines (82 loc) · 2.43 KB
/
ci.yml
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Test and Publish
on: push
jobs:
unit-test-and-style-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup caching
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.OS }}-cache-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-cache-
- name: Install dependencies
run: |
yarn
- name: Run tests
env:
INFO_USER_ID: ${{ secrets.INFO_USER_ID }}
INFO_PASSWORD: ${{ secrets.INFO_PASSWORD }}
INFO_EMAIL_NAME: ${{ secrets.INFO_EMAIL_NAME }}
run: |
yarn lint
yarn test
build-and-publish:
needs: unit-test-and-style-check
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/checkout@v3
- name: Setup caching
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.OS }}-cache-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-cache-
- name: Install dependencies
run: |
yarn
- name: Build library
run: |
yarn build
- name: Prepare for publishing
id: prepare_publish
run: |
export ref='${{ github.ref }}'
export tag=${ref:11}
echo "::set-output name=tag::$tag"
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Publish to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
TAG: ${{ steps.prepare_publish.outputs.tag }}
run: |
yarn publish --new-version $TAG
- name: Build demo
run: |
yarn build-dist
zip -r demo.zip ./demo/*
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body_path: ./release
- name: Upload demo
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: demo.zip
asset_name: demo.zip
asset_content_type: application/zip