-
Notifications
You must be signed in to change notification settings - Fork 111
74 lines (65 loc) · 1.83 KB
/
build-release.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
name: Build and Release
# 定义本Action需要对仓库中的文件进行写操作的权限。
permissions:
contents: write
# 推送的tag中以v开头则执行此action
on:
push:
tags:
- "v*"
jobs:
build-release:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout code"
uses: actions/checkout@v3
# 设置node版本
- name: "Set up Node.js"
uses: actions/setup-node@v3
with:
node-version: '14.18.0'
# 安装依赖
- name: "Install dependencies"
run: npm install
# 执行构建命令
- name: "Install dependencies"
run: npm run build-rollup:prod
# 将dist目录打成zip包
- name: Zip Dist
run: zip -r dist.zip dist
# 创建Release
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
# 上传zip包
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUBTOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist.zip
asset_name: js-screen-shot-dist.zip
asset_content_type: application/zip
create-changelog:
runs-on: ubuntu-latest
# 需要等build结束后才执行此处
needs: build-release
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 16.x
# 生成版本更新日志
- run: npx changelogithub
env:
GITHUB_TOKEN: ${{secrets.GITHUBTOKEN}}