-
Notifications
You must be signed in to change notification settings - Fork 11
77 lines (65 loc) · 2.29 KB
/
build_and_publish.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
name: Build and Publish
on: [push, pull_request]
env:
YARN_ENABLE_GLOBAL_CACHE: false
jobs:
build:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message, 'ci skip') }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Get the Yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/cache@v4
with:
path: ${{steps.yarn-cache-dir-path.outputs.dir}}
key: ${{runner.os}}-yarn-${{hashFiles('**/yarn.lock')}}
restore-keys: |
${{runner.os}}-yarn-
- name: Install dependencies
run: corepack yarn install --immutable
- name: Lint
run: corepack yarn lint
- name: Build library
run: corepack yarn build
- name: Build demo extension
run: corepack yarn dev:build
- name: Show files to publish
run: npm publish --dry-run
- name: Upload built library
uses: actions/upload-artifact@v4
with:
name: thu-learn-lib
path: lib/
- name: Upload built demo extension
uses: actions/upload-artifact@v4
with:
name: thu-learn-lib-demo
path: dist/
publish-to-npm:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
steps:
- uses: actions/checkout@v4
- name: Download build result
uses: actions/download-artifact@v4
with:
name: thu-learn-lib
path: lib/
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
registry-url: 'https://registry.npmjs.org'
- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}