This repository has been archived by the owner on Jun 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
119 lines (102 loc) · 4.14 KB
/
github-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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Authing UI Components Github CI
on:
workflow_dispatch:
inputs:
name:
description: 'Please enter your github name'
required: true
email:
description: 'Please enter your github email'
required: true
version:
description: 'Please enter your release version'
required: true
jobs:
readyGo:
runs-on: ubuntu-latest
env:
PUBLISH_OPTS: ${{ github.ref_name == 'master' && '--verbose' || '--verbose --tag=alpha' }}
ALIYUN_ACCESS_KEY: ${{ secrets.ALIYUN_ACCESS_KEY }}
ALIYUN_ACCESS_KEY_SECRET: ${{ secrets.ALIYUN_ACCESS_KEY_SECRET }}
OSS_REGION_PROD: ${{ secrets.OSS_REGION_PROD }}
CDN_OSS_PROD: ${{ secrets.CDN_OSS_PROD }}
# React repo 编译的时候会把 warning 变成 error,导致 CI 失败
# 暂时没有用到 CI 这个变量,可以将 CI 置为 false
# 需要解决下 warning,然后把 CI 置为默认的 true
CI: false
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 12.14.0
registry-url: https://registry.npmjs.org/
- name: before scripts
run: |
echo "Current branch: ${{ github.ref_name }}"
echo "Current publish version: ${{ github.event.inputs.version }}"
echo "Current user.name: ${{ github.event.inputs.name }}"
echo "Current user.email: ${{ github.event.inputs.email }}"
- name: set git config
run: |
git config --global user.email ${{ github.event.inputs.email }}
git config --global user.name ${{ github.event.inputs.name }}
- name: install package
run: |
npm install yarn -g
yarn
- name: build lib
run: |
npm run build:lib
- name: lerna version
run: |
lerna version $VERSION --yes
env:
VERSION: ${{ github.event.inputs.version }}
- name: publish lib
if: ${{ github.ref_name == 'master' }}
run: |
npm config set //registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN
lerna publish from-package --yes
echo "publish:lib successfully 🚀"
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: publish rc
if: ${{ github.ref_name != 'master' }}
run: |
npm config set //registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN
lerna publish from-package --yes --canary --pre-dist-tag=rc --preid=rc
echo "publish:rc successfully 🚀"
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: setup oss
if: ${{ github.ref_name == 'master' }}
uses: yizhoumo/setup-ossutil@v1
with:
ossutil-version: '1.7.0' # Optional, default to '1.7.0'
endpoint: ${{ secrets.OSS_REGION_PROD }}
access-key-id: ${{ secrets.ALIYUN_ACCESS_KEY }}
access-key-secret: ${{ secrets.ALIYUN_ACCESS_KEY_SECRET }}
- name: upload oss
if: ${{ github.ref_name == 'master' }}
run: |
echo "上传打包到 CDN"
echo "VERSION: $VERSION"
ossutil cp -f -r packages/angular-components/dist/ng-ui-components/bundles oss://$CDN_OSS_PROD/packages/ng-ui-components/$VERSION/
ossutil cp -f -r packages/native-js/lib oss://$CDN_OSS_PROD/native-js-ui-components/$VERSION/
ossutil cp -f -r packages/react-components/lib oss://$CDN_OSS_PROD/packages/react-ui-components/$VERSION/
ossutil cp -f -r packages/vue-components/lib oss://$CDN_OSS_PROD/packages/vue-ui-components/$VERSION/
env:
VERSION: ${{ github.event.inputs.version }}
- name: release
if: ${{ github.ref_name == 'master' }}
uses: actions/github-script@v3
with:
script: |
github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ env.VERSION }}",
sha: context.sha
})
env:
VERSION: ${{ github.event.inputs.version }}