-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (49 loc) · 1.9 KB
/
master_push.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
name: Build and Deploy
on:
push:
branches:
- master
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- name: 检出代码
uses: actions/checkout@v2
- name: 设置 Node.js 版本
uses: actions/setup-node@v2
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- name: 安装 pnpm
run: npm install -g pnpm
- name: 删除 node_modules 目录
run: rm -rf node_modules
- name: 安装依赖
run: pnpm i
- name: 项目构建
run: pnpm run build
- name: 项目部署
uses: JamesIves/github-pages-deploy-action@4.1.5
with:
branch: gh-pages
folder: dist
- name: 获取版本号
uses: tyankatsu0105/read-package-version-actions@v1
id: package-version
# 暂存 contains(github.ref, 'refs/tags/v${{ steps.package-version.outputs.version }}') 结果
- name: 判断 tag 是否存在
id: tag-exists
run: echo ::set-output name=tag-exists::$(contains(github.ref, "refs/tags/v${{ steps.package-version.outputs.version }}"))
- name: 创建 tag
run: git tag v${{ steps.package-version.outputs.version }} && git push --tags
if: steps.tag-exists.outputs.tag-exists == 'false'
- name: 发布 Release
uses: softprops/action-gh-release@v2
if: steps.tag-exists.outputs.tag-exists == 'false'
with:
name: v${{ steps.package-version.outputs.version }}
tag_name: v${{ steps.package-version.outputs.version }}
- name: 发布到 NPM
# 根据 version 判断是否需要加 --tag [alpha|beta]
run: npm publish --tag ${{ contains(steps.package-version.outputs.version, 'alpha') && 'alpha' || contains(steps.package-version.outputs.version, 'beta') && 'beta' || 'latest' }}
if: steps.tag-exists.outputs.tag-exists == 'false'